@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
@@ -0,0 +1,91 @@
1
+ import {
2
+ init_buffer
3
+ } from "./chunk-HX3SHTCE.js";
4
+
5
+ // packages/safe-bash-command-llm/dist/providers/shared.js
6
+ init_buffer();
7
+ function providerLimits(input = {}) {
8
+ const limits = { maxRequestBytes: Infinity, maxResponseBytes: Infinity, maxEventBytes: Infinity, maxPolls: Infinity, pollIntervalMs: 1e3, ...input };
9
+ for (const [name, value] of Object.entries(limits)) {
10
+ if (name !== "pollIntervalMs" && value === Infinity)
11
+ continue;
12
+ if (!Number.isSafeInteger(value) || value < (name === "maxPolls" || name === "pollIntervalMs" ? 0 : 1))
13
+ throw new RangeError(`Invalid provider limit: ${name}`);
14
+ }
15
+ return Object.freeze(limits);
16
+ }
17
+ function credential(value) {
18
+ if (typeof value !== "string" || value.length === 0 || [...value].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127))
19
+ throw new TypeError("Invalid provider apiKey");
20
+ return value;
21
+ }
22
+ function jsonBody(value, limit) {
23
+ const text = JSON.stringify(value);
24
+ if (text.length > limit)
25
+ throw new RangeError("Provider request byte limit exceeded");
26
+ const bytes = new TextEncoder().encode(text);
27
+ if (bytes.length > limit)
28
+ throw new RangeError("Provider request byte limit exceeded");
29
+ return { body: (async function* () {
30
+ yield bytes;
31
+ })(), headers: [["content-type", "application/json"]] };
32
+ }
33
+ function multipart(options, files, limit) {
34
+ const encoder = new TextEncoder();
35
+ const parts = [];
36
+ const entries = Object.entries(options).map(([name, value]) => {
37
+ if (![...name].every((char) => "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-".includes(char)))
38
+ throw new TypeError("Invalid multipart option name");
39
+ return [name, String(value)];
40
+ });
41
+ let size = files.reduce((sum, file) => sum + file.bytes.length, 0);
42
+ for (const [, value] of entries) {
43
+ if (value.length > limit)
44
+ throw new RangeError("Provider request byte limit exceeded");
45
+ size += encoder.encode(value).length;
46
+ }
47
+ if (size > limit)
48
+ throw new RangeError("Provider request byte limit exceeded");
49
+ let boundary = "safe-bash-llm-boundary";
50
+ const contains = (bytes, needle) => {
51
+ outer: for (let start = 0; start <= bytes.length - needle.length; start++) {
52
+ for (let index = 0; index < needle.length; index++)
53
+ if (bytes[start + index] !== needle[index])
54
+ continue outer;
55
+ return true;
56
+ }
57
+ return false;
58
+ };
59
+ while (entries.some(([, value]) => value.includes(boundary)) || files.some((file) => contains(file.bytes, encoder.encode(boundary)))) {
60
+ boundary += "x";
61
+ }
62
+ for (const [name, value] of entries)
63
+ parts.push(encoder.encode(`--${boundary}\r
64
+ Content-Disposition: form-data; name="${name}"\r
65
+ \r
66
+ ${value}\r
67
+ `));
68
+ for (const [index, file] of files.entries()) {
69
+ if ([...file.mimeType].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) > 126))
70
+ throw new TypeError("Invalid attachment MIME type");
71
+ parts.push(encoder.encode(`--${boundary}\r
72
+ Content-Disposition: form-data; name="${file.field}"; filename="attachment-${index}"\r
73
+ Content-Type: ${file.mimeType}\r
74
+ \r
75
+ `), Uint8Array.from(file.bytes), encoder.encode("\r\n"));
76
+ }
77
+ parts.push(encoder.encode(`--${boundary}--\r
78
+ `));
79
+ if (parts.reduce((sum, part) => sum + part.length, 0) > limit)
80
+ throw new RangeError("Provider request byte limit exceeded");
81
+ return { body: (async function* () {
82
+ yield* parts;
83
+ })(), headers: [["content-type", `multipart/form-data; boundary=${boundary}`]] };
84
+ }
85
+
86
+ export {
87
+ providerLimits,
88
+ credential,
89
+ jsonBody,
90
+ multipart
91
+ };
@@ -0,0 +1,90 @@
1
+ import {
2
+ openAiBytes,
3
+ openAiError,
4
+ openAiRecord
5
+ } from "./chunk-H4LWTITX.js";
6
+ import {
7
+ init_buffer
8
+ } from "./chunk-HX3SHTCE.js";
9
+
10
+ // packages/safe-bash-command-llm/dist/openai-sse.js
11
+ init_buffer();
12
+ async function* events(source, signal, limit, responseLimit) {
13
+ const decoder = new TextDecoder("utf-8", { fatal: true });
14
+ let line = "", data = [], size = 0, afterCarriageReturn = false;
15
+ for await (const chunk of openAiBytes(source, signal, responseLimit)) {
16
+ const text = decoder.decode(chunk, { stream: true });
17
+ for (const character of text) {
18
+ if (afterCarriageReturn && character === "\n") {
19
+ afterCarriageReturn = false;
20
+ continue;
21
+ }
22
+ afterCarriageReturn = character === "\r";
23
+ const codePoint = character.codePointAt(0);
24
+ size += codePoint < 128 ? 1 : codePoint < 2048 ? 2 : codePoint < 65536 ? 3 : 4;
25
+ if (size > limit)
26
+ throw new Error("OpenAI SSE event exceeds buffer limit: event byte limit exceeded");
27
+ if (character !== "\n" && character !== "\r") {
28
+ line += character;
29
+ continue;
30
+ }
31
+ if (line === "") {
32
+ if (data.length > 0)
33
+ yield data.join("\n");
34
+ data = [];
35
+ size = 0;
36
+ } else if (line === "data" || line.startsWith("data:")) {
37
+ const value = line.slice(5);
38
+ data.push(value.startsWith(" ") ? value.slice(1) : value);
39
+ }
40
+ line = "";
41
+ }
42
+ }
43
+ decoder.decode();
44
+ throw new Error("OpenAI chat stream ended before [DONE]");
45
+ }
46
+ async function* openAiChat(source, signal, limit = Infinity, responseLimit = Infinity) {
47
+ let usage;
48
+ const metadata = {};
49
+ for await (const data of events(source, signal, limit, responseLimit)) {
50
+ signal.throwIfAborted();
51
+ if (data.trim() === "[DONE]")
52
+ return { ...usage ? { usage } : {}, ...Object.keys(metadata).length ? { metadata } : {} };
53
+ let parsed;
54
+ try {
55
+ parsed = JSON.parse(data);
56
+ } catch {
57
+ throw new Error("OpenAI returned malformed SSE JSON");
58
+ }
59
+ if (!openAiRecord(parsed))
60
+ throw new Error("OpenAI returned a non-object SSE event");
61
+ if (parsed.error != null)
62
+ throw new Error(`OpenAI: ${openAiError(parsed.error) ?? "stream failed"}`);
63
+ if (parsed.usage !== void 0 && parsed.usage !== null) {
64
+ if (!openAiRecord(parsed.usage))
65
+ throw new Error("OpenAI SSE event has invalid usage");
66
+ usage = parsed.usage;
67
+ }
68
+ for (const key of ["id", "model", "created", "system_fingerprint"]) {
69
+ if (parsed[key] !== void 0)
70
+ metadata[key] = parsed[key];
71
+ }
72
+ if (!Array.isArray(parsed.choices))
73
+ throw new Error("OpenAI SSE event has no choices");
74
+ for (const choice of parsed.choices) {
75
+ signal.throwIfAborted();
76
+ if (!openAiRecord(choice) || !openAiRecord(choice.delta))
77
+ throw new Error("OpenAI SSE event has a malformed delta");
78
+ const content = choice.delta.content;
79
+ if (content != null && typeof content !== "string")
80
+ throw new Error("OpenAI SSE delta.content is not text");
81
+ if (typeof content === "string" && content.length > 0)
82
+ yield content;
83
+ }
84
+ }
85
+ throw new Error("OpenAI chat stream ended before [DONE]");
86
+ }
87
+
88
+ export {
89
+ openAiChat
90
+ };
@@ -0,0 +1,314 @@
1
+ import {
2
+ parseLlmNumericOption
3
+ } from "./chunk-VMK4XVKO.js";
4
+ import {
5
+ acceptsMimeType
6
+ } from "./chunk-AKDMCNX4.js";
7
+ import {
8
+ init_buffer
9
+ } from "./chunk-HX3SHTCE.js";
10
+
11
+ // packages/safe-bash-command-llm/dist/service.js
12
+ init_buffer();
13
+ import { yieldTurn } from "../../safe-bash-contracts/yield.js";
14
+
15
+ // packages/safe-bash-command-llm/dist/model-options.js
16
+ init_buffer();
17
+ function validateModelOptions(model, values) {
18
+ if (model.options === void 0)
19
+ return { ...values };
20
+ const result = {};
21
+ for (const [name, input] of Object.entries(values)) {
22
+ const fail = (message) => {
23
+ throw new Error(`${name}
24
+ ${message}`);
25
+ };
26
+ const rule = Object.hasOwn(model.options, name) ? model.options[name] : void 0;
27
+ if (!rule)
28
+ return fail("Extra inputs are not permitted");
29
+ let value = input;
30
+ if (input === null && rule.nullable) {
31
+ result[name] = null;
32
+ continue;
33
+ }
34
+ switch (rule.type) {
35
+ case "number":
36
+ case "integer": {
37
+ const parsed = parseLlmNumericOption(input, rule.type);
38
+ if (parsed === void 0)
39
+ return fail(rule.type === "integer" ? "Input should be a valid integer, unable to parse string as an integer" : "Input should be a valid number, unable to parse string as a number");
40
+ value = parsed;
41
+ if (rule.type === "integer" && !Number.isSafeInteger(value))
42
+ fail("Input should be a valid integer");
43
+ if (rule.maximum !== void 0 && !(value <= rule.maximum))
44
+ fail(`Input should be less than or equal to ${rule.maximum}`);
45
+ if (rule.minimum !== void 0 && !(value >= rule.minimum))
46
+ fail(`Input should be greater than or equal to ${rule.minimum}`);
47
+ if (!Number.isFinite(value))
48
+ fail("Input should be a valid number, unable to parse string as a number");
49
+ break;
50
+ }
51
+ case "boolean": {
52
+ const text = String(input).toLowerCase();
53
+ if (["true", "1", "yes", "on", "y", "t"].includes(text))
54
+ value = true;
55
+ else if (["false", "0", "no", "off", "n", "f"].includes(text))
56
+ value = false;
57
+ else
58
+ fail("Input should be a valid boolean");
59
+ break;
60
+ }
61
+ case "string":
62
+ if (typeof input !== "string")
63
+ fail("Input should be a valid string");
64
+ break;
65
+ }
66
+ Object.defineProperty(result, name, { value, enumerable: true, configurable: true, writable: true });
67
+ }
68
+ return result;
69
+ }
70
+
71
+ // packages/safe-bash-command-llm/dist/service.js
72
+ function abortable(start, signal) {
73
+ signal.throwIfAborted();
74
+ return new Promise((resolve, reject) => {
75
+ const abort = () => {
76
+ signal.removeEventListener("abort", abort);
77
+ reject(signal.reason);
78
+ };
79
+ signal.addEventListener("abort", abort, { once: true });
80
+ Promise.resolve().then(() => {
81
+ signal.throwIfAborted();
82
+ return start();
83
+ }).then((value) => {
84
+ signal.removeEventListener("abort", abort);
85
+ if (signal.aborted)
86
+ reject(signal.reason);
87
+ else
88
+ resolve(value);
89
+ }, (error) => {
90
+ signal.removeEventListener("abort", abort);
91
+ reject(signal.aborted ? signal.reason : error);
92
+ });
93
+ if (signal.aborted)
94
+ abort();
95
+ });
96
+ }
97
+ async function textByteLength(text, signal, maxBytes) {
98
+ let size = 0, checkpoint = 0;
99
+ signal.throwIfAborted();
100
+ for (let index = 0; index < text.length; index++) {
101
+ if (index - checkpoint >= 65536) {
102
+ await yieldTurn(signal);
103
+ checkpoint = index;
104
+ }
105
+ const code = text.charCodeAt(index);
106
+ if (code < 128)
107
+ size++;
108
+ else if (code < 2048)
109
+ size += 2;
110
+ else if (code >= 55296 && code <= 56319 && index + 1 < text.length && text.charCodeAt(index + 1) >= 56320 && text.charCodeAt(index + 1) <= 57343) {
111
+ size += 4;
112
+ index++;
113
+ } else
114
+ size += 3;
115
+ if (size > maxBytes)
116
+ throw new RangeError("LLM output byte limit exceeded");
117
+ }
118
+ signal.throwIfAborted();
119
+ return size;
120
+ }
121
+ function validateMetadata(value) {
122
+ for (const field of [value.usage, value.metadata]) {
123
+ if (field !== void 0 && (!field || typeof field !== "object" || Array.isArray(field)))
124
+ throw new TypeError("Invalid LLM response metadata");
125
+ }
126
+ }
127
+ function validateOptions(options) {
128
+ for (const [key, value] of Object.entries(options)) {
129
+ if (!key || value !== null && !["string", "number", "boolean"].includes(typeof value) || typeof value === "number" && !Number.isFinite(value)) {
130
+ throw new TypeError(`Invalid model option ${key}: expected a finite scalar`);
131
+ }
132
+ }
133
+ }
134
+ async function* streamResult(completion, model, request) {
135
+ const limit = request.maxOutputBytes ?? Infinity;
136
+ if (limit !== Infinity && (!Number.isSafeInteger(limit) || limit < 0))
137
+ throw new RangeError("Invalid LLM output limit");
138
+ const iterator = completion()[Symbol.asyncIterator]();
139
+ let ended = false;
140
+ let size = 0;
141
+ try {
142
+ while (true) {
143
+ request.signal.throwIfAborted();
144
+ const result = await abortable(() => iterator.next(), request.signal);
145
+ request.signal.throwIfAborted();
146
+ if (result.done) {
147
+ ended = true;
148
+ const metadata = result.value;
149
+ if (metadata !== void 0 && (!metadata || typeof metadata !== "object" || Array.isArray(metadata)))
150
+ throw new TypeError("Invalid LLM response metadata");
151
+ const details = metadata;
152
+ if (details)
153
+ validateMetadata(details);
154
+ yield { type: "response", response: { model: model.id, ...details?.usage ? { usage: details.usage } : {}, ...details?.metadata ? { metadata: details.metadata } : {} } };
155
+ return;
156
+ }
157
+ const chunk = result.value;
158
+ const text = (model.outputType ?? "text/plain").toLowerCase().startsWith("text/");
159
+ if (text ? typeof chunk !== "string" : !(chunk instanceof Uint8Array))
160
+ throw new TypeError("Provider returned an incompatible LLM output chunk");
161
+ size += typeof chunk === "string" ? await textByteLength(chunk, request.signal, limit - size) : chunk.byteLength;
162
+ request.signal.throwIfAborted();
163
+ if (size > limit)
164
+ throw new RangeError("LLM output byte limit exceeded");
165
+ yield typeof chunk === "string" ? { type: "text", text: chunk } : { type: "bytes", data: new Uint8Array(chunk) };
166
+ }
167
+ } finally {
168
+ if (!ended) {
169
+ const closing = Promise.resolve().then(() => iterator.return?.());
170
+ if (request.signal.aborted)
171
+ void closing.catch(() => void 0);
172
+ else
173
+ await abortable(() => closing, request.signal);
174
+ }
175
+ }
176
+ }
177
+ function createLlmService(options) {
178
+ const models = [];
179
+ const lookup = /* @__PURE__ */ new Map();
180
+ const defaultModel = options.defaultModel;
181
+ for (const provider of options.providers) {
182
+ if (!provider.name || typeof provider.complete !== "function")
183
+ throw new TypeError("Providers require a name and complete function");
184
+ for (const declared of provider.models) {
185
+ if (!declared.id)
186
+ throw new TypeError("Models require a nonempty id");
187
+ const model = Object.freeze({
188
+ ...declared,
189
+ ...declared.options ? { options: Object.freeze(Object.fromEntries(Object.entries(declared.options).map(([name, rule]) => [name, Object.freeze({ ...rule })]))) } : {},
190
+ ...declared.capabilities ? { capabilities: Object.freeze([...declared.capabilities]) } : {},
191
+ ...declared.aliases ? { aliases: Object.freeze([...declared.aliases]) } : {},
192
+ ...declared.attachmentTypes ? { attachmentTypes: Object.freeze([...declared.attachmentTypes]) } : {}
193
+ });
194
+ const entry = Object.freeze({ provider, model });
195
+ for (const name of /* @__PURE__ */ new Set([model.id, `${provider.name}/${model.id}`, ...model.aliases ?? []])) {
196
+ if (!name)
197
+ throw new TypeError("Model aliases must not be empty");
198
+ if (lookup.has(name))
199
+ throw new Error(`Duplicate model id or alias: ${name}`);
200
+ lookup.set(name, entry);
201
+ }
202
+ models.push(entry);
203
+ }
204
+ }
205
+ return Object.freeze({
206
+ version: 1,
207
+ models: Object.freeze(models),
208
+ resolve(model) {
209
+ const selected = model ?? defaultModel;
210
+ if (selected === void 0)
211
+ throw new Error("No model selected; use --model or configure defaultModel");
212
+ const entry = lookup.get(selected);
213
+ if (!entry)
214
+ throw new Error(`Unknown model: ${selected}`);
215
+ return entry;
216
+ },
217
+ complete(request) {
218
+ request.signal.throwIfAborted();
219
+ validateOptions(request.options);
220
+ if (typeof request.prompt !== "string" || request.system !== void 0 && typeof request.system !== "string")
221
+ throw new TypeError("Invalid LLM prompt");
222
+ const entry = this.resolve(request.model);
223
+ if (request.messages?.length && !entry.model.capabilities?.includes("messages"))
224
+ throw new Error(`Model ${entry.model.id} does not support messages`);
225
+ if (request.messages?.some((message) => !["system", "user", "assistant"].includes(message.role) || typeof message.content !== "string"))
226
+ throw new TypeError("Invalid LLM message");
227
+ if (request.schema !== void 0) {
228
+ if (!entry.model.capabilities?.includes("schema"))
229
+ throw new Error(`Model ${entry.model.id} does not support schema`);
230
+ if (!request.schema || typeof request.schema !== "object" || Array.isArray(request.schema))
231
+ throw new TypeError("Invalid LLM schema");
232
+ }
233
+ for (const attachment of request.attachments) {
234
+ if (!acceptsMimeType(entry.model.attachmentTypes ?? [], attachment.mimeType)) {
235
+ throw new Error(`Model ${entry.model.id} does not accept ${attachment.mimeType}`);
236
+ }
237
+ }
238
+ const { maxOutputBytes: ignoredMaxOutputBytes, ...input } = request;
239
+ return entry.provider.complete({ ...input, model: entry.model.id, options: validateModelOptions(entry.model, request.options) });
240
+ },
241
+ async *stream(request) {
242
+ const entry = this.resolve(request.model);
243
+ yield* streamResult(() => this.complete(request), entry.model, request);
244
+ },
245
+ async *streamSources(request) {
246
+ const sources = /* @__PURE__ */ new Set([request.prompt, ...request.system === void 0 ? [] : [request.system], ...request.messages?.map((message) => message.content) ?? [], ...request.attachments.map((attachment) => attachment.source)]);
247
+ let closing, failed = false;
248
+ const close = () => closing ??= Promise.allSettled([...sources].map((source) => Promise.resolve().then(() => source.dispose()))).then((results) => {
249
+ const rejected = results.find((result) => result.status === "rejected");
250
+ if (rejected?.status === "rejected")
251
+ throw rejected.reason;
252
+ });
253
+ const abort = () => {
254
+ void close().catch(() => void 0);
255
+ };
256
+ request.signal.addEventListener("abort", abort, { once: true });
257
+ try {
258
+ request.signal.throwIfAborted();
259
+ validateOptions(request.options);
260
+ const entry = this.resolve(request.model);
261
+ if (!entry.provider.completeSources || entry.model.inputSources === false)
262
+ throw new Error(`Model ${entry.model.id} does not support streamed inputs`);
263
+ for (const source of sources)
264
+ if (!source || typeof source.dispose !== "function" || typeof source.bytes?.[Symbol.asyncIterator] !== "function")
265
+ throw new TypeError("Invalid LLM input source");
266
+ if (request.messages?.length && !entry.model.capabilities?.includes("messages"))
267
+ throw new Error(`Model ${entry.model.id} does not support messages`);
268
+ if (request.messages?.some((message) => !["system", "user", "assistant"].includes(message.role)))
269
+ throw new TypeError("Invalid LLM message");
270
+ if (request.schema !== void 0) {
271
+ if (!entry.model.capabilities?.includes("schema"))
272
+ throw new Error(`Model ${entry.model.id} does not support schema`);
273
+ if (!request.schema || typeof request.schema !== "object" || Array.isArray(request.schema))
274
+ throw new TypeError("Invalid LLM schema");
275
+ }
276
+ for (const attachment of request.attachments)
277
+ if (!acceptsMimeType(entry.model.attachmentTypes ?? [], attachment.mimeType))
278
+ throw new Error(`Model ${entry.model.id} does not accept ${attachment.mimeType}`);
279
+ const { maxOutputBytes: ignoredMaxOutputBytes, ...input } = request;
280
+ yield* streamResult(() => entry.provider.completeSources({ ...input, model: entry.model.id, options: validateModelOptions(entry.model, request.options) }), entry.model, request);
281
+ } catch (error) {
282
+ failed = true;
283
+ throw request.signal.aborted ? request.signal.reason : error;
284
+ } finally {
285
+ request.signal.removeEventListener("abort", abort);
286
+ await close().catch((error) => {
287
+ if (!failed)
288
+ throw error;
289
+ });
290
+ }
291
+ },
292
+ async embed(request) {
293
+ request.signal.throwIfAborted();
294
+ validateOptions(request.options);
295
+ if (!Array.isArray(request.inputs) || Array.from(request.inputs).some((input) => typeof input !== "string"))
296
+ throw new TypeError("Embedding inputs must be strings");
297
+ const entry = this.resolve(request.model);
298
+ if (!entry.model.capabilities?.includes("embed") || !entry.provider.embed)
299
+ throw new Error(`Model ${entry.model.id} does not support embeddings`);
300
+ const embed = entry.provider.embed.bind(entry.provider);
301
+ const result = await abortable(() => embed({ ...request, model: entry.model.id, options: validateModelOptions(entry.model, request.options) }), request.signal);
302
+ request.signal.throwIfAborted();
303
+ 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))
304
+ throw new TypeError("Invalid embedding response");
305
+ validateMetadata(result);
306
+ return result;
307
+ }
308
+ });
309
+ }
310
+
311
+ export {
312
+ validateModelOptions,
313
+ createLlmService
314
+ };