@poe-platform/safe-bash 0.1.788 → 0.1.790

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 (342) hide show
  1. package/README.md +1 -1
  2. package/dist/image-ast/index.browser.js +147 -80
  3. package/dist/image-ast/index.js +147 -80
  4. package/dist/mp4-ast/mp4.d.ts +2 -0
  5. package/dist/pdf-ast/cos/parser.d.ts +1 -0
  6. package/dist/pdf-ast/cos/security.d.ts +2 -0
  7. package/dist/pdf-ast/cos/writer.d.ts +1 -0
  8. package/dist/pdf-ast/document.d.ts +3 -0
  9. package/dist/pdf-ast/edit/forms.d.ts +1 -0
  10. package/dist/pdf-ast/index.js +171 -82
  11. package/dist/safe-bash/chunks/{chunk-L5QQLNTO.js → chunk-22PI65AH.js} +2 -2
  12. package/dist/safe-bash/chunks/{chunk-Q3E6C3DX.js → chunk-2TAGYMPK.js} +49 -34
  13. package/dist/safe-bash/chunks/{chunk-Z3HX3ZBA.js → chunk-2W4HTMEK.js} +52 -48
  14. package/dist/safe-bash/chunks/{chunk-FFZXP6ZC.js → chunk-3M7L7XU2.js} +2 -2
  15. package/dist/safe-bash/chunks/{chunk-XNODZRVD.js → chunk-3QAO6UYS.js} +2 -2
  16. package/dist/safe-bash/chunks/{chunk-YPETOVQU.js → chunk-3VKFK3NF.js} +2 -2
  17. package/dist/safe-bash/chunks/chunk-5OST7NOX.js +42 -0
  18. package/dist/safe-bash/chunks/{chunk-KEBSX2AX.js → chunk-6HLURHVU.js} +2 -2
  19. package/dist/safe-bash/chunks/chunk-DYEUZE6Z.js +19 -0
  20. package/dist/safe-bash/chunks/{chunk-T2TGCHKE.js → chunk-FM3WBSZT.js} +2 -2
  21. package/dist/safe-bash/chunks/chunk-GAYRKQM6.js +22 -0
  22. package/dist/safe-bash/chunks/{chunk-Q45QCA4J.js → chunk-I3KSESCR.js} +0 -7
  23. package/dist/safe-bash/chunks/{chunk-OSKDIBQS.js → chunk-JLIMK5TD.js} +1 -1
  24. package/dist/safe-bash/chunks/{chunk-2AYZCT5X.js → chunk-JQ2FAJJT.js} +27 -23
  25. package/dist/safe-bash/chunks/{chunk-QA3NVP43.js → chunk-JRE6Z3T7.js} +2 -2
  26. package/dist/safe-bash/chunks/{chunk-DC5EHLKS.js → chunk-NDIL6T7Y.js} +5 -5
  27. package/dist/safe-bash/chunks/{chunk-747G42FY.js → chunk-OPR4UAIT.js} +2 -2
  28. package/dist/safe-bash/chunks/chunk-OSMQCYSP.js +19 -0
  29. package/dist/safe-bash/chunks/chunk-OYB332PQ.js +17 -0
  30. package/dist/safe-bash/chunks/{chunk-ZMYVCRAF.js → chunk-QTIH2AFE.js} +77 -69
  31. package/dist/safe-bash/chunks/{chunk-PYTLIUST.js → chunk-SBESXWT2.js} +43 -44
  32. package/dist/safe-bash/chunks/{chunk-4FDQJUFW.js → chunk-SDEPGTOF.js} +1 -1
  33. package/dist/safe-bash/chunks/chunk-UZU5BIJI.js +32 -0
  34. package/dist/safe-bash/chunks/{chunk-BI6JV62X.js → chunk-VCCMROTL.js} +7 -10
  35. package/dist/safe-bash/chunks/chunk-W47GHRRF.js +13 -0
  36. package/dist/safe-bash/chunks/{chunk-NPMQWZUZ.js → chunk-WS7KZIUM.js} +2 -2
  37. package/dist/safe-bash/chunks/{chunk-3PZYHMGM.js → chunk-YYAERCWS.js} +7 -7
  38. package/dist/safe-bash/chunks/{chunk-5U7JECDB.js → chunk-ZPGVEUKF.js} +8 -7
  39. package/dist/safe-bash/chunks/{csvkit-K55OYAQC.js → csvkit-USUJG62I.js} +65 -11
  40. package/dist/safe-bash/chunks/{ffmpeg-BEFTQ6DZ.js → ffmpeg-KRGG5DLH.js} +21 -10
  41. package/dist/safe-bash/chunks/{gh-HQWOWLWE.js → gh-UCFDUZCX.js} +16 -8
  42. package/dist/safe-bash/chunks/{git-UFNPAOYZ.js → git-LPAF6KDG.js} +7 -9
  43. package/dist/safe-bash/chunks/{imagemagick-53BMHH6D.js → imagemagick-KGREKK4G.js} +38 -7
  44. package/dist/safe-bash/chunks/{implementation-QUTAAYMT.js → implementation-FXDRYS5A.js} +34 -8
  45. package/dist/safe-bash/chunks/{pdfimages-4OYI6FLG.js → pdfimages-UADCF4G4.js} +12 -8
  46. package/dist/safe-bash/chunks/{pdfinfo-I7U6TQPP.js → pdfinfo-O7UWPF4W.js} +38 -13
  47. package/dist/safe-bash/chunks/{pdftk-SUA6FMHI.js → pdftk-AERXIJTN.js} +13 -8
  48. package/dist/safe-bash/chunks/{pdftoppm-4C5DGEWX.js → pdftoppm-L466JQKI.js} +17 -10
  49. package/dist/safe-bash/chunks/{pdftotext-Y4WI225Y.js → pdftotext-SUSI4WXS.js} +19 -9
  50. package/dist/safe-bash/chunks/{qpdf-IORB4RV5.js → qpdf-YL24KVRH.js} +14 -8
  51. package/dist/safe-bash/chunks/{sips-WHAMJFEU.js → sips-QXEQZERX.js} +14 -7
  52. package/dist/safe-bash/chunks/{soffice-SYEK6WJS.js → soffice-TBITRML3.js} +16 -8
  53. package/dist/safe-bash/chunks/{wkhtmltopdf-ZIICWJLF.js → wkhtmltopdf-NJA2THRC.js} +27 -7
  54. package/dist/safe-bash/command-chunks/chunk-2C5BEBPY.js +1388 -0
  55. package/dist/safe-bash/command-chunks/{chunk-FXYWQ6S4.js → chunk-2EXV2ZLV.js} +2 -2
  56. package/dist/safe-bash/command-chunks/{chunk-PFBJR2PY.js → chunk-2KRKKW5S.js} +2 -2
  57. package/dist/safe-bash/command-chunks/{chunk-4DSJDVBM.js → chunk-32F3RBUW.js} +10 -749
  58. package/dist/safe-bash/command-chunks/{chunk-L3MLMXL4.js → chunk-3ZK5F23O.js} +1 -1
  59. package/dist/safe-bash/command-chunks/{chunk-4QX6XCDD.js → chunk-4RNIZ3RT.js} +79 -0
  60. package/dist/safe-bash/command-chunks/{chunk-D7TADAYG.js → chunk-64LG3EVJ.js} +17 -0
  61. package/dist/safe-bash/command-chunks/{chunk-TOSM3T3A.js → chunk-6EASC5EC.js} +20 -9
  62. package/dist/safe-bash/command-chunks/{chunk-ZF3ZVGQC.js → chunk-7JRITHKW.js} +150 -80
  63. package/dist/safe-bash/command-chunks/{chunk-IJ3FXP4Q.js → chunk-A3ZX6SCY.js} +1 -1
  64. package/dist/safe-bash/{chunks/chunk-LD76P7AG.js → command-chunks/chunk-AKDMCNX4.js} +74 -39
  65. package/dist/safe-bash/command-chunks/{chunk-KSIGF4AG.js → chunk-BK4CMEE6.js} +1 -1
  66. package/dist/safe-bash/command-chunks/{chunk-JUDOV5MJ.js → chunk-CBDVLMJB.js} +1 -1
  67. package/dist/safe-bash/command-chunks/{chunk-XGMWWUHV.js → chunk-CZ5DAK4K.js} +1 -1
  68. package/dist/safe-bash/command-chunks/{chunk-Z57TV6TC.js → chunk-EZ2DTOLI.js} +4 -2
  69. package/dist/safe-bash/command-chunks/{chunk-ADCGH6A7.js → chunk-FH3D75FC.js} +1 -1
  70. package/dist/safe-bash/command-chunks/{chunk-WYJTWJZ5.js → chunk-G3G6W5ZE.js} +1 -1
  71. package/dist/safe-bash/command-chunks/{chunk-3HDIDEUJ.js → chunk-GF54KE2M.js} +1 -1
  72. package/dist/safe-bash/command-chunks/chunk-H4LWTITX.js +169 -0
  73. package/dist/safe-bash/command-chunks/chunk-I2MQNBGR.js +145 -0
  74. package/dist/safe-bash/command-chunks/{chunk-Z7TYZG3A.js → chunk-IHHTTQX6.js} +5 -3
  75. package/dist/safe-bash/command-chunks/{chunk-5GRLAARV.js → chunk-IOXI5ZAJ.js} +1 -1
  76. package/dist/safe-bash/command-chunks/{chunk-INDIFLBW.js → chunk-JTAGNROA.js} +4 -0
  77. package/dist/safe-bash/command-chunks/{chunk-Y5IHIAY3.js → chunk-MDPIOQUD.js} +12 -8
  78. package/dist/safe-bash/command-chunks/chunk-PGEYORBZ.js +25 -0
  79. package/dist/safe-bash/command-chunks/chunk-QI4MGIN6.js +6 -0
  80. package/dist/safe-bash/command-chunks/chunk-QM4UZF3C.js +753 -0
  81. package/dist/safe-bash/command-chunks/chunk-QTYZAWSB.js +91 -0
  82. package/dist/safe-bash/command-chunks/chunk-SNK7K3XW.js +90 -0
  83. package/dist/safe-bash/command-chunks/chunk-T5OLGM43.js +314 -0
  84. package/dist/safe-bash/command-chunks/chunk-TB7IFMUZ.js +802 -0
  85. package/dist/safe-bash/command-chunks/{chunk-YNT4ZJHW.js → chunk-TPPBPIWL.js} +3 -3
  86. package/dist/safe-bash/command-chunks/chunk-VMK4XVKO.js +82 -0
  87. package/dist/safe-bash/command-chunks/chunk-VNSJKXDU.js +130 -0
  88. package/dist/safe-bash/command-chunks/{chunk-2LP3VMPA.js → chunk-WFDW4XXD.js} +1 -17
  89. package/dist/safe-bash/command-chunks/chunk-WR37IS4O.js +318 -0
  90. package/dist/safe-bash/command-chunks/chunk-YFNTMH6Z.js +6 -0
  91. package/dist/safe-bash/commands/basic.js +148 -48
  92. package/dist/safe-bash/commands/bytes/compression/index.js +5 -6
  93. package/dist/safe-bash/commands/cmp.d.ts +2 -3
  94. package/dist/safe-bash/commands/cmp.js +2 -689
  95. package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
  96. package/dist/safe-bash/commands/docx/index.browser.js +4 -47
  97. package/dist/safe-bash/commands/docx/index.d.ts +2 -24
  98. package/dist/safe-bash/commands/docx/index.js +2 -41
  99. package/dist/safe-bash/commands/docx/io.d.ts +1 -14
  100. package/dist/safe-bash/commands/docx/io.js +1 -15
  101. package/dist/safe-bash/commands/factor/index.browser.js +2 -2
  102. package/dist/safe-bash/commands/getopt/index.browser.js +2 -2
  103. package/dist/safe-bash/commands/hexdump/index.browser.js +2 -2
  104. package/dist/safe-bash/commands/iconv/index.browser.js +2 -2
  105. package/dist/safe-bash/commands/line-endings/index.browser.js +2 -2
  106. package/dist/safe-bash/commands/llm/command.d.ts +1 -4
  107. package/dist/safe-bash/commands/llm/command.js +1 -248
  108. package/dist/safe-bash/commands/llm/elevenlabs-stream.d.ts +1 -2
  109. package/dist/safe-bash/commands/llm/elevenlabs-stream.js +1 -117
  110. package/dist/safe-bash/commands/llm/elevenlabs.d.ts +1 -15
  111. package/dist/safe-bash/commands/llm/elevenlabs.js +1 -123
  112. package/dist/safe-bash/commands/llm/index.browser.js +20 -15
  113. package/dist/safe-bash/commands/llm/index.d.ts +1 -6
  114. package/dist/safe-bash/commands/llm/index.js +1 -4
  115. package/dist/safe-bash/commands/llm/mime.d.ts +1 -2
  116. package/dist/safe-bash/commands/llm/mime.js +1 -136
  117. package/dist/safe-bash/commands/llm/openai-http.d.ts +1 -8
  118. package/dist/safe-bash/commands/llm/openai-http.js +1 -143
  119. package/dist/safe-bash/commands/llm/openai-sse.d.ts +1 -3
  120. package/dist/safe-bash/commands/llm/openai-sse.js +1 -78
  121. package/dist/safe-bash/commands/llm/openai.d.ts +1 -14
  122. package/dist/safe-bash/commands/llm/openai.js +1 -288
  123. package/dist/safe-bash/commands/llm/providers/elevenlabs.d.ts +1 -1
  124. package/dist/safe-bash/commands/llm/providers/elevenlabs.js +1 -1
  125. package/dist/safe-bash/commands/llm/providers/index.browser.js +6 -6
  126. package/dist/safe-bash/commands/llm/providers/index.d.ts +1 -3
  127. package/dist/safe-bash/commands/llm/providers/index.js +1 -2
  128. package/dist/safe-bash/commands/llm/providers/openai.d.ts +1 -1
  129. package/dist/safe-bash/commands/llm/providers/openai.js +1 -1
  130. package/dist/safe-bash/commands/llm/providers/shared.d.ts +1 -23
  131. package/dist/safe-bash/commands/llm/providers/shared.js +1 -65
  132. package/dist/safe-bash/commands/llm/service.d.ts +1 -37
  133. package/dist/safe-bash/commands/llm/service.js +1 -151
  134. package/dist/safe-bash/commands/llm/types.d.ts +1 -52
  135. package/dist/safe-bash/commands/llm/types.js +1 -1
  136. package/dist/safe-bash/commands/mdq/index.browser.js +3 -3
  137. package/dist/safe-bash/commands/media/index.browser.js +1 -1
  138. package/dist/safe-bash/commands/network/index.browser.js +9 -9
  139. package/dist/safe-bash/commands/network/types.d.ts +2 -40
  140. package/dist/safe-bash/commands/node/index.browser.js +6 -8
  141. package/dist/safe-bash/commands/op/index.browser.js +3 -3
  142. package/dist/safe-bash/commands/op/index.js +12 -28
  143. package/dist/safe-bash/commands/pptx/index.d.ts +2 -28
  144. package/dist/safe-bash/commands/pptx/index.js +2 -152
  145. package/dist/safe-bash/commands/pr/index.browser.js +2 -2
  146. package/dist/safe-bash/commands/printf-float.d.ts +1 -0
  147. package/dist/safe-bash/commands/printf-float.js +48 -38
  148. package/dist/safe-bash/commands/printf-format.js +9 -6
  149. package/dist/safe-bash/commands/printf-quote.d.ts +3 -0
  150. package/dist/safe-bash/commands/printf-quote.js +62 -0
  151. package/dist/safe-bash/commands/printf-wide.d.ts +5 -0
  152. package/dist/safe-bash/commands/printf-wide.js +41 -0
  153. package/dist/safe-bash/commands/python/index.browser.js +8 -8
  154. package/dist/safe-bash/commands/python/worker.browser.js +2 -2
  155. package/dist/safe-bash/commands/truncate.d.ts +2 -3
  156. package/dist/safe-bash/commands/truncate.js +2 -686
  157. package/dist/safe-bash/commands/tsort/index.browser.js +2 -2
  158. package/dist/safe-bash/commands/xml/index.browser.js +2 -2
  159. package/dist/safe-bash/commands/yq/index.browser.js +3 -3
  160. package/dist/safe-bash/contracts/diagnostics.d.ts +2 -0
  161. package/dist/safe-bash/contracts/diagnostics.js +2 -0
  162. package/dist/safe-bash/contracts/runtime-control.d.ts +2 -0
  163. package/dist/safe-bash/contracts/runtime-control.js +2 -0
  164. package/dist/safe-bash/core.browser.d.ts +1 -1
  165. package/dist/safe-bash/core.browser.js +10645 -14065
  166. package/dist/safe-bash/core.d.ts +10 -1
  167. package/dist/safe-bash/core.js +0 -1
  168. package/dist/safe-bash/jobs.browser.js +5 -4
  169. package/dist/safe-bash/opt-in/commands/cmp/index.d.ts +6 -2
  170. package/dist/safe-bash/opt-in/commands/cmp/index.js +776 -79
  171. package/dist/safe-bash/opt-in/commands/cmp/options.d.ts +0 -12
  172. package/dist/safe-bash/opt-in/commands/cmp/options.js +0 -153
  173. package/dist/safe-bash/opt-in/commands/truncate/index.d.ts +8 -3
  174. package/dist/safe-bash/opt-in/commands/truncate/index.js +790 -272
  175. package/dist/safe-bash/opt-in/commands/truncate/sync.d.ts +1 -0
  176. package/dist/safe-bash/opt-in/commands/truncate/sync.js +60 -0
  177. package/dist/safe-bash/optional-host.browser.js +61 -80
  178. package/dist/safe-bash/optional-host.d.ts +3 -1
  179. package/dist/safe-bash/optional-host.js +3 -1
  180. package/dist/safe-bash/shell/runtime.js +44 -18
  181. package/dist/safe-bash/yq-browser/index.js +1 -1
  182. package/dist/safe-bash-checksum-engine/index.d.ts +1 -1
  183. package/dist/safe-bash-checksum-engine/index.js +14 -2
  184. package/dist/safe-bash-command-bzip2/index.js +2 -1
  185. package/dist/safe-bash-command-cmp/index.d.ts +10 -0
  186. package/dist/safe-bash-command-cmp/index.js +796 -0
  187. package/dist/safe-bash-command-cmp/options.d.ts +12 -0
  188. package/dist/safe-bash-command-cmp/options.js +42 -0
  189. package/dist/safe-bash-command-csvcut/index.js +11 -8
  190. package/dist/safe-bash-command-csvgrep/index.js +35 -7
  191. package/dist/safe-bash-command-csvkit/codecs/python.js +4 -3
  192. package/dist/safe-bash-command-csvkit/codecs/utf8.js +3 -2
  193. package/dist/safe-bash-command-csvkit/index.js +80 -324
  194. package/dist/safe-bash-command-csvkit/python-regex.d.ts +5 -0
  195. package/dist/safe-bash-command-csvkit/python-regex.js +14 -0
  196. package/dist/safe-bash-command-csvkit/runtime.d.ts +1 -0
  197. package/dist/safe-bash-command-csvkit/sync-support.js +4 -2
  198. package/dist/safe-bash-command-diff3/index.js +3 -0
  199. package/dist/safe-bash-command-docx/LICENSE +21 -0
  200. package/dist/safe-bash-command-docx/index.d.ts +30 -0
  201. package/dist/safe-bash-command-docx/index.js +67 -0
  202. package/dist/safe-bash-command-docx/io.d.ts +14 -0
  203. package/dist/safe-bash-command-docx/io.js +26 -0
  204. package/dist/safe-bash-command-envsubst/index.js +34 -3
  205. package/dist/safe-bash-command-exiftool/index.js +3 -0
  206. package/dist/safe-bash-command-ffmpeg/index.js +8073 -7940
  207. package/dist/safe-bash-command-fold/family.js +1 -1
  208. package/dist/safe-bash-command-fold/index.js +1 -1
  209. package/dist/safe-bash-command-git/git_rust.wasm +0 -0
  210. package/dist/safe-bash-command-git/wasm.generated.js +1 -1
  211. package/dist/safe-bash-command-htmlq/index.js +5 -0
  212. package/dist/safe-bash-command-imagemagick/index.d.ts +25 -21
  213. package/dist/safe-bash-command-imagemagick/index.js +671 -273
  214. package/dist/safe-bash-command-llm/LICENSE +21 -0
  215. package/dist/safe-bash-command-llm/command.d.ts +5 -0
  216. package/dist/safe-bash-command-llm/command.js +14 -0
  217. package/dist/safe-bash-command-llm/configuration.d.ts +18 -0
  218. package/dist/safe-bash-command-llm/elevenlabs-stream.d.ts +2 -0
  219. package/dist/safe-bash-command-llm/elevenlabs-stream.js +7 -0
  220. package/dist/safe-bash-command-llm/elevenlabs.d.ts +15 -0
  221. package/dist/safe-bash-command-llm/elevenlabs.js +10 -0
  222. package/dist/safe-bash-command-llm/index.d.ts +10 -0
  223. package/dist/safe-bash-command-llm/index.js +46 -0
  224. package/dist/safe-bash-command-llm/mime.d.ts +2 -0
  225. package/dist/safe-bash-command-llm/mime.js +9 -0
  226. package/dist/safe-bash-command-llm/model-options.d.ts +3 -0
  227. package/dist/safe-bash-command-llm/openai-http.d.ts +8 -0
  228. package/dist/safe-bash-command-llm/openai-http.js +17 -0
  229. package/dist/safe-bash-command-llm/openai-sse.d.ts +3 -0
  230. package/dist/safe-bash-command-llm/openai-sse.js +8 -0
  231. package/dist/safe-bash-command-llm/openai.d.ts +14 -0
  232. package/dist/safe-bash-command-llm/openai.js +12 -0
  233. package/dist/safe-bash-command-llm/providers/elevenlabs.d.ts +1 -0
  234. package/dist/safe-bash-command-llm/providers/elevenlabs.js +11 -0
  235. package/dist/safe-bash-command-llm/providers/index.d.ts +3 -0
  236. package/dist/safe-bash-command-llm/providers/index.js +24 -0
  237. package/dist/safe-bash-command-llm/providers/openai.d.ts +1 -0
  238. package/dist/safe-bash-command-llm/providers/openai.js +13 -0
  239. package/dist/safe-bash-command-llm/providers/shared.d.ts +23 -0
  240. package/dist/safe-bash-command-llm/providers/shared.js +13 -0
  241. package/dist/safe-bash-command-llm/schemas.d.ts +2 -0
  242. package/dist/safe-bash-command-llm/service.d.ts +42 -0
  243. package/dist/safe-bash-command-llm/service.js +9 -0
  244. package/dist/safe-bash-command-llm/templates.d.ts +27 -0
  245. package/dist/safe-bash-command-llm/types.d.ts +87 -0
  246. package/dist/safe-bash-command-llm/types.js +6 -0
  247. package/dist/safe-bash-command-mmdc/command.d.ts +4 -0
  248. package/dist/safe-bash-command-mmdc/index.d.ts +1 -1
  249. package/dist/safe-bash-command-mmdc/index.js +7134 -6699
  250. package/dist/safe-bash-command-mmdc/layout.d.ts +1 -0
  251. package/dist/safe-bash-command-mmdc/parser.d.ts +1 -0
  252. package/dist/safe-bash-command-mmdc/png.d.ts +3 -0
  253. package/dist/safe-bash-command-mmdc/raster.d.ts +1 -0
  254. package/dist/safe-bash-command-mmdc/svg.d.ts +1 -0
  255. package/dist/safe-bash-command-op/index.js +19 -14
  256. package/dist/safe-bash-command-pandoc/command.js +3 -3
  257. package/dist/safe-bash-command-pandoc/index.js +3 -3
  258. package/dist/safe-bash-command-pdfimages/index.d.ts +7 -1
  259. package/dist/safe-bash-command-pdfimages/index.js +210 -113
  260. package/dist/safe-bash-command-pdfinfo/index.d.ts +24 -20
  261. package/dist/safe-bash-command-pdfinfo/index.js +517 -241
  262. package/dist/safe-bash-command-pdftk/index.d.ts +7 -3
  263. package/dist/safe-bash-command-pdftk/index.js +261 -125
  264. package/dist/safe-bash-command-pdftoppm/index.d.ts +15 -7
  265. package/dist/safe-bash-command-pdftoppm/index.js +326 -189
  266. package/dist/safe-bash-command-pdftotext/index.d.ts +9 -5
  267. package/dist/safe-bash-command-pdftotext/index.js +237 -107
  268. package/dist/safe-bash-command-pptx/LICENSE +21 -0
  269. package/dist/safe-bash-command-pptx/index.d.ts +33 -0
  270. package/dist/safe-bash-command-pptx/index.js +168 -0
  271. package/dist/safe-bash-command-qpdf/index.d.ts +9 -3
  272. package/dist/safe-bash-command-qpdf/index.js +254 -130
  273. package/dist/safe-bash-command-sha512sum/index.js +12 -475
  274. package/dist/safe-bash-command-sips/index.d.ts +9 -5
  275. package/dist/safe-bash-command-sips/index.js +65 -46
  276. package/dist/safe-bash-command-soffice/index.d.ts +9 -3
  277. package/dist/safe-bash-command-soffice/index.js +66 -25
  278. package/dist/safe-bash-command-sqlite3/engine.d.ts +9 -0
  279. package/dist/safe-bash-command-sqlite3/index.d.ts +1 -0
  280. package/dist/safe-bash-command-sqlite3/index.js +851 -352
  281. package/dist/safe-bash-command-ssconvert/formats/xls.js +3 -3
  282. package/dist/safe-bash-command-ssconvert/index.js +147 -80
  283. package/dist/safe-bash-command-timeout/index.js +3 -3
  284. package/dist/safe-bash-command-truncate/index.d.ts +8 -3
  285. package/dist/safe-bash-command-truncate/index.js +790 -272
  286. package/dist/safe-bash-command-truncate/sync.d.ts +1 -0
  287. package/dist/safe-bash-command-truncate/sync.js +60 -0
  288. package/dist/safe-bash-command-wkhtmltopdf/index.js +239 -118
  289. package/dist/safe-bash-command-wkhtmltopdf/pdf-renderer.d.ts +1 -1
  290. package/dist/safe-bash-command-xxd/index.js +78 -20
  291. package/dist/safe-bash-command-xz/command.d.ts +4 -0
  292. package/dist/safe-bash-command-xz/index.d.ts +1 -1
  293. package/dist/safe-bash-command-xz/index.js +1 -1
  294. package/dist/safe-bash-compression-engine/bounded-codec.js +3 -3
  295. package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
  296. package/dist/safe-bash-compression-engine/files.js +6 -6
  297. package/dist/safe-bash-compression-engine/index.js +5 -5
  298. package/dist/safe-bash-compression-engine/operand.js +6 -6
  299. package/dist/safe-bash-compression-engine/stream.js +5 -5
  300. package/dist/safe-bash-compression-engine/zstd-decode.js +4 -4
  301. package/dist/safe-bash-contracts/command.js +3 -3
  302. package/dist/safe-bash-contracts/default-executor.d.ts +5 -0
  303. package/dist/safe-bash-contracts/default-executor.js +37 -0
  304. package/dist/safe-bash-contracts/diagnostics.js +3 -3
  305. package/dist/safe-bash-contracts/escaping.js +9 -9
  306. package/dist/safe-bash-contracts/filesystem-descriptor.js +3 -3
  307. package/dist/safe-bash-contracts/filesystem-output.js +8 -8
  308. package/dist/safe-bash-contracts/http.d.ts +41 -0
  309. package/dist/safe-bash-contracts/http.js +6 -0
  310. package/dist/safe-bash-contracts/index.js +21 -19
  311. package/dist/safe-bash-contracts/io.d.ts +12 -0
  312. package/dist/safe-bash-contracts/io.js +4 -1
  313. package/dist/safe-bash-contracts/output.js +3 -2
  314. package/dist/safe-bash-contracts/runtime-control.js +2 -2
  315. package/dist/safe-bash-contracts/signals.js +1 -1
  316. package/dist/safe-bash-contracts/yield.d.ts +1 -0
  317. package/dist/safe-bash-contracts/yield.js +3 -1
  318. package/dist/safe-bash-csv-engine/index.d.ts +10 -1
  319. package/dist/safe-bash-csv-engine/index.js +78 -6
  320. package/dist/safe-bash-io-engine/commands/search/requirements.js +3 -3
  321. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +3 -3
  322. package/dist/safe-bash-io-engine/gnu-information.d.ts +1 -1
  323. package/dist/safe-bash-io-engine/gnu-information.js +1 -1
  324. package/dist/safe-bash-io-engine/internal.d.ts +1 -1
  325. package/dist/safe-bash-io-engine/internal.js +2 -2
  326. package/dist/safe-bash-query-engine/index.js +5 -5
  327. package/dist/safe-bash-query-engine/interpreter.js +3 -3
  328. package/dist/safe-bash-query-engine/query-core.js +5 -5
  329. package/package.json +2 -2
  330. package/dist/safe-bash/chunks/chunk-2G2T5MEM.js +0 -14
  331. package/dist/safe-bash/chunks/chunk-FJZNUUOQ.js +0 -81
  332. package/dist/safe-bash/chunks/chunk-GJWUEOT6.js +0 -14
  333. package/dist/safe-bash/chunks/chunk-LAPF2XE6.js +0 -14
  334. package/dist/safe-bash/chunks/chunk-O6356Z27.js +0 -37
  335. package/dist/safe-bash/chunks/chunk-S2LSZFZ6.js +0 -758
  336. package/dist/safe-bash/chunks/chunk-T3VDYWKZ.js +0 -21
  337. package/dist/safe-bash/chunks/chunk-VYW4Q6KF.js +0 -12
  338. package/dist/safe-bash/chunks/chunk-WHURJBET.js +0 -409
  339. package/dist/safe-bash/opt-in/commands/cmp/compare.js +0 -95
  340. package/dist/safe-bash/opt-in/commands/cmp/io.js +0 -218
  341. package/dist/safe-bash/command-chunks/{chunk-RTOJNFFL.js → chunk-KNI4GRXF.js} +7 -7
  342. package/dist/safe-bash/command-chunks/{chunk-DEH3CMGL.js → chunk-QJ3ONEBI.js} +3 -3
