@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,289 +1,2 @@
1
- import { openAiBytes, openAiError, openAiJson, openAiRecord, openAiResponse } from "./openai-http.js";
2
- import { openAiChat } from "./openai-sse.js";
3
- import { acceptsMimeType } from "./mime.js";
4
- import { credential, providerLimits, jsonBody, multipart } from "./providers/shared.js";
5
- const numericOptions = {
6
- chat: new Map([
7
- ["temperature", ["number", 0, 2]], ["top_p", ["number", 0, 1]],
8
- ["frequency_penalty", ["number", -2, 2]], ["presence_penalty", ["number", -2, 2]],
9
- ["max_tokens", ["integer", 1, Number.MAX_SAFE_INTEGER]], ["max_completion_tokens", ["integer", 1, Number.MAX_SAFE_INTEGER]],
10
- ["n", ["integer", 1, Number.MAX_SAFE_INTEGER]], ["seed", ["integer", Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER]], ["top_logprobs", ["integer", 0, 20]],
11
- ]),
12
- images: new Map([
13
- ["n", ["integer", 1, 10]], ["output_compression", ["integer", 0, 100]], ["partial_images", ["integer", 0, 3]],
14
- ]),
15
- };
16
- function jsonOptions(options, endpoint) {
17
- return Object.fromEntries(Object.entries(options).map(([key, value]) => {
18
- if ((endpoint === "chat" ? ["store", "parallel_tool_calls", "logprobs"] : ["stream"]).includes(key)) {
19
- if (value !== "true" && value !== "false" && typeof value !== "boolean")
20
- throw new Error(`Invalid OpenAI option ${key}: expected boolean`);
21
- return [key, value === true || value === "true"];
22
- }
23
- const numeric = numericOptions[endpoint].get(key);
24
- if (!numeric)
25
- return [key, value];
26
- const [type, minimum, maximum] = numeric;
27
- const number = typeof value === "number" ? value : typeof value === "string" && value.trim() ? Number(value) : NaN;
28
- if (!Number.isFinite(number) || type === "integer" && !Number.isSafeInteger(number)) {
29
- throw new Error(`Invalid OpenAI option ${key}: expected a finite ${type === "integer" ? "safe integer" : "number"}`);
30
- }
31
- if (number < minimum || number > maximum)
32
- throw new RangeError(`Invalid OpenAI option ${key}: expected ${minimum}..${maximum}`);
33
- return [key, number];
34
- }));
35
- }
36
- function base64(bytes) {
37
- let binary = "";
38
- for (let offset = 0; offset < bytes.length; offset += 8192) {
39
- binary += String.fromCharCode(...bytes.subarray(offset, offset + 8192));
40
- }
41
- return btoa(binary);
42
- }
43
- // Keep image JSON and decoded output within a Worker-sized budget even when
44
- // the general provider response allowance is larger (e.g. video downloads).
45
- function imageSize(value) {
46
- if (typeof value !== "string" || value.length === 0)
47
- throw new Error("OpenAI image response has no b64_json");
48
- if (value.length % 4 !== 0)
49
- throw new Error("OpenAI image response contains non-canonical base64");
50
- return value.length / 4 * 3 - (value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0);
51
- }
52
- function imageSlab(value) {
53
- let decoded;
54
- try {
55
- decoded = atob(value);
56
- }
57
- catch {
58
- throw new Error("OpenAI image response contains invalid base64");
59
- }
60
- if (btoa(decoded) !== value)
61
- throw new Error("OpenAI image response contains non-canonical base64");
62
- return decoded;
63
- }
64
- function* imageBytes(value, signal) {
65
- for (let offset = 0; offset < value.length; offset += 8192) {
66
- signal.throwIfAborted();
67
- const decoded = imageSlab(value.slice(offset, offset + 8192));
68
- const bytes = new Uint8Array(decoded.length);
69
- for (let index = 0; index < decoded.length; index++)
70
- bytes[index] = decoded.charCodeAt(index);
71
- yield bytes;
72
- }
73
- }
74
- function waitForPoll(signal, interval) {
75
- signal.throwIfAborted();
76
- return new Promise((resolve, reject) => {
77
- const abort = () => { clearTimeout(timer); signal.removeEventListener("abort", abort); reject(signal.reason); };
78
- const timer = setTimeout(() => { signal.removeEventListener("abort", abort); resolve(); }, interval);
79
- signal.addEventListener("abort", abort, { once: true });
80
- if (signal.aborted)
81
- abort();
82
- });
83
- }
84
- function job(value, expectedId) {
85
- if (value.error != null)
86
- throw new Error(`OpenAI video failed: ${openAiError(value.error) ?? "unknown error"}`);
87
- if (typeof value.id !== "string" || value.id.length === 0 || value.id === "." || value.id === ".." || (expectedId !== undefined && value.id !== expectedId)) {
88
- throw new Error("OpenAI video response has an invalid job id");
89
- }
90
- if (value.status !== "queued" && value.status !== "in_progress" && value.status !== "completed") {
91
- throw new Error(`OpenAI video failed: ${typeof value.status === "string" ? value.status : "invalid status"}`);
92
- }
93
- return { id: value.id, status: value.status };
94
- }
95
- export function createOpenAiProvider(options) {
96
- const { transport, apiKey } = options;
97
- const limits = providerLimits(options.limits);
98
- if (typeof transport !== "function")
99
- throw new TypeError("OpenAI requires an injected HTTP transport");
100
- if (typeof apiKey !== "string" || !apiKey.trim() || apiKey.includes("\r") || apiKey.includes("\n"))
101
- throw new TypeError("OpenAI requires a valid API key");
102
- credential(apiKey);
103
- const base = new URL(options.baseUrl ?? "https://api.openai.com/v1");
104
- if ((base.protocol !== "https:" && base.protocol !== "http:") || base.username || base.password || base.search || base.hash) {
105
- throw new TypeError("OpenAI baseUrl must be an HTTP(S) URL without credentials, query or fragment");
106
- }
107
- const baseUrl = base.href.endsWith("/") ? base.href.slice(0, -1) : base.href;
108
- const configured = options.models.map(model => Object.freeze({
109
- ...model,
110
- capabilities: Object.freeze(model.capabilities ?? (model.endpoint === "chat" ? ["messages"] : model.endpoint === "embeddings" ? ["embed"] : [])),
111
- ...(model.aliases === undefined ? {} : { aliases: Object.freeze([...model.aliases]) }),
112
- ...(model.attachmentTypes === undefined ? {} : { attachmentTypes: Object.freeze([...model.attachmentTypes]) }),
113
- }));
114
- const byId = new Map();
115
- for (const model of configured) {
116
- if (!model.id || byId.has(model.id))
117
- throw new TypeError(`OpenAI duplicate or empty model id: ${model.id}`);
118
- if (!["chat", "images", "videos", "embeddings"].includes(model.endpoint))
119
- throw new TypeError(`OpenAI invalid endpoint for model: ${model.id}`);
120
- if (model.endpoint === "images" && !acceptsMimeType(["image/png", "image/jpeg", "image/webp"], model.outputType ?? ""))
121
- throw new TypeError("Image models require outputType image/png, image/jpeg or image/webp");
122
- if (model.endpoint === "videos" && !acceptsMimeType(["video/mp4"], model.outputType ?? ""))
123
- throw new TypeError("Video models require outputType video/mp4");
124
- if (model.endpoint === "chat" && model.outputType !== undefined && !acceptsMimeType(["text/*"], model.outputType))
125
- throw new TypeError("Chat models require a text outputType");
126
- byId.set(model.id, model);
127
- }
128
- return {
129
- name: "openai", models: Object.freeze(configured),
130
- async embed(request) {
131
- request.signal.throwIfAborted();
132
- const model = byId.get(request.model);
133
- if (!model || model.endpoint !== "embeddings")
134
- throw new Error(`Model ${request.model} does not support embeddings`);
135
- const values = {};
136
- for (const [key, value] of Object.entries(request.options)) {
137
- if (key === "dimensions") {
138
- const number = typeof value === "number" ? value : typeof value === "string" && value.trim() ? Number(value) : NaN;
139
- if (!Number.isSafeInteger(number) || number < 1)
140
- throw new TypeError("Invalid OpenAI dimensions: expected a positive integer");
141
- values[key] = number;
142
- }
143
- else if (key === "user" && typeof value === "string")
144
- values[key] = value;
145
- else
146
- throw new TypeError(`Unsupported OpenAI embedding option: ${key}`);
147
- }
148
- for await (const response of openAiResponse(transport, {
149
- url: `${baseUrl}/embeddings`, method: "POST", signal: request.signal,
150
- ...jsonBody({ ...values, model: request.model, input: request.inputs }, limits.maxRequestBytes),
151
- headers: [["authorization", `Bearer ${apiKey}`], ["content-type", "application/json"]],
152
- }, limits.maxResponseBytes)) {
153
- const body = await openAiJson(response, request.signal, limits.maxResponseBytes);
154
- if (!Array.isArray(body.data) || body.data.length !== request.inputs.length)
155
- throw new TypeError("Invalid OpenAI embedding response");
156
- const vectors = new Array(request.inputs.length);
157
- for (const item of body.data) {
158
- if (!openAiRecord(item) || !Number.isSafeInteger(item.index) || item.index < 0 || item.index >= vectors.length || vectors[item.index] !== undefined || !Array.isArray(item.embedding) || !item.embedding.length || item.embedding.some(value => typeof value !== "number" || !Number.isFinite(value)))
159
- throw new TypeError("Invalid OpenAI embedding response");
160
- vectors[item.index] = item.embedding;
161
- }
162
- if (vectors.some(vector => vector.length !== vectors[0]?.length))
163
- throw new TypeError("Invalid OpenAI embedding dimensions");
164
- return { model: request.model, vectors, ...(openAiRecord(body.usage) ? { usage: body.usage } : {}) };
165
- }
166
- throw new Error("OpenAI returned no embedding response");
167
- },
168
- async *complete(request) {
169
- request.signal.throwIfAborted();
170
- const model = byId.get(request.model);
171
- if (!model)
172
- throw new Error(`Unknown model: ${request.model}`);
173
- if (model.endpoint === "embeddings")
174
- throw new TypeError("Embedding models require embed()");
175
- if (model.endpoint !== "chat" && (request.messages?.length || request.schema !== undefined))
176
- throw new TypeError("Messages and schemas require a chat model");
177
- if (request.attachments.some(attachment => !acceptsMimeType(["image/*"], attachment.mimeType))) {
178
- throw new Error(`OpenAI ${model.endpoint} endpoint only supports image attachments`);
179
- }
180
- if (model.endpoint === "videos" && request.attachments.length > 1)
181
- throw new Error("OpenAI videos accepts only one input_reference image");
182
- if (request.attachments.reduce((size, file) => size + file.bytes.byteLength, 0) > limits.maxRequestBytes)
183
- throw new RangeError("Provider request byte limit exceeded");
184
- if (model.endpoint !== "chat" && request.system !== undefined)
185
- throw new TypeError("System prompts are supported only by chat models");
186
- if (request.schema !== undefined && request.options.response_format !== undefined)
187
- throw new TypeError("OpenAI option response_format conflicts with request schema");
188
- const reserved = model.endpoint === "chat" ? ["model", "messages", "stream"]
189
- : model.endpoint === "images" ? ["model", "prompt", "image", "image[]"] : ["model", "prompt", "input_reference"];
190
- for (const key of Object.keys(request.options)) {
191
- if (reserved.includes(key))
192
- throw new Error(`OpenAI option ${key} is controlled by the provider`);
193
- }
194
- const send = (path, method, body) => openAiResponse(transport, {
195
- url: `${baseUrl}${path}`, method, signal: request.signal,
196
- ...body, headers: [["authorization", `Bearer ${apiKey}`], ...(body?.headers ?? [])],
197
- }, limits.maxResponseBytes);
198
- if (model.endpoint === "chat") {
199
- const messages = [];
200
- if (request.system !== undefined)
201
- messages.push({ role: "system", content: request.system });
202
- messages.push(...request.messages ?? []);
203
- messages.push({ role: "user", content: request.attachments.length === 0 ? request.prompt : [
204
- { type: "text", text: request.prompt },
205
- ...request.attachments.map(attachment => ({ type: "image_url", image_url: { url: `data:${attachment.mimeType};base64,${base64(attachment.bytes)}` } })),
206
- ] });
207
- let details;
208
- for await (const response of send("/chat/completions", "POST", jsonBody({ ...jsonOptions(request.options, "chat"), ...(request.schema === undefined ? {} : { response_format: { type: "json_schema", json_schema: { name: "response", schema: request.schema } } }), model: request.model, messages, stream: true }, limits.maxRequestBytes))) {
209
- details = yield* openAiChat(response.body, request.signal, limits.maxEventBytes, limits.maxResponseBytes);
210
- }
211
- return details;
212
- }
213
- else if (model.endpoint === "images") {
214
- const editing = request.attachments.length > 0;
215
- const outputFormat = model.outputType.split(";", 1)[0].trim().toLowerCase().slice("image/".length);
216
- if (request.options.output_format !== undefined && request.options.output_format !== outputFormat)
217
- throw new TypeError("output_format conflicts with model outputType");
218
- const values = { ...jsonOptions(request.options, "images"), output_format: outputFormat, model: request.model, prompt: request.prompt };
219
- if (values.stream === true)
220
- throw new TypeError("Image event streaming is not supported by this reference provider");
221
- const body = editing ? multipart({ ...values, ...request.options }, request.attachments.map(file => ({ ...file, field: "image[]" })), limits.maxRequestBytes) : jsonBody(values, limits.maxRequestBytes);
222
- for await (const response of send(editing ? "/images/edits" : "/images/generations", "POST", body)) {
223
- const value = await openAiJson(response, request.signal, limits.maxResponseBytes);
224
- if (value.error != null)
225
- throw new Error(`OpenAI: ${openAiError(value.error) ?? "image generation failed"}`);
226
- if (!Array.isArray(value.data) || value.data.length === 0)
227
- throw new Error("OpenAI image response has no images");
228
- let size = 0;
229
- const images = [];
230
- for (const item of value.data) {
231
- request.signal.throwIfAborted();
232
- if (!openAiRecord(item))
233
- throw new Error("OpenAI image response contains a malformed image");
234
- size += imageSize(item.b64_json);
235
- if (size > limits.maxResponseBytes)
236
- throw new RangeError("Provider image byte limit exceeded");
237
- images.push(item.b64_json);
238
- }
239
- // Validate every slab before publishing any output, including padding
240
- // in the middle of an image or a malformed later image.
241
- for (const image of images) {
242
- for (let offset = 0; offset < image.length; offset += 8192) {
243
- request.signal.throwIfAborted();
244
- const slab = image.slice(offset, offset + 8192);
245
- if (offset + 8192 < image.length && slab.includes("="))
246
- throw new Error("OpenAI image response contains non-canonical base64");
247
- imageSlab(slab);
248
- }
249
- }
250
- for (const image of images)
251
- yield* imageBytes(image, request.signal);
252
- }
253
- }
254
- else {
255
- let current;
256
- for await (const response of send("/videos", "POST", multipart({ ...request.options, model: request.model, prompt: request.prompt }, request.attachments.map(file => ({ ...file, field: "input_reference" })), limits.maxRequestBytes))) {
257
- current = job(await openAiJson(response, request.signal, limits.maxResponseBytes));
258
- }
259
- if (!current)
260
- throw new Error("OpenAI video creation returned no job");
261
- const path = `/videos/${encodeURIComponent(current.id)}`;
262
- let polls = 0;
263
- while (current.status !== "completed") {
264
- if (polls++ >= limits.maxPolls)
265
- throw new RangeError("Provider video polling limit exceeded");
266
- await waitForPoll(request.signal, limits.pollIntervalMs);
267
- for await (const response of send(path, "GET"))
268
- current = job(await openAiJson(response, request.signal, limits.maxResponseBytes), current.id);
269
- }
270
- for await (const response of send(`${path}/content`, "GET")) {
271
- const contentType = response.headers.find(([name]) => name.toLowerCase() === "content-type")?.[1].split(";")[0]?.trim().toLowerCase();
272
- if (contentType && contentType !== "application/octet-stream" && !contentType.startsWith("video/")) {
273
- throw new Error(`OpenAI video download has unexpected content type: ${contentType}`);
274
- }
275
- let received = false;
276
- for await (const chunk of openAiBytes(response.body, request.signal, limits.maxResponseBytes)) {
277
- if (chunk.byteLength === 0)
278
- continue;
279
- received = true;
280
- yield chunk;
281
- }
282
- if (!received)
283
- throw new Error("OpenAI video download is empty");
284
- }
285
- }
286
- },
287
- };
288
- }
1
+ export * from "../../../safe-bash-command-llm/openai.js";
289
2
  //# sourceMappingURL=openai.js.map