@@ -1,21 +0,0 @@
1
- import {
2
- __reExport,
3
- init_platform
4
- } from "./chunk-Q45QCA4J.js";
5
-
6
- // packages/safe-bash/src/contracts/command.ts
7
- var command_exports = {};
8
- init_platform();
9
- __reExport(command_exports, command_star);
10
- import * as command_star from "../../safe-bash-contracts/command.js";
11
-
12
- // packages/safe-bash/src/contracts/io.ts
13
- var io_exports = {};
14
- init_platform();
15
- __reExport(io_exports, io_star);
16
- import * as io_star from "../../safe-bash-contracts/io.js";
17
-
18
- export {
19
- command_exports,
20
- io_exports
21
- };
@@ -1,12 +0,0 @@
1
- import {
2
- init_platform
3
- } from "./chunk-Q45QCA4J.js";
4
-
5
- // packages/safe-bash/src/commands/llm/providers/index.ts
6
- init_platform();
7
-
8
- // packages/safe-bash/src/commands/llm/providers/openai.ts
9
- init_platform();
10
-
11
- // packages/safe-bash/src/commands/llm/providers/elevenlabs.ts
12
- init_platform();
@@ -1,409 +0,0 @@
1
- import {
2
- escaping_exports
3
- } from "./chunk-2G2T5MEM.js";
4
- import {
5
- contracts_exports
6
- } from "./chunk-FJZNUUOQ.js";
7
- import {
8
- yield_exports
9
- } from "./chunk-LAPF2XE6.js";
10
- import {
11
- internal_exports
12
- } from "./chunk-GJWUEOT6.js";
13
- import {
14
- acceptsMimeType,
15
- sniffMimeType
16
- } from "./chunk-LD76P7AG.js";
17
- import {
18
- init_platform
19
- } from "./chunk-Q45QCA4J.js";
20
-
21
- // packages/safe-bash/src/commands/llm/index.ts
22
- init_platform();
23
-
24
- // packages/safe-bash/src/commands/llm/command.ts
25
- init_platform();
26
-
27
- // packages/safe-bash/src/commands/llm/service.ts
28
- init_platform();
29
- function abortable(start, signal) {
30
- signal.throwIfAborted();
31
- return new Promise((resolve, reject) => {
32
- const abort = () => {
33
- signal.removeEventListener("abort", abort);
34
- reject(signal.reason);
35
- };
36
- signal.addEventListener("abort", abort, { once: true });
37
- Promise.resolve().then(() => {
38
- signal.throwIfAborted();
39
- return start();
40
- }).then(
41
- (value) => {
42
- signal.removeEventListener("abort", abort);
43
- if (signal.aborted) reject(signal.reason);
44
- else resolve(value);
45
- },
46
- (error) => {
47
- signal.removeEventListener("abort", abort);
48
- reject(signal.aborted ? signal.reason : error);
49
- }
50
- );
51
- if (signal.aborted) abort();
52
- });
53
- }
54
- function validateMetadata(value) {
55
- for (const field of [value.usage, value.metadata]) {
56
- if (field !== void 0 && (!field || typeof field !== "object" || Array.isArray(field))) throw new TypeError("Invalid LLM response metadata");
57
- }
58
- }
59
- function validateOptions(options) {
60
- for (const [key, value] of Object.entries(options)) {
61
- if (!key || value !== null && !["string", "number", "boolean"].includes(typeof value) || typeof value === "number" && !Number.isFinite(value)) {
62
- throw new TypeError(`Invalid model option ${key}: expected a finite scalar`);
63
- }
64
- }
65
- }
66
- function createLlmService(options) {
67
- const models = [];
68
- const lookup = /* @__PURE__ */ new Map();
69
- const defaultModel = options.defaultModel;
70
- for (const provider of options.providers) {
71
- if (!provider.name || typeof provider.complete !== "function") throw new TypeError("Providers require a name and complete function");
72
- for (const declared of provider.models) {
73
- if (!declared.id) throw new TypeError("Models require a nonempty id");
74
- const model = Object.freeze({
75
- ...declared,
76
- ...declared.capabilities ? { capabilities: Object.freeze([...declared.capabilities]) } : {},
77
- ...declared.aliases ? { aliases: Object.freeze([...declared.aliases]) } : {},
78
- ...declared.attachmentTypes ? { attachmentTypes: Object.freeze([...declared.attachmentTypes]) } : {}
79
- });
80
- const entry = Object.freeze({ provider, model });
81
- for (const name of /* @__PURE__ */ new Set([model.id, `${provider.name}/${model.id}`, ...model.aliases ?? []])) {
82
- if (!name) throw new TypeError("Model aliases must not be empty");
83
- if (lookup.has(name)) throw new Error(`Duplicate model id or alias: ${name}`);
84
- lookup.set(name, entry);
85
- }
86
- models.push(entry);
87
- }
88
- }
89
- return Object.freeze({
90
- version: 1,
91
- models: Object.freeze(models),
92
- resolve(model) {
93
- const selected = model ?? defaultModel;
94
- if (selected === void 0) throw new Error("No model selected; use --model or configure defaultModel");
95
- const entry = lookup.get(selected);
96
- if (!entry) throw new Error(`Unknown model: ${selected}`);
97
- return entry;
98
- },
99
- complete(request) {
100
- request.signal.throwIfAborted();
101
- validateOptions(request.options);
102
- if (typeof request.prompt !== "string" || request.system !== void 0 && typeof request.system !== "string") throw new TypeError("Invalid LLM prompt");
103
- const entry = this.resolve(request.model);
104
- if (request.messages?.length && !entry.model.capabilities?.includes("messages")) throw new Error(`Model ${entry.model.id} does not support messages`);
105
- if (request.messages?.some((message) => !["system", "user", "assistant"].includes(message.role) || typeof message.content !== "string")) throw new TypeError("Invalid LLM message");
106
- if (request.schema !== void 0) {
107
- if (!entry.model.capabilities?.includes("schema")) throw new Error(`Model ${entry.model.id} does not support schema`);
108
- if (!request.schema || typeof request.schema !== "object" || Array.isArray(request.schema)) throw new TypeError("Invalid LLM schema");
109
- }
110
- for (const attachment of request.attachments) {
111
- if (!acceptsMimeType(entry.model.attachmentTypes ?? [], attachment.mimeType)) {
112
- throw new Error(`Model ${entry.model.id} does not accept ${attachment.mimeType}`);
113
- }
114
- }
115
- const { maxOutputBytes: ignoredMaxOutputBytes, ...input } = request;
116
- return entry.provider.complete({ ...input, model: entry.model.id });
117
- },
118
- async *stream(request) {
119
- const limit = request.maxOutputBytes ?? Infinity;
120
- if (limit !== Infinity && (!Number.isSafeInteger(limit) || limit < 0)) throw new RangeError("Invalid LLM output limit");
121
- const entry = this.resolve(request.model);
122
- const iterator = this.complete(request)[Symbol.asyncIterator]();
123
- let ended = false;
124
- let size = 0;
125
- try {
126
- while (true) {
127
- request.signal.throwIfAborted();
128
- const result = await abortable(() => iterator.next(), request.signal);
129
- request.signal.throwIfAborted();
130
- if (result.done) {
131
- ended = true;
132
- const metadata = result.value;
133
- if (metadata !== void 0 && (!metadata || typeof metadata !== "object" || Array.isArray(metadata))) throw new TypeError("Invalid LLM response metadata");
134
- const details = metadata;
135
- if (details) validateMetadata(details);
136
- yield { type: "response", response: { model: entry.model.id, ...details?.usage ? { usage: details.usage } : {}, ...details?.metadata ? { metadata: details.metadata } : {} } };
137
- return;
138
- }
139
- const chunk = result.value;
140
- const text = (entry.model.outputType ?? "text/plain").toLowerCase().startsWith("text/");
141
- if (text ? typeof chunk !== "string" : !(chunk instanceof Uint8Array)) throw new TypeError("Provider returned an incompatible LLM output chunk");
142
- size += typeof chunk === "string" ? new TextEncoder().encode(chunk).length : chunk.byteLength;
143
- if (size > limit) throw new RangeError("LLM output byte limit exceeded");
144
- yield typeof chunk === "string" ? { type: "text", text: chunk } : { type: "bytes", data: new Uint8Array(chunk) };
145
- }
146
- } finally {
147
- if (!ended) {
148
- const closing = Promise.resolve().then(() => iterator.return?.());
149
- if (request.signal.aborted) void closing.catch(() => void 0);
150
- else await closing;
151
- }
152
- }
153
- },
154
- async embed(request) {
155
- request.signal.throwIfAborted();
156
- validateOptions(request.options);
157
- if (!Array.isArray(request.inputs) || Array.from(request.inputs).some((input) => typeof input !== "string")) throw new TypeError("Embedding inputs must be strings");
158
- const entry = this.resolve(request.model);
159
- if (!entry.model.capabilities?.includes("embed") || !entry.provider.embed) throw new Error(`Model ${entry.model.id} does not support embeddings`);
160
- const embed = entry.provider.embed.bind(entry.provider);
161
- const result = await abortable(() => embed({ ...request, model: entry.model.id }), request.signal);
162
- request.signal.throwIfAborted();
163
- if (result.model !== entry.model.id || !Array.isArray(result.vectors) || result.vectors.length !== request.inputs.length || Array.from(result.vectors).some((vector) => !Array.isArray(vector) || !vector.length || Array.from(vector).some((value) => typeof value !== "number" || !Number.isFinite(value)) || vector.length !== result.vectors[0]?.length)) throw new TypeError("Invalid embedding response");
164
- validateMetadata(result);
165
- return result;
166
- }
167
- });
168
- }
169
-
170
- // packages/safe-bash/src/commands/llm/command.ts
171
- async function parse(length, text, step) {
172
- const parsed = { prompt: "", options: /* @__PURE__ */ Object.create(null), attachments: [] };
173
- const operands = [];
174
- let ended = false;
175
- for (let index = 0; index < length; index++) {
176
- await step();
177
- const argument = text(index);
178
- if (ended || !argument.startsWith("-") || argument === "-") {
179
- operands.push(argument);
180
- continue;
181
- }
182
- if (argument === "--") {
183
- ended = true;
184
- continue;
185
- }
186
- const equals = argument.indexOf("=");
187
- const long = argument.startsWith("--");
188
- const flag = long ? argument.slice(0, equals < 0 ? void 0 : equals) : argument.slice(0, 2);
189
- const attached = long ? equals < 0 ? void 0 : argument.slice(equals + 1) : argument.length > 2 ? argument.slice(2) : void 0;
190
- const take = () => {
191
- if (++index >= length) throw new Error(`Option ${flag} requires an argument`);
192
- return text(index);
193
- };
194
- if (!["-m", "--model", "-s", "--system", "-o", "--option", "-a", "--attachment", "--at"].includes(flag)) throw new Error(`Unknown option: ${flag}`);
195
- const value = attached ?? take();
196
- if (flag === "-m" || flag === "--model") parsed.model = value;
197
- else if (flag === "-s" || flag === "--system") parsed.system = value;
198
- else if (flag === "-o" || flag === "--option") parsed.options[value] = take();
199
- else if (flag === "--at") parsed.attachments.push({ path: value, mimeType: take() });
200
- else parsed.attachments.push({ path: value });
201
- }
202
- parsed.prompt = operands.join(" ");
203
- return parsed;
204
- }
205
- async function interrupted(start, signal) {
206
- signal.throwIfAborted();
207
- return new Promise((resolve, reject) => {
208
- const aborted = () => reject(signal.reason);
209
- signal.addEventListener("abort", aborted, { once: true });
210
- Promise.resolve().then(() => {
211
- signal.throwIfAborted();
212
- return start();
213
- }).then(
214
- (value) => {
215
- signal.removeEventListener("abort", aborted);
216
- resolve(value);
217
- },
218
- (error) => {
219
- signal.removeEventListener("abort", aborted);
220
- reject(error);
221
- }
222
- );
223
- });
224
- }
225
- async function execute(context, service) {
226
- context.signal.throwIfAborted();
227
- const controller = new AbortController();
228
- const operation = (0, contracts_exports.createOutputOperation)(context, context.stdout);
229
- const signal = AbortSignal.any([operation.signal, controller.signal]);
230
- (0, yield_exports.inheritYieldCheckpoint)(context.signal, signal);
231
- let iterator;
232
- let closed = false;
233
- let ended = false;
234
- operation.registerCleanup(() => {
235
- if (closed) return;
236
- closed = true;
237
- controller.abort(new Error("llm request closed"));
238
- if (!ended && iterator) {
239
- const resource = iterator;
240
- void Promise.resolve().then(() => resource.return?.()).catch(() => {
241
- });
242
- }
243
- });
244
- let work = 0;
245
- const step = async () => {
246
- signal.throwIfAborted();
247
- if (closed) throw new Error("LLM invocation is closed");
248
- work++;
249
- if (work % 256 === 0) await (0, yield_exports.yieldTurn)(signal);
250
- };
251
- let writing = false;
252
- const write = async (chunk) => {
253
- writing = true;
254
- await operation.output.write(chunk);
255
- writing = false;
256
- };
257
- const emitText = async (text) => {
258
- for (let offset = 0; offset < text.length; ) {
259
- await step();
260
- let end = Math.min(text.length, offset + 16384);
261
- const last = text.charCodeAt(end - 1);
262
- if (end < text.length && last >= 55296 && last <= 56319) end--;
263
- await write(new TextEncoder().encode(text.slice(offset, end)));
264
- offset = end;
265
- }
266
- };
267
- let inputBytes = 0;
268
- const inputLimit = context.inputBudget?.maxBytes ?? Infinity;
269
- const checkInput = (size) => {
270
- context.inputBudget?.check(inputBytes + size);
271
- if (size > inputLimit - inputBytes) throw new contracts_exports.FsError("EFBIG", { message: "llm input byte limit exceeded" });
272
- };
273
- const admitInput = (size) => {
274
- checkInput(size);
275
- inputBytes += size;
276
- };
277
- try {
278
- const argumentsValue = (0, contracts_exports.getCommandArguments)(context);
279
- const argumentText = (index) => {
280
- const bytes = argumentsValue.bytes(index);
281
- if (!bytes) throw new Error("Missing option argument");
282
- return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
283
- };
284
- if (argumentsValue.args.length === 1 && ["--help", "-h"].includes(argumentsValue.args[0])) {
285
- argumentText(0);
286
- await emitText("Usage: llm [prompt] [-m MODEL] [-s SYSTEM] [-o KEY VALUE] [-a PATH] [--at PATH MIMETYPE]\n llm models\nOptions: --model, --system, --option, --attachment; -- ends options\n");
287
- return { exitCode: 0 };
288
- }
289
- if (argumentsValue.args.length === 2 && argumentsValue.args[0] === "models" && ["--help", "-h"].includes(argumentsValue.args[1])) {
290
- argumentText(0);
291
- argumentText(1);
292
- await emitText("Usage: llm models [OPTIONS]\n\n List configured models\n\nOptions:\n -h, --help Show this message and exit.\n");
293
- return { exitCode: 0 };
294
- }
295
- const args = await parse(argumentsValue.args.length, argumentText, step);
296
- if (argumentsValue.args[0] === "models" && args.prompt === "models" && !args.attachments.length) {
297
- for (const { provider, model } of service.models) {
298
- await step();
299
- await emitText(`${provider.name}/${model.id} aliases: ${model.aliases?.join(", ") || "-"} attachments: ${model.attachmentTypes?.join(", ") || "-"} output: ${model.outputType ?? "text/plain"}
300
- `);
301
- }
302
- return { exitCode: 0 };
303
- }
304
- const entry = service.resolve(args.model);
305
- const fragments = [];
306
- const decoder = new TextDecoder("utf-8", { fatal: true });
307
- const input = await operation.acquire(() => context.stdinInput ? { next: () => context.stdinInput.read(Math.min(65536, inputLimit - inputBytes + 1), signal) } : context.stdin[Symbol.asyncIterator](), async (iterator2) => {
308
- await iterator2.return?.();
309
- });
310
- while (true) {
311
- await step();
312
- const result = await interrupted(() => input.next(), signal);
313
- signal.throwIfAborted();
314
- if (result.done) break;
315
- const chunk = result.value;
316
- if (!(chunk instanceof Uint8Array)) throw new TypeError("Byte sources must yield Uint8Array chunks");
317
- admitInput(chunk.byteLength);
318
- fragments.push(decoder.decode(chunk, { stream: true }));
319
- }
320
- fragments.push(decoder.decode());
321
- const content = fragments.join("");
322
- const attachments = [];
323
- for (const attachment of args.attachments) {
324
- await step();
325
- if (attachment.path.includes("://")) throw new Error("URL attachments are not supported");
326
- const path = (0, internal_exports.pathOf)(context, attachment.path);
327
- const stat = await interrupted(() => context.fs.stat(path, { signal }), signal);
328
- checkInput(stat.size);
329
- const bytes = await interrupted(() => context.fs.readFile(path, {
330
- signal,
331
- ...inputLimit === Infinity ? {} : { maxBytes: inputLimit - inputBytes }
332
- }), signal);
333
- signal.throwIfAborted();
334
- if (!(bytes instanceof Uint8Array)) throw new TypeError("Attachment read must return Uint8Array");
335
- admitInput(bytes.byteLength);
336
- const mimeType = attachment.mimeType ?? sniffMimeType(path, bytes);
337
- if (!acceptsMimeType(entry.model.attachmentTypes ?? [], mimeType)) throw new Error(`Model ${entry.model.id} does not accept ${mimeType}`);
338
- attachments.push({ mimeType, bytes: new Uint8Array(bytes) });
339
- }
340
- const request = {
341
- model: entry.model.id,
342
- prompt: content && args.prompt ? `${content}
343
-
344
- ${args.prompt}` : content || args.prompt,
345
- ...args.system === void 0 ? {} : { system: args.system },
346
- attachments,
347
- options: args.options,
348
- signal
349
- };
350
- signal.throwIfAborted();
351
- iterator = service.complete(request)[Symbol.asyncIterator]();
352
- const text = (entry.model.outputType ?? "text/plain").toLowerCase().startsWith("text/");
353
- let pendingSurrogate = "";
354
- while (true) {
355
- await step();
356
- const result = await interrupted(() => iterator.next(), signal);
357
- signal.throwIfAborted();
358
- if (result.done) {
359
- ended = true;
360
- break;
361
- }
362
- if (text ? typeof result.value !== "string" : !(result.value instanceof Uint8Array)) throw new Error(`Provider ${entry.provider.name} returned a response chunk incompatible with ${entry.model.outputType ?? "text/plain"}`);
363
- if (typeof result.value === "string") {
364
- let chunk = pendingSurrogate + result.value;
365
- const last = chunk.charCodeAt(chunk.length - 1);
366
- pendingSurrogate = last >= 55296 && last <= 56319 ? chunk.slice(-1) : "";
367
- if (pendingSurrogate) chunk = chunk.slice(0, -1);
368
- if (chunk) await emitText(chunk);
369
- } else await write(result.value);
370
- }
371
- if (text) {
372
- if (pendingSurrogate) await emitText(pendingSurrogate);
373
- await write(Uint8Array.of(10));
374
- }
375
- return { exitCode: 0 };
376
- } catch (error) {
377
- context.signal.throwIfAborted();
378
- operation.signal.throwIfAborted();
379
- controller.abort(error);
380
- if (writing) throw error;
381
- await operation.close();
382
- await (0, escaping_exports.writeDiagnostic)(context.stderr, `${error instanceof Error ? error.message.slice(0, 4096) : "llm provider failed"}
383
- `, context.signal);
384
- return { exitCode: 1 };
385
- } finally {
386
- controller.abort(new Error("llm request closed"));
387
- await operation.close();
388
- }
389
- }
390
- function createLlmCommands(options) {
391
- if (!options.service && options.providers === void 0) throw new TypeError("Provide LLM providers or an authorized service");
392
- if (options.service && (options.providers || options.defaultModel !== void 0)) throw new TypeError("Configure providers and defaultModel on the injected LLM service");
393
- const service = options.service ?? createLlmService({ ...options, providers: options.providers ?? [] });
394
- return [{ name: "llm", description: "Query injected language and media models", execute: (context) => execute(context, service) }];
395
- }
396
- function llmCommands(options) {
397
- const definitions = createLlmCommands(options);
398
- const replace = options.replace ?? false;
399
- return { name: "llm-commands", setup(host) {
400
- if (!replace && host.commands.has("llm")) throw new Error("Command already registered: llm");
401
- for (const definition of definitions) host.commands.register(definition, { replace });
402
- } };
403
- }
404
-
405
- export {
406
- createLlmService,
407
- createLlmCommands,
408
- llmCommands
409
- };
@@ -1,95 +0,0 @@
1
- import { InputError, observe } from "./io.js";
2
- import { integerMaximum, quote } from "./options.js";
3
- import { yieldTurn } from "@poe-platform/safe-bash/contracts/yield";
4
- function displayByte(byte) {
5
- const high = byte >= 128;
6
- const value = high ? byte - 128 : byte;
7
- return `${high ? "M-" : ""}${value < 32 ? `^${String.fromCharCode(value + 64)}` : value === 127 ? "^?" : String.fromCharCode(value)}`;
8
- }
9
- function remaining(input, skip) {
10
- if (input.stat?.type !== "file" || !Number.isSafeInteger(input.stat.size) || input.stat.size < 0)
11
- return undefined;
12
- const size = BigInt(input.stat.size);
13
- return skip < size ? size - skip : 0n;
14
- }
15
- export async function compare(session, args) {
16
- const left = await session.open(args.files[0]);
17
- if (args.files[0] === args.files[1] && (args.files[0] === "-" || args.skips[0] === args.skips[1] && args.skips[0] <= integerMaximum))
18
- return 0;
19
- const right = await session.open(args.files[1]);
20
- if (left.path !== undefined && right.path !== undefined && args.skips[0] === args.skips[1] && args.skips[0] <= integerMaximum
21
- && session.context.fs.compareEntry && await observe(() => session.context.fs.compareEntry(left.path, session.context.fs, right.path, { signal: session.signal }), session.signal) === "same")
22
- return 0;
23
- const sizes = [remaining(left, args.skips[0]), remaining(right, args.skips[1])];
24
- if (args.mode === "silent" && sizes[0] !== undefined && sizes[1] !== undefined && sizes[0] !== sizes[1]
25
- && (sizes[0] < sizes[1] ? sizes[0] : sizes[1]) < args.count)
26
- return 1;
27
- const comparisonBlockBytes = session.comparisonBlockBytes ?? left.stat?.ioBlockSize ?? 65536;
28
- if (!Number.isSafeInteger(comparisonBlockBytes) || comparisonBlockBytes < 1) {
29
- throw new InputError(left.name, new Error("invalid preferred I/O block size"), false);
30
- }
31
- let maximum = args.count;
32
- for (const size of sizes)
33
- if (size !== undefined && size < maximum)
34
- maximum = size;
35
- const width = maximum.toString().length;
36
- const inputs = [left, right];
37
- const cursors = inputs.map((input, index) => session.cursor(input, args.skips[index]));
38
- for (let index = 0; index < 2; index++) {
39
- const skip = args.skips[index];
40
- if (skip > integerMaximum && inputs[index].stat?.type !== "file")
41
- throw new InputError(inputs[index].name, new Error("Value too large to be stored in data type"), false);
42
- if (inputs[index].path === undefined || session.context.fs.readStream && (inputs[index].stat?.type !== "file" || inputs[index].stat.size < 0))
43
- await cursors[index].skip(skip);
44
- if (inputs[index].stat?.type === "directory")
45
- await cursors[index].available();
46
- }
47
- let compared = 0n, line = 1n, atLineStart = true, work = 0;
48
- while (true) {
49
- const remaining = args.count - compared;
50
- const requested = Number(remaining < BigInt(comparisonBlockBytes) ? remaining : BigInt(comparisonBlockBytes));
51
- const first = await cursors[0].block(requested), second = await cursors[1].block(requested);
52
- const count = Math.min(first.length, second.length);
53
- let different = false, output = "";
54
- for (let offset = 0; offset < count; offset++) {
55
- const byteLeft = first[offset], byteRight = second[offset];
56
- compared++;
57
- if (byteLeft !== byteRight) {
58
- different = true;
59
- if (args.mode === "silent")
60
- return 1;
61
- const octalLeft = byteLeft.toString(8).padStart(3, " "), octalRight = byteRight.toString(8).padStart(3, " ");
62
- if (args.mode === "first") {
63
- await session.output(`${left.name} ${right.name} differ: ${args.printBytes ? "byte" : "char"} ${compared}, line ${line}${args.printBytes ? ` is ${octalLeft} ${displayByte(byteLeft)} ${octalRight} ${displayByte(byteRight)}` : ""}\n`);
64
- return 1;
65
- }
66
- output += `${compared.toString().padStart(width, " ")} ${octalLeft} ${args.printBytes ? `${displayByte(byteLeft).padEnd(4, " ")} ` : ""}${octalRight}${args.printBytes ? ` ${displayByte(byteRight)}` : ""}\n`;
67
- if (output.length >= 16384) {
68
- await session.output(output);
69
- output = "";
70
- }
71
- }
72
- if (byteLeft === 10)
73
- line++;
74
- atLineStart = byteLeft === 10;
75
- }
76
- if (output)
77
- await session.output(output);
78
- if (first.length !== second.length) {
79
- if (args.mode !== "silent") {
80
- const name = first.length < second.length ? left.name : right.name;
81
- const extra = compared === 0n ? "which is empty" : args.mode === "all" ? `after byte ${compared}`
82
- : `after byte ${compared}, ${atLineStart ? "line" : "in line"} ${atLineStart ? line - 1n : line}`;
83
- await session.output(`cmp: EOF on ${quote(name)} ${extra}\n`, true);
84
- }
85
- return 1;
86
- }
87
- if (first.length !== comparisonBlockBytes)
88
- return different ? 1 : 0;
89
- work += count;
90
- if (work >= 65536) {
91
- await yieldTurn(session.signal);
92
- work = 0;
93
- }
94
- }
95
- }