@@ -1,2 +1,2 @@
1
- export { createElevenLabsProvider, type ElevenLabsProviderOptions, type ElevenLabsModel } from "../elevenlabs.js";
1
+ export * from "../../../../safe-bash-command-llm/providers/elevenlabs.js";
2
2
  //# sourceMappingURL=elevenlabs.d.ts.map
@@ -1,2 +1,2 @@
1
- export { createElevenLabsProvider } from "../elevenlabs.js";
1
+ export * from "../../../../safe-bash-command-llm/providers/elevenlabs.js";
2
2
  //# sourceMappingURL=elevenlabs.js.map
@@ -1,10 +1,10 @@
1
- import "../../../chunks/chunk-VYW4Q6KF.js";
2
1
  import {
3
- createElevenLabsProvider,
4
- createOpenAiProvider
5
- } from "../../../chunks/chunk-S2LSZFZ6.js";
6
- import "../../../chunks/chunk-LD76P7AG.js";
7
- import "../../../chunks/chunk-Q45QCA4J.js";
2
+ init_platform
3
+ } from "../../../chunks/chunk-I3KSESCR.js";
4
+
5
+ // packages/safe-bash/src/commands/llm/providers/index.ts
6
+ init_platform();
7
+ import { createElevenLabsProvider, createOpenAiProvider } from "../../../../safe-bash-command-llm/providers/index.js";
8
8
  export {
9
9
  createElevenLabsProvider,
10
10
  createOpenAiProvider
@@ -1,4 +1,2 @@
1
- export { createOpenAiProvider, type OpenAiProviderOptions, type OpenAiModel } from "./openai.js";
2
- export { createElevenLabsProvider, type ElevenLabsProviderOptions, type ElevenLabsModel } from "./elevenlabs.js";
3
- export type { LlmProviderLimits } from "./shared.js";
1
+ export * from "../../../../safe-bash-command-llm/providers/index.js";
4
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,2 @@
1
- export { createOpenAiProvider } from "./openai.js";
2
- export { createElevenLabsProvider } from "./elevenlabs.js";
1
+ export * from "../../../../safe-bash-command-llm/providers/index.js";
3
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- export { createOpenAiProvider, type OpenAiProviderOptions, type OpenAiModel } from "../openai.js";
1
+ export * from "../../../../safe-bash-command-llm/providers/openai.js";
2
2
  //# sourceMappingURL=openai.d.ts.map
@@ -1,2 +1,2 @@
1
- export { createOpenAiProvider } from "../openai.js";
1
+ export * from "../../../../safe-bash-command-llm/providers/openai.js";
2
2
  //# sourceMappingURL=openai.js.map
@@ -1,24 +1,2 @@
1
- import type { ByteSource } from "../../../contracts/io.js";
2
- import type { HttpHeaders } from "../../network/types.js";
3
- export interface LlmProviderLimits {
4
- readonly maxRequestBytes: number;
5
- readonly maxResponseBytes: number;
6
- readonly maxEventBytes: number;
7
- readonly maxPolls: number;
8
- readonly pollIntervalMs: number;
9
- }
10
- export declare function providerLimits(input?: Partial<LlmProviderLimits>): LlmProviderLimits;
11
- export declare function credential(value: string): string;
12
- export declare function jsonBody(value: unknown, limit: number): {
13
- body: ByteSource;
14
- headers: HttpHeaders;
15
- };
16
- export declare function multipart(options: Record<string, unknown>, files: readonly {
17
- field: string;
18
- mimeType: string;
19
- bytes: Uint8Array;
20
- }[], limit: number): {
21
- body: ByteSource;
22
- headers: HttpHeaders;
23
- };
1
+ export * from "../../../../safe-bash-command-llm/providers/shared.js";
24
2
  //# sourceMappingURL=shared.d.ts.map
@@ -1,66 +1,2 @@
1
- export function providerLimits(input = {}) {
2
- const limits = { maxRequestBytes: Infinity, maxResponseBytes: Infinity, maxEventBytes: Infinity, maxPolls: Infinity, pollIntervalMs: 1000, ...input };
3
- for (const [name, value] of Object.entries(limits)) {
4
- if (name !== "pollIntervalMs" && value === Infinity)
5
- continue;
6
- if (!Number.isSafeInteger(value) || value < (name === "maxPolls" || name === "pollIntervalMs" ? 0 : 1))
7
- throw new RangeError(`Invalid provider limit: ${name}`);
8
- }
9
- return Object.freeze(limits);
10
- }
11
- export function credential(value) {
12
- if (typeof value !== "string" || value.length === 0 || [...value].some(char => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127))
13
- throw new TypeError("Invalid provider apiKey");
14
- return value;
15
- }
16
- export function jsonBody(value, limit) {
17
- const text = JSON.stringify(value);
18
- if (text.length > limit)
19
- throw new RangeError("Provider request byte limit exceeded");
20
- const bytes = new TextEncoder().encode(text);
21
- if (bytes.length > limit)
22
- throw new RangeError("Provider request byte limit exceeded");
23
- return { body: (async function* () { yield bytes; })(), headers: [["content-type", "application/json"]] };
24
- }
25
- export function multipart(options, files, limit) {
26
- const encoder = new TextEncoder();
27
- const parts = [];
28
- const entries = Object.entries(options).map(([name, value]) => {
29
- if (![...name].every(char => "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-".includes(char)))
30
- throw new TypeError("Invalid multipart option name");
31
- return [name, String(value)];
32
- });
33
- let size = files.reduce((sum, file) => sum + file.bytes.length, 0);
34
- for (const [, value] of entries) {
35
- if (value.length > limit)
36
- throw new RangeError("Provider request byte limit exceeded");
37
- size += encoder.encode(value).length;
38
- }
39
- if (size > limit)
40
- throw new RangeError("Provider request byte limit exceeded");
41
- let boundary = "safe-bash-llm-boundary";
42
- const contains = (bytes, needle) => {
43
- outer: for (let start = 0; start <= bytes.length - needle.length; start++) {
44
- for (let index = 0; index < needle.length; index++)
45
- if (bytes[start + index] !== needle[index])
46
- continue outer;
47
- return true;
48
- }
49
- return false;
50
- };
51
- while (entries.some(([, value]) => value.includes(boundary)) || files.some(file => contains(file.bytes, encoder.encode(boundary)))) {
52
- boundary += "x";
53
- }
54
- for (const [name, value] of entries)
55
- parts.push(encoder.encode(`--${boundary}\r\nContent-Disposition: form-data; name="${name}"\r\n\r\n${value}\r\n`));
56
- for (const [index, file] of files.entries()) {
57
- if ([...file.mimeType].some(char => char.charCodeAt(0) < 32 || char.charCodeAt(0) > 126))
58
- throw new TypeError("Invalid attachment MIME type");
59
- parts.push(encoder.encode(`--${boundary}\r\nContent-Disposition: form-data; name="${file.field}"; filename="attachment-${index}"\r\nContent-Type: ${file.mimeType}\r\n\r\n`), Uint8Array.from(file.bytes), encoder.encode("\r\n"));
60
- }
61
- parts.push(encoder.encode(`--${boundary}--\r\n`));
62
- if (parts.reduce((sum, part) => sum + part.length, 0) > limit)
63
- throw new RangeError("Provider request byte limit exceeded");
64
- return { body: (async function* () { yield* parts; })(), headers: [["content-type", `multipart/form-data; boundary=${boundary}`]] };
65
- }
1
+ export * from "../../../../safe-bash-command-llm/providers/shared.js";
66
2
  //# sourceMappingURL=shared.js.map
@@ -1,38 +1,2 @@
1
- import type { LlmModel, LlmProvider, LlmRequest, LlmEmbeddingRequest, LlmEmbeddingResponse, LlmResponseMetadata } from "./types.js";
2
- export interface LlmServiceOptions {
3
- readonly providers: readonly LlmProvider[];
4
- readonly defaultModel?: string;
5
- }
6
- export interface LlmServiceModel {
7
- readonly provider: LlmProvider;
8
- readonly model: LlmModel;
9
- }
10
- export interface LlmServiceRequest extends Omit<LlmRequest, "model"> {
11
- readonly model?: string;
12
- readonly maxOutputBytes?: number;
13
- }
14
- export type LlmStreamEvent = {
15
- readonly type: "text";
16
- readonly text: string;
17
- } | {
18
- readonly type: "bytes";
19
- readonly data: Uint8Array;
20
- } | {
21
- readonly type: "response";
22
- readonly response: LlmResponseMetadata & {
23
- readonly model: string;
24
- };
25
- };
26
- /** Structured host API shared by shell and other language front ends. */
27
- export interface LlmService {
28
- readonly version: 1;
29
- readonly models: readonly LlmServiceModel[];
30
- resolve(model?: string): LlmServiceModel;
31
- complete(request: LlmServiceRequest): AsyncIterable<string | Uint8Array, LlmResponseMetadata | void>;
32
- stream(request: LlmServiceRequest): AsyncIterable<LlmStreamEvent>;
33
- embed(request: Omit<LlmEmbeddingRequest, "model"> & {
34
- readonly model?: string;
35
- }): Promise<LlmEmbeddingResponse>;
36
- }
37
- export declare function createLlmService(options: LlmServiceOptions): LlmService;
1
+ export * from "../../../safe-bash-command-llm/service.js";
38
2
  //# sourceMappingURL=service.d.ts.map
@@ -1,152 +1,2 @@
1
- import { acceptsMimeType } from "./mime.js";
2
- function abortable(start, signal) {
3
- signal.throwIfAborted();
4
- return new Promise((resolve, reject) => {
5
- const abort = () => { signal.removeEventListener("abort", abort); reject(signal.reason); };
6
- signal.addEventListener("abort", abort, { once: true });
7
- Promise.resolve().then(() => { signal.throwIfAborted(); return start(); }).then(value => { signal.removeEventListener("abort", abort); if (signal.aborted)
8
- reject(signal.reason);
9
- else
10
- resolve(value); }, error => { signal.removeEventListener("abort", abort); reject(signal.aborted ? signal.reason : error); });
11
- if (signal.aborted)
12
- abort();
13
- });
14
- }
15
- function validateMetadata(value) {
16
- for (const field of [value.usage, value.metadata]) {
17
- if (field !== undefined && (!field || typeof field !== "object" || Array.isArray(field)))
18
- throw new TypeError("Invalid LLM response metadata");
19
- }
20
- }
21
- function validateOptions(options) {
22
- for (const [key, value] of Object.entries(options)) {
23
- if (!key || value !== null && !["string", "number", "boolean"].includes(typeof value) || typeof value === "number" && !Number.isFinite(value)) {
24
- throw new TypeError(`Invalid model option ${key}: expected a finite scalar`);
25
- }
26
- }
27
- }
28
- export function createLlmService(options) {
29
- const models = [];
30
- const lookup = new Map();
31
- const defaultModel = options.defaultModel;
32
- for (const provider of options.providers) {
33
- if (!provider.name || typeof provider.complete !== "function")
34
- throw new TypeError("Providers require a name and complete function");
35
- for (const declared of provider.models) {
36
- if (!declared.id)
37
- throw new TypeError("Models require a nonempty id");
38
- const model = Object.freeze({ ...declared,
39
- ...(declared.capabilities ? { capabilities: Object.freeze([...declared.capabilities]) } : {}),
40
- ...(declared.aliases ? { aliases: Object.freeze([...declared.aliases]) } : {}),
41
- ...(declared.attachmentTypes ? { attachmentTypes: Object.freeze([...declared.attachmentTypes]) } : {}),
42
- });
43
- const entry = Object.freeze({ provider, model });
44
- for (const name of new Set([model.id, `${provider.name}/${model.id}`, ...model.aliases ?? []])) {
45
- if (!name)
46
- throw new TypeError("Model aliases must not be empty");
47
- if (lookup.has(name))
48
- throw new Error(`Duplicate model id or alias: ${name}`);
49
- lookup.set(name, entry);
50
- }
51
- models.push(entry);
52
- }
53
- }
54
- return Object.freeze({
55
- version: 1,
56
- models: Object.freeze(models),
57
- resolve(model) {
58
- const selected = model ?? defaultModel;
59
- if (selected === undefined)
60
- throw new Error("No model selected; use --model or configure defaultModel");
61
- const entry = lookup.get(selected);
62
- if (!entry)
63
- throw new Error(`Unknown model: ${selected}`);
64
- return entry;
65
- },
66
- complete(request) {
67
- request.signal.throwIfAborted();
68
- validateOptions(request.options);
69
- if (typeof request.prompt !== "string" || request.system !== undefined && typeof request.system !== "string")
70
- throw new TypeError("Invalid LLM prompt");
71
- const entry = this.resolve(request.model);
72
- if (request.messages?.length && !entry.model.capabilities?.includes("messages"))
73
- throw new Error(`Model ${entry.model.id} does not support messages`);
74
- if (request.messages?.some(message => !["system", "user", "assistant"].includes(message.role) || typeof message.content !== "string"))
75
- throw new TypeError("Invalid LLM message");
76
- if (request.schema !== undefined) {
77
- if (!entry.model.capabilities?.includes("schema"))
78
- throw new Error(`Model ${entry.model.id} does not support schema`);
79
- if (!request.schema || typeof request.schema !== "object" || Array.isArray(request.schema))
80
- throw new TypeError("Invalid LLM schema");
81
- }
82
- for (const attachment of request.attachments) {
83
- if (!acceptsMimeType(entry.model.attachmentTypes ?? [], attachment.mimeType)) {
84
- throw new Error(`Model ${entry.model.id} does not accept ${attachment.mimeType}`);
85
- }
86
- }
87
- const { maxOutputBytes: ignoredMaxOutputBytes, ...input } = request;
88
- return entry.provider.complete({ ...input, model: entry.model.id });
89
- },
90
- async *stream(request) {
91
- const limit = request.maxOutputBytes ?? Infinity;
92
- if (limit !== Infinity && (!Number.isSafeInteger(limit) || limit < 0))
93
- throw new RangeError("Invalid LLM output limit");
94
- const entry = this.resolve(request.model);
95
- const iterator = this.complete(request)[Symbol.asyncIterator]();
96
- let ended = false;
97
- let size = 0;
98
- try {
99
- while (true) {
100
- request.signal.throwIfAborted();
101
- const result = await abortable(() => iterator.next(), request.signal);
102
- request.signal.throwIfAborted();
103
- if (result.done) {
104
- ended = true;
105
- const metadata = result.value;
106
- if (metadata !== undefined && (!metadata || typeof metadata !== "object" || Array.isArray(metadata)))
107
- throw new TypeError("Invalid LLM response metadata");
108
- const details = metadata;
109
- if (details)
110
- validateMetadata(details);
111
- yield { type: "response", response: { model: entry.model.id, ...(details?.usage ? { usage: details.usage } : {}), ...(details?.metadata ? { metadata: details.metadata } : {}) } };
112
- return;
113
- }
114
- const chunk = result.value;
115
- const text = (entry.model.outputType ?? "text/plain").toLowerCase().startsWith("text/");
116
- if (text ? typeof chunk !== "string" : !(chunk instanceof Uint8Array))
117
- throw new TypeError("Provider returned an incompatible LLM output chunk");
118
- size += typeof chunk === "string" ? new TextEncoder().encode(chunk).length : chunk.byteLength;
119
- if (size > limit)
120
- throw new RangeError("LLM output byte limit exceeded");
121
- yield typeof chunk === "string" ? { type: "text", text: chunk } : { type: "bytes", data: new Uint8Array(chunk) };
122
- }
123
- }
124
- finally {
125
- if (!ended) {
126
- const closing = Promise.resolve().then(() => iterator.return?.());
127
- if (request.signal.aborted)
128
- void closing.catch(() => undefined);
129
- else
130
- await closing;
131
- }
132
- }
133
- },
134
- async embed(request) {
135
- request.signal.throwIfAborted();
136
- validateOptions(request.options);
137
- if (!Array.isArray(request.inputs) || Array.from(request.inputs).some(input => typeof input !== "string"))
138
- throw new TypeError("Embedding inputs must be strings");
139
- const entry = this.resolve(request.model);
140
- if (!entry.model.capabilities?.includes("embed") || !entry.provider.embed)
141
- throw new Error(`Model ${entry.model.id} does not support embeddings`);
142
- const embed = entry.provider.embed.bind(entry.provider);
143
- const result = await abortable(() => embed({ ...request, model: entry.model.id }), request.signal);
144
- request.signal.throwIfAborted();
145
- 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))
146
- throw new TypeError("Invalid embedding response");
147
- validateMetadata(result);
148
- return result;
149
- },
150
- });
151
- }
1
+ export * from "../../../safe-bash-command-llm/service.js";
152
2
  //# sourceMappingURL=service.js.map