@bkm016/basalt 0.1.11 → 0.1.13

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 (287) hide show
  1. package/{chunk-7jezts2n.js → chunk-06s9pr82.js} +2 -2
  2. package/{chunk-msm9hmk9.js → chunk-095adzn5.js} +2 -2
  3. package/chunk-0a7ft50x.js +18 -0
  4. package/{chunk-tevejprz.js → chunk-0nedq669.js} +4 -4
  5. package/chunk-0x9netvr.js +5 -0
  6. package/{chunk-9as0p561.js → chunk-15ve3nmv.js} +11 -11
  7. package/chunk-1dbfmejf.js +2 -0
  8. package/{chunk-hbnmymaq.js → chunk-1q6e3mj7.js} +2 -2
  9. package/{chunk-wnzvnskb.js → chunk-22az84sh.js} +2 -2
  10. package/{chunk-ax04trym.js → chunk-2q56egb8.js} +1 -1
  11. package/{chunk-r4ttdkrz.js → chunk-2tf7qfbx.js} +2 -2
  12. package/{chunk-a1352w87.js → chunk-2zbj8ny6.js} +2 -2
  13. package/chunk-302n9g7p.js +2 -0
  14. package/{chunk-bk4rpnm8.js → chunk-37ndxehw.js} +2 -2
  15. package/chunk-41das1ty.js +2 -0
  16. package/{chunk-c71173py.js → chunk-44a7f5ta.js} +6 -6
  17. package/{chunk-jn5pqy5v.js → chunk-46vy2m29.js} +1 -1
  18. package/{chunk-1zj3zvw5.js → chunk-4k9t9jvx.js} +4 -4
  19. package/{chunk-c4qr1f41.js → chunk-4rnmxtpx.js} +2 -2
  20. package/{chunk-fgwda4m0.js → chunk-4w9zqv0k.js} +1 -1
  21. package/chunk-6d9r9p91.js +20 -0
  22. package/chunk-6f4ht2hw.js +2 -0
  23. package/{chunk-jj4hqbrx.js → chunk-6sea12mw.js} +3 -3
  24. package/chunk-74wwdx3y.js +3 -0
  25. package/{chunk-gkf5jwvj.js → chunk-77c2cqp2.js} +1 -1
  26. package/chunk-7chv3knf.js +2 -0
  27. package/chunk-86yr2c0r.js +3 -0
  28. package/{chunk-d0a1jxk5.js → chunk-8cgz8xv7.js} +2 -2
  29. package/{chunk-tvm4zmgj.js → chunk-959z9efn.js} +2 -2
  30. package/{chunk-zc9ar0r4.js → chunk-9e8vhzy7.js} +1 -1
  31. package/chunk-b516bp7n.js +3 -0
  32. package/chunk-bja7p3em.js +25 -0
  33. package/chunk-bng72094.js +2 -0
  34. package/{chunk-a98wma9j.js → chunk-bp61xdsc.js} +1 -1
  35. package/chunk-bq54argx.js +2 -0
  36. package/chunk-ct77cdg7.js +2 -0
  37. package/{chunk-02d3x4mj.js → chunk-dk6fgprw.js} +3 -3
  38. package/chunk-drett6hb.js +2 -0
  39. package/{chunk-4gtgqcct.js → chunk-edbq461k.js} +3 -3
  40. package/{chunk-xh444pfn.js → chunk-f0h2bv11.js} +12 -12
  41. package/{chunk-8mezk0cb.js → chunk-g2etemv5.js} +2 -2
  42. package/{chunk-n0ybj4h9.js → chunk-g5p9mj1r.js} +2 -2
  43. package/{chunk-zyyzk5ha.js → chunk-gpnqmtbk.js} +1 -1
  44. package/{chunk-q9f4xb0w.js → chunk-h9zxqeqr.js} +3 -3
  45. package/{chunk-hb4f2v34.js → chunk-jjtt9aq8.js} +3 -3
  46. package/{chunk-29qrxygd.js → chunk-kbpbrr11.js} +2 -2
  47. package/chunk-m71pj3g1.js +2 -0
  48. package/chunk-mdkfm1ak.js +7 -0
  49. package/chunk-mf04h0yy.js +7 -0
  50. package/chunk-n22vd4at.js +2 -0
  51. package/{chunk-c0zfefq8.js → chunk-nbjnwd54.js} +1 -1
  52. package/{chunk-d5j74pcp.js → chunk-pryvvs96.js} +22 -22
  53. package/{chunk-13gvs0ax.js → chunk-r1jn77q6.js} +2 -2
  54. package/{chunk-ypqjfv3a.js → chunk-rn3jwyh1.js} +2 -2
  55. package/chunk-sgrrxsnz.js +482 -0
  56. package/chunk-sgz87ht5.js +2 -0
  57. package/{chunk-stj493dn.js → chunk-snz19yc2.js} +2 -2
  58. package/{chunk-n2jcx65v.js → chunk-szj85dqe.js} +2 -2
  59. package/{chunk-nrsd810j.js → chunk-tfhp09nj.js} +2 -2
  60. package/{chunk-xtq1xpq0.js → chunk-tfhze1vq.js} +2 -2
  61. package/{chunk-755sy11p.js → chunk-tjg0gcks.js} +1 -1
  62. package/{chunk-en218k4y.js → chunk-tnj2kqb8.js} +1 -1
  63. package/{chunk-h1kb8b49.js → chunk-vqm94hz2.js} +2 -2
  64. package/{chunk-82v8jh1h.js → chunk-xvm0y99b.js} +2 -2
  65. package/{chunk-asyr3gnq.js → chunk-y23dpz5e.js} +2 -2
  66. package/{chunk-1n7dat03.js → chunk-y4pvhes1.js} +6 -6
  67. package/{chunk-bwawt15q.js → chunk-ydzag81d.js} +2 -2
  68. package/chunk-ymg7mtcx.js +3 -0
  69. package/chunk-yy1f9jxc.js +4044 -0
  70. package/{chunk-30rjf7my.js → chunk-z0c8ek0j.js} +5 -5
  71. package/chunk-zk91579b.js +3 -0
  72. package/{chunk-jtsve11b.js → chunk-zx75vnw8.js} +18 -18
  73. package/compiled.js +85 -12
  74. package/package.json +1 -1
  75. package/ui-test-worker.js +53 -53
  76. package/web/{chunk-3a57m7xm.js → chunk-0jbf73pr.js} +3 -3
  77. package/web/{chunk-dk0fnj87.js → chunk-0rhx7qb8.js} +1 -1
  78. package/web/{chunk-q8v5j963.js → chunk-0rvwj2wh.js} +2 -2
  79. package/web/chunk-12qf1r6m.js +1 -0
  80. package/web/{chunk-2ds0a2z1.js → chunk-14vmr99v.js} +3 -3
  81. package/web/{chunk-v3dn9bfw.js → chunk-16jc5m0f.js} +1 -1
  82. package/web/{chunk-f79ajymt.js → chunk-1m6fx2h7.js} +2 -2
  83. package/web/{chunk-793m5jjh.js → chunk-1xm9x7d6.js} +2 -2
  84. package/web/{chunk-j4gvtszc.js → chunk-1zwc09e8.js} +2 -2
  85. package/web/{chunk-mykbcvqz.js → chunk-20jxvmbw.js} +1 -1
  86. package/web/chunk-2n5xbnrt.js +1 -0
  87. package/web/{chunk-57pyz29y.js → chunk-2sef2wft.js} +2 -2
  88. package/web/{chunk-9kkzmss7.js → chunk-2x7vmhm0.js} +3 -3
  89. package/web/{chunk-cbwvfedy.js → chunk-2y1avvqj.js} +8 -8
  90. package/web/chunk-36s08nye.js +1 -0
  91. package/web/chunk-3ctmehg4.js +1 -0
  92. package/web/{chunk-cpshsp24.js → chunk-3jjksgze.js} +1 -1
  93. package/web/{chunk-94denx9h.js → chunk-3p9w8sg5.js} +3 -3
  94. package/web/{chunk-47mbbmst.js → chunk-3wpxymxa.js} +3 -3
  95. package/web/{chunk-2tsxj613.js → chunk-4py9sndw.js} +9 -9
  96. package/web/chunk-4swea9sn.js +1 -0
  97. package/web/chunk-4zz5a483.js +1 -0
  98. package/web/{chunk-hjyev38w.js → chunk-5cwxhhae.js} +5 -5
  99. package/web/chunk-5ym5ffd5.js +4 -0
  100. package/web/{chunk-gten0rpx.js → chunk-6e87m0nm.js} +2 -2
  101. package/web/{chunk-5ahx98zj.js → chunk-6rsr2cyw.js} +8 -8
  102. package/web/chunk-6y55gk1n.js +1 -0
  103. package/web/chunk-7aep7k4v.js +1 -0
  104. package/web/{chunk-tggja45g.js → chunk-8j4tzff5.js} +4 -4
  105. package/web/chunk-8tgavnwx.js +1 -0
  106. package/web/{chunk-zdhyq3ch.js → chunk-97t3ngqf.js} +12 -12
  107. package/web/{chunk-0hvxb5d5.js → chunk-980zhtht.js} +1 -1
  108. package/web/chunk-9k7fkx80.js +1 -0
  109. package/web/{chunk-yrh86m0n.js → chunk-9wz8jne3.js} +1 -1
  110. package/web/chunk-a00vg115.js +1 -0
  111. package/web/chunk-a4gbxnm3.js +1 -0
  112. package/web/{chunk-nhx8pw7p.js → chunk-a6g3nqp0.js} +2 -2
  113. package/web/{chunk-xjc5fmcr.js → chunk-a9er7a7c.js} +24 -24
  114. package/web/chunk-atppv8fk.js +1 -0
  115. package/web/{chunk-xbyrgyy0.js → chunk-awkdw9rw.js} +2 -2
  116. package/web/{chunk-2f2agfpj.js → chunk-b4gcpsbg.js} +11 -11
  117. package/web/{chunk-n33753da.js → chunk-b9jry5a3.js} +1 -1
  118. package/web/chunk-ba9qy65y.js +2 -0
  119. package/web/chunk-bq6mep6p.js +2 -0
  120. package/web/chunk-bwy3e58v.js +1 -0
  121. package/web/{chunk-drchr3yn.js → chunk-c57f714b.js} +2 -2
  122. package/web/{chunk-e763h2px.js → chunk-c6m4vfn5.js} +118 -118
  123. package/web/{chunk-mpdeqzc9.js → chunk-cr04125j.js} +9 -9
  124. package/web/{chunk-dsbyfvwz.js → chunk-cr05dttm.js} +1 -1
  125. package/web/{chunk-a3pye9ag.js → chunk-ct7z7bea.js} +3 -3
  126. package/web/{chunk-2weaa3gn.js → chunk-ct90yf8z.js} +2 -2
  127. package/web/{chunk-gyhr27dm.js → chunk-ddg8rz82.js} +3 -3
  128. package/web/{chunk-wbwets5x.js → chunk-dmha2y9c.js} +28 -28
  129. package/web/{chunk-4gc663j0.js → chunk-e57h40qa.js} +6 -6
  130. package/web/chunk-eeesa5q1.js +1 -0
  131. package/web/{chunk-4wwd3pfz.js → chunk-eqndhs21.js} +2 -2
  132. package/web/{chunk-zv73g4qq.js → chunk-eqxy6535.js} +2 -2
  133. package/web/{chunk-hm8thq7c.js → chunk-et1rsgmp.js} +3 -3
  134. package/web/chunk-f7jpakwh.js +1 -0
  135. package/web/{chunk-enryqmj7.js → chunk-fnvgdvrg.js} +5 -5
  136. package/web/chunk-fp62avjh.js +1 -0
  137. package/web/{chunk-6jb2zyp6.js → chunk-frnh4zqf.js} +2 -2
  138. package/web/chunk-g0be12na.js +1 -0
  139. package/web/{chunk-1zfxaafq.js → chunk-g7hqafb8.js} +1 -1
  140. package/web/{chunk-kfbgvh0c.js → chunk-ga07tv37.js} +1 -1
  141. package/web/chunk-gr163fex.js +1 -0
  142. package/web/chunk-gx340asc.js +1 -0
  143. package/web/chunk-gxtz10wf.js +1 -0
  144. package/web/chunk-h0c42zy3.js +1 -0
  145. package/web/{chunk-b3j07x0n.js → chunk-h1k2kqbs.js} +6 -6
  146. package/web/{chunk-pq56b3mq.js → chunk-h6k1x096.js} +2 -2
  147. package/web/{chunk-885kpj14.js → chunk-jccz14ye.js} +2 -2
  148. package/web/{chunk-1t38sgrk.js → chunk-jh33m2mq.js} +4 -4
  149. package/web/{chunk-g0rtcedn.js → chunk-jh3k7xex.js} +3 -3
  150. package/web/{chunk-nafe18y9.js → chunk-jpem3qvs.js} +10 -10
  151. package/web/{chunk-s0xy00v5.js → chunk-k0cg4n2k.js} +2 -2
  152. package/web/chunk-k9qnvx86.js +2 -0
  153. package/web/chunk-kcnj0gan.js +1 -0
  154. package/web/{chunk-8csw0mvf.js → chunk-ke8dffnk.js} +2 -2
  155. package/web/chunk-kpp5xqsb.js +1 -0
  156. package/web/chunk-m33yted6.js +1 -0
  157. package/web/chunk-me5jqqn6.js +1 -0
  158. package/web/{chunk-tpdcrrf1.js → chunk-mkxeenph.js} +1 -1
  159. package/web/chunk-mnf4ngj9.js +2 -0
  160. package/web/{chunk-30aeb767.js → chunk-mykrm8ba.js} +2 -2
  161. package/web/chunk-mzqqwbmr.js +1 -0
  162. package/web/chunk-mzzaet63.js +1 -0
  163. package/web/chunk-npyrdsf8.css +1 -0
  164. package/web/chunk-p6e2vr51.js +34 -0
  165. package/web/chunk-p7pa02k9.js +2 -0
  166. package/web/chunk-q34as3v6.js +1 -0
  167. package/web/{chunk-27812gqr.js → chunk-q4vy3dkk.js} +3 -3
  168. package/web/chunk-q6c8p73w.js +1 -0
  169. package/web/{chunk-m24yb8md.js → chunk-qb8mbptk.js} +1 -1
  170. package/web/{chunk-b6sqwmq7.js → chunk-qbmtah1x.js} +1 -1
  171. package/web/{chunk-ydtrc1ay.js → chunk-qh62nkem.js} +2 -2
  172. package/web/chunk-qn93we3a.js +1 -0
  173. package/web/{chunk-3ftb27f3.js → chunk-qq06x2ce.js} +8 -8
  174. package/web/{chunk-fj753yzt.js → chunk-qq6m2my8.js} +2 -2
  175. package/web/chunk-r1f1egve.js +1 -0
  176. package/web/chunk-s935z8er.js +2 -0
  177. package/web/{chunk-90fkdzx3.js → chunk-sq75q603.js} +21 -21
  178. package/web/{chunk-05mvzx00.js → chunk-ss96cz1f.js} +1 -1
  179. package/web/{chunk-3b4wqmnh.js → chunk-t82sngk9.js} +7 -7
  180. package/web/chunk-tt9410zw.js +8 -0
  181. package/web/{chunk-8151c970.js → chunk-v4cqc9f9.js} +1 -1
  182. package/web/chunk-ve8gy05p.js +1142 -0
  183. package/web/chunk-vg1ebkce.js +1 -0
  184. package/web/{chunk-g31dbnzm.js → chunk-vk7ch6fh.js} +5 -5
  185. package/web/chunk-vnt34mkb.js +1 -0
  186. package/web/{chunk-59nk506k.js → chunk-w28dn4dw.js} +1 -1
  187. package/web/{chunk-ppjw1mps.js → chunk-w4tfad6c.js} +4 -4
  188. package/web/{chunk-36dc7tcg.js → chunk-wpxtkxjt.js} +2 -2
  189. package/web/chunk-xcyqd7cn.js +1 -0
  190. package/web/chunk-xe121vg7.js +1 -0
  191. package/web/chunk-xh4xn1az.js +1 -0
  192. package/web/{chunk-d4519smc.js → chunk-xk1vkcj4.js} +15 -15
  193. package/web/chunk-xrk5ewsn.js +1 -0
  194. package/web/{chunk-96xhmmqz.js → chunk-xvm66b7v.js} +5 -5
  195. package/web/chunk-xxmaqj1m.js +2 -0
  196. package/web/chunk-xzwxcxb4.js +1 -0
  197. package/web/{chunk-7dycbjxn.js → chunk-y9waq403.js} +4 -4
  198. package/web/chunk-ydhnkws0.js +1 -0
  199. package/web/{chunk-3020mmp1.js → chunk-yn4t5s9r.js} +1 -1
  200. package/web/chunk-ys2tns0p.js +1 -0
  201. package/web/chunk-zb61mf0a.js +1 -0
  202. package/web/{chunk-g4as4zzd.js → chunk-ze6azq7z.js} +4 -4
  203. package/web/chunk-zh7193nq.js +2 -0
  204. package/web/chunk-zqcg6frm.js +1 -0
  205. package/web/{chunk-qykt7avq.js → chunk-zxrbbbtp.js} +2 -2
  206. package/web/index.html +1 -1
  207. package/worker.js +1 -1
  208. package/chunk-38g3gctw.js +0 -3
  209. package/chunk-3k627vf2.js +0 -3
  210. package/chunk-4dw43syb.js +0 -2
  211. package/chunk-7zkswxvk.js +0 -2
  212. package/chunk-95964592.js +0 -25
  213. package/chunk-a1rb1a48.js +0 -20
  214. package/chunk-b2bxqeb4.js +0 -2
  215. package/chunk-bdjr0kfr.js +0 -7
  216. package/chunk-bpw6q7g0.js +0 -3
  217. package/chunk-c6q04xrd.js +0 -3
  218. package/chunk-cmwdjes8.js +0 -18
  219. package/chunk-dfh9m9n7.js +0 -7
  220. package/chunk-dq01v5eq.js +0 -2
  221. package/chunk-e1x629v0.js +0 -5
  222. package/chunk-gbjn6d81.js +0 -2
  223. package/chunk-jymx3a77.js +0 -3951
  224. package/chunk-m1eam0s5.js +0 -2
  225. package/chunk-mbpb5c7w.js +0 -2
  226. package/chunk-pnspvnyd.js +0 -2
  227. package/chunk-pz2afna8.js +0 -2
  228. package/chunk-qaeyhe65.js +0 -2
  229. package/chunk-qnkrrwmg.js +0 -2
  230. package/chunk-v3ee9z3f.js +0 -2
  231. package/chunk-vtqr7dm8.js +0 -3
  232. package/chunk-zq32mwxj.js +0 -479
  233. package/web/chunk-086dshck.js +0 -1
  234. package/web/chunk-0fy590s0.js +0 -1
  235. package/web/chunk-0mdf1qja.js +0 -1
  236. package/web/chunk-0y971zgq.js +0 -2
  237. package/web/chunk-32zmk3f5.js +0 -1
  238. package/web/chunk-3d3wnh8a.js +0 -2
  239. package/web/chunk-48479gnx.js +0 -1
  240. package/web/chunk-4rwwtfnd.js +0 -2
  241. package/web/chunk-6cjm2yr7.js +0 -1
  242. package/web/chunk-7ycxz39p.js +0 -1
  243. package/web/chunk-8z7texmv.js +0 -1
  244. package/web/chunk-9jy8nc4r.js +0 -1
  245. package/web/chunk-9wr33d0t.js +0 -1
  246. package/web/chunk-a4tdrxdh.js +0 -1
  247. package/web/chunk-a9fvsyc1.js +0 -1
  248. package/web/chunk-apvbvg4d.js +0 -1
  249. package/web/chunk-bkxcc7v5.js +0 -1
  250. package/web/chunk-bve354k7.js +0 -1
  251. package/web/chunk-cwpxakby.js +0 -1
  252. package/web/chunk-d3f763n7.js +0 -2
  253. package/web/chunk-dtrh40vr.js +0 -1
  254. package/web/chunk-e68jw0bg.js +0 -1
  255. package/web/chunk-jd7npyv9.js +0 -8
  256. package/web/chunk-jhpg2kcf.js +0 -1
  257. package/web/chunk-jqqbkdtw.js +0 -4
  258. package/web/chunk-jzz5htxp.js +0 -1
  259. package/web/chunk-ka3q31t1.js +0 -1
  260. package/web/chunk-kahab58k.js +0 -1139
  261. package/web/chunk-krgvx75q.js +0 -1
  262. package/web/chunk-kxeaj44h.js +0 -1
  263. package/web/chunk-m1rdyvb5.js +0 -1
  264. package/web/chunk-m7k4wr3k.js +0 -1
  265. package/web/chunk-mdj3r75b.js +0 -1
  266. package/web/chunk-nbcpbqq4.js +0 -1
  267. package/web/chunk-nkpdd9hw.js +0 -1
  268. package/web/chunk-p1yc8hwn.js +0 -2
  269. package/web/chunk-p29brxyt.js +0 -1
  270. package/web/chunk-p8fbes0t.js +0 -1
  271. package/web/chunk-pbp1p5ex.js +0 -1
  272. package/web/chunk-q65zxczs.js +0 -34
  273. package/web/chunk-r6q1301x.js +0 -1
  274. package/web/chunk-r8kghrkb.js +0 -1
  275. package/web/chunk-rhxn7mxg.js +0 -1
  276. package/web/chunk-rqympya7.js +0 -2
  277. package/web/chunk-svqshmpg.js +0 -1
  278. package/web/chunk-swzxq7r3.css +0 -1
  279. package/web/chunk-t18tn37m.js +0 -2
  280. package/web/chunk-tbsaseer.js +0 -1
  281. package/web/chunk-tgkdyxbn.js +0 -1
  282. package/web/chunk-v0zfnvc1.js +0 -1
  283. package/web/chunk-vj31fs16.js +0 -1
  284. package/web/chunk-vr79r8vh.js +0 -1
  285. package/web/chunk-wb9tax0m.js +0 -1
  286. package/web/chunk-x9eghjjd.js +0 -1
  287. package/web/chunk-z3ky5ews.js +0 -2
@@ -1,12 +1,12 @@
1
1
  // @bun
2
- import{W}from"./chunk-4gtgqcct.js";import{Ye}from"./chunk-7jezts2n.js";import{fe,Or,Nr,pe,Yt,ge}from"./chunk-r4ttdkrz.js";import{y}from"./chunk-3k627vf2.js";import{U,Le,re,Se,Q}from"./chunk-1n7dat03.js";function j(a,o){let l={v:1,id:a};if(o)l.phase=o;return JSON.stringify(l)}function E(a){if(!a)return;if(a.startsWith("{"))try{let o=JSON.parse(a);if(o.v===1&&typeof o.id==="string"){if(o.phase==="commentary"||o.phase==="final_answer")return{id:o.id,phase:o.phase};return{id:o.id}}}catch{}return{id:a}}function N(a,o){let l=o.filter((c)=>c.type==="text").map((c)=>c.text).join(`
3
- `),d=o.filter((c)=>c.type==="image"),u=l.length>0;if(d.length===0||!a.input.includes("image"))return y(u?l:d.length>0?"(see attached image)":"(no tool output)");let p=[];if(u)p.push({type:"input_text",text:y(l)});for(let c of d)p.push({type:"input_image",detail:"auto",image_url:`data:${c.mimeType};base64,${c.data}`});return p}function at(a,o,l,d){let u=re(o,d?.supportsMidConvoSystemMessages),p=[],c=(n)=>{let s=n.replace(/[^a-zA-Z0-9_-]/g,"_");return(s.length>64?s.slice(0,64):s).replace(/_+$/,"")},b=(n)=>{let s=`fc_${Ye(n)}`;return s.length>64?s.slice(0,64):s},k=(n,s,i)=>{if(!l.has(a.provider))return c(n);if(!n.includes("|"))return c(n);let[r,g]=n.split("|"),h=c(r),x=i.provider!==a.provider||i.api!==a.api?b(g):c(g);if(!x.startsWith("fc_"))x=c(`fc_${x}`);return`${h}|${x}`},m=ge(u.messages,a,k),I=Se(u.messages,(d?.supportsAdditionalTools??!1)||(d?.supportsToolSearch??!1)),v=(n,s)=>{let i=I.anchorsAdditions?n.toolsAdded??[]:[];if(i.length===0)return;if(d?.supportsAdditionalTools){p.push({type:"additional_tools",role:"developer",tools:Je(i,d.toolOptions)});return}if(!d?.supportsToolSearch)return;let r=i.map((h)=>h.name),g=`pi_tool_load_${Ye(`${s}:${r.join(",")}`)}`;p.push({type:"tool_search_call",call_id:g,execution:"client",status:"completed",arguments:{query:r.join(" "),limit:r.length}}),p.push({type:"tool_search_output",call_id:g,execution:"client",status:"completed",tools:Je(i,{...d.toolOptions,toolSearchResult:!0})})},C=d?.includeSystemPrompt??!0,w=a.compat,M=a.reasoning&&w?.supportsDeveloperRole!==!1?"developer":"system",t=0,e=0;for(let n of m){let s=e++===0&&n.role==="system";if(n.role==="system"){if(!s)v(n,`system:${t}`);if(!s||C){let i=s?U(n):Le(n);if(i.length>0)p.push({role:M,content:y(i)})}}else if(n.role==="user")if(typeof n.content==="string")p.push({role:"user",content:[{type:"input_text",text:y(n.content)}]});else{let i=n.content.map((r)=>{if(r.type==="text")return{type:"input_text",text:y(r.text)};return{type:"input_image",detail:"auto",image_url:`data:${r.mimeType};base64,${r.data}`}});if(i.length===0)continue;p.push({role:"user",content:i})}else if(n.role==="assistant"){let i=[],r=n,g=r.provider===a.provider&&r.api===a.api,h=g&&r.model===a.id,P=g&&r.model!==a.id,x=0;for(let S of n.content)if(S.type==="thinking"){if(S.thinkingSignature){let f=JSON.parse(S.thinkingSignature);i.push(f)}}else if(S.type==="text"){let f=S,T=E(f.textSignature),J=x===0?`msg_pi_${t}`:`msg_pi_${t}_${x}`;x++;let _=T?.id;if(!_)_=J;else if(_.length>64)_=`msg_${Ye(_)}`;i.push({type:"message",role:"assistant",content:[{type:"output_text",text:y(f.text),annotations:[]}],status:"completed",id:_,phase:T?.phase})}else if(S.type==="toolCall"){let f=S,[T,J]=f.id.split("|"),_=d?.grammarToolInputProperties?.get(f.name),R=J,A=_===void 0?"fc_":"ctc_";if(P||!R?.startsWith(A))R=void 0;if(_!==void 0)i.push({type:"custom_tool_call",id:R,call_id:T,name:f.name,input:y(Or(f.name,f.arguments,_)),...h&&f.namespace!==void 0?{namespace:f.namespace}:{}});else i.push({type:"function_call",id:R,call_id:T,name:f.name,arguments:JSON.stringify(f.arguments),...h&&f.namespace!==void 0?{namespace:f.namespace}:{}})}if(i.length===0)continue;p.push(...i)}else if(n.role==="toolResult"){let[i]=n.toolCallId.split("|"),r=N(a,n.content);if(d?.grammarToolInputProperties?.has(n.toolName))p.push({type:"custom_tool_call_output",call_id:i,output:r});else p.push({type:"function_call_output",call_id:i,output:r})}if(!s)t++}return p}function Je(a,o){let l=o?.strict===void 0?!1:o.strict,d=o?.supportsStrictMode??!0,u=o?.supportsOpenAIGrammarTools??!1;return a.map((p)=>{let c=Yt(p,u);if(c)return{type:"custom",name:p.name,description:p.description,format:{type:"grammar",syntax:c.format,definition:c.definition},...o?.toolSearchResult?{defer_loading:!0}:{}};let k=pe(p,d)??l,m={type:"function",name:p.name,description:p.description,parameters:fe(p,k===!0),...o?.toolSearchResult?{defer_loading:!0}:{}};if(d)m.strict=k;return m})}function z(a){let o=a.customInput?.property;if(o===void 0)return"";let l=a.arguments[o];return typeof l==="string"?l:""}function O(a,o,l){let d=a.customInput;if(!d)return;let u=Nr(d.jsonBuffer,d.property,o,l);return a.arguments={[d.property]:o},u}async function lt(a,o,l,d,u){let p=!1,c=new Map,b=new Map,k=(t)=>{if(t.type==="message"&&t.phase==="final_answer")o.stopReason="stop"},m=(t,e)=>{let n=c.get(t);return n?.type===e?n:void 0},I=(t,e)=>{if(e===void 0)return;l.push({type:"toolcall_delta",contentIndex:t.contentIndex,delta:e,partial:o})},v=(t,e)=>{if(e.type==="reasoning"){let n={type:"thinking",thinking:""};o.content.push(n);let s={type:"thinking",block:n,contentIndex:o.content.length-1};return c.set(t,s),l.push({type:"thinking_start",contentIndex:s.contentIndex,partial:o}),s}if(e.type==="message"){k(e);let n={type:"text",text:""};o.content.push(n);let s={type:"text",block:n,contentIndex:o.content.length-1};return c.set(t,s),l.push({type:"text_start",contentIndex:s.contentIndex,partial:o}),s}if(e.type==="function_call"){let n={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:{},...e.namespace!==void 0?{namespace:e.namespace}:{},partialJson:e.arguments||""};o.content.push(n);let s={type:"toolCall",block:n,contentIndex:o.content.length-1};return c.set(t,s),l.push({type:"toolcall_start",contentIndex:s.contentIndex,partial:o}),s}if(e.type==="custom_tool_call"){let n=u?.grammarToolInputProperties?.get(e.name)??"input",s=e.input||"",i={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:{[n]:s},...e.namespace!==void 0?{namespace:e.namespace}:{},customInput:{property:n,jsonBuffer:{input:"",started:!1,closed:!1}}};o.content.push(i);let r={type:"toolCall",block:i,contentIndex:o.content.length-1};return c.set(t,r),l.push({type:"toolcall_start",contentIndex:r.contentIndex,partial:o}),r}return},C=(t,e)=>c.get(t)??v(t,e),w=(t)=>{for(let e of t){if(e.type!=="reasoning"||!e.encrypted_content)continue;let n=b.get(e.id);if(!n?.thinkingSignature)continue;let s=JSON.parse(n.thinkingSignature);if(s.encrypted_content)continue;n.thinkingSignature=JSON.stringify({...s,encrypted_content:e.encrypted_content})}},M=(t)=>{if(p=!0,w(t.output??[]),t?.id)o.responseId=t.id;if(t?.usage){let r=t.usage.input_tokens_details,g=r?.cached_tokens||0,h=r?.cache_write_tokens||0;o.usage={input:Math.max(0,(t.usage.input_tokens||0)-g-h),output:t.usage.output_tokens||0,cacheRead:g,cacheWrite:h,reasoning:t.usage.output_tokens_details?.reasoning_tokens||0,totalTokens:t.usage.total_tokens||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}if(Q(d,o.usage),u?.applyServiceTierPricing){let r=u.resolveServiceTier?u.resolveServiceTier(t?.service_tier,u.serviceTier):t?.service_tier??u.serviceTier;u.applyServiceTierPricing(o.usage,r)}let e=t?.status,n=t?.incomplete_details,s=typeof n?.reason==="string"?n.reason:void 0;o.rawStopReason=s?`${e}.${s}`:e;let i=B(e,s);if(o.stopReason=i.stopReason,i.errorMessage===void 0)delete o.errorMessage;else o.errorMessage=i.errorMessage;if(o.content.some((r)=>r.type==="toolCall")&&o.stopReason==="stop")o.stopReason="toolUse"};for await(let t of a)if(await u?.onProviderStreamEvent?.(t,d),t.type==="response.created")o.responseId=t.response.id;else if(t.type==="response.output_item.added")v(t.output_index,t.item);else if(t.type==="response.reasoning_summary_text.delta"){let e=m(t.output_index,"thinking");if(!e)continue;e.block.thinking+=t.delta,l.push({type:"thinking_delta",contentIndex:e.contentIndex,delta:t.delta,partial:o})}else if(t.type==="response.reasoning_summary_part.done"){let e=m(t.output_index,"thinking");if(!e)continue;e.block.thinking+=`
2
+ import{G}from"./chunk-edbq461k.js";import{rt}from"./chunk-06s9pr82.js";import{be,Wr,Hr,fe,nr,Se}from"./chunk-2tf7qfbx.js";import{w}from"./chunk-b516bp7n.js";import{W,De,ie,ve,Y}from"./chunk-y4pvhes1.js";function j(a,o){let l={v:1,id:a};if(o)l.phase=o;return JSON.stringify(l)}function E(a){if(!a)return;if(a.startsWith("{"))try{let o=JSON.parse(a);if(o.v===1&&typeof o.id==="string"){if(o.phase==="commentary"||o.phase==="final_answer")return{id:o.id,phase:o.phase};return{id:o.id}}}catch{}return{id:a}}function N(a,o){let l=o.filter((c)=>c.type==="text").map((c)=>c.text).join(`
3
+ `),d=o.filter((c)=>c.type==="image"),u=l.length>0;if(d.length===0||!a.input.includes("image"))return w(u?l:d.length>0?"(see attached image)":"(no tool output)");let p=[];if(u)p.push({type:"input_text",text:w(l)});for(let c of d)p.push({type:"input_image",detail:"auto",image_url:`data:${c.mimeType};base64,${c.data}`});return p}function ut(a,o,l,d){let u=ie(o,d?.supportsMidConvoSystemMessages),p=[],c=(n)=>{let s=n.replace(/[^a-zA-Z0-9_-]/g,"_");return(s.length>64?s.slice(0,64):s).replace(/_+$/,"")},S=(n)=>{let s=`fc_${rt(n)}`;return s.length>64?s.slice(0,64):s},x=(n,s,i)=>{if(!l.has(a.provider))return c(n);if(!n.includes("|"))return c(n);let[r,g]=n.split("|"),h=c(r),y=i.provider!==a.provider||i.api!==a.api?S(g):c(g);if(!y.startsWith("fc_"))y=c(`fc_${y}`);return`${h}|${y}`},m=Se(u.messages,a,x),k=ve(u.messages,(d?.supportsAdditionalTools??!1)||(d?.supportsToolSearch??!1)),T=(n,s)=>{let i=k.anchorsAdditions?n.toolsAdded??[]:[];if(i.length===0)return;if(d?.supportsAdditionalTools){p.push({type:"additional_tools",role:"developer",tools:tt(i,d.toolOptions)});return}if(!d?.supportsToolSearch)return;let r=i.map((h)=>h.name),g=`pi_tool_load_${rt(`${s}:${r.join(",")}`)}`;p.push({type:"tool_search_call",call_id:g,execution:"client",status:"completed",arguments:{query:r.join(" "),limit:r.length}}),p.push({type:"tool_search_output",call_id:g,execution:"client",status:"completed",tools:tt(i,{...d.toolOptions,toolSearchResult:!0})})},R=d?.includeSystemPrompt??!0,C=a.compat,M=a.reasoning&&C?.supportsDeveloperRole!==!1?"developer":"system",t=0,e=0;for(let n of m){let s=e++===0&&n.role==="system";if(n.role==="system"){if(!s)T(n,`system:${t}`);if(!s||R){let i=s?W(n):De(n);if(i.length>0)p.push({role:M,content:w(i)})}}else if(n.role==="user")if(typeof n.content==="string")p.push({role:"user",content:[{type:"input_text",text:w(n.content)}]});else{let i=n.content.map((r)=>{if(r.type==="text")return{type:"input_text",text:w(r.text)};return{type:"input_image",detail:"auto",image_url:`data:${r.mimeType};base64,${r.data}`}});if(i.length===0)continue;p.push({role:"user",content:i})}else if(n.role==="assistant"){let i=[],r=n,g=r.provider===a.provider&&r.api===a.api,h=g&&r.model===a.id,P=g&&r.model!==a.id,y=0;for(let I of n.content)if(I.type==="thinking"){if(I.thinkingSignature){let f=JSON.parse(I.thinkingSignature);i.push(f)}}else if(I.type==="text"){let f=I,b=E(f.textSignature),J=y===0?`msg_pi_${t}`:`msg_pi_${t}_${y}`;y++;let _=b?.id;if(!_)_=J;else if(_.length>64)_=`msg_${rt(_)}`;i.push({type:"message",role:"assistant",content:[{type:"output_text",text:w(f.text),annotations:[]}],status:"completed",id:_,phase:b?.phase})}else if(I.type==="toolCall"){let f=I,[b,J]=f.id.split("|"),_=d?.grammarToolInputProperties?.get(f.name),v=J,A=_===void 0?"fc_":"ctc_";if(P||!v?.startsWith(A))v=void 0;if(_!==void 0)i.push({type:"custom_tool_call",id:v,call_id:b,name:f.name,input:w(Wr(f.name,f.arguments,_)),...h&&f.namespace!==void 0?{namespace:f.namespace}:{}});else i.push({type:"function_call",id:v,call_id:b,name:f.name,arguments:JSON.stringify(f.arguments),...h&&f.namespace!==void 0?{namespace:f.namespace}:{}})}if(i.length===0)continue;p.push(...i)}else if(n.role==="toolResult"){let[i]=n.toolCallId.split("|"),r=N(a,n.content);if(d?.grammarToolInputProperties?.has(n.toolName))p.push({type:"custom_tool_call_output",call_id:i,output:r});else p.push({type:"function_call_output",call_id:i,output:r})}if(!s)t++}return p}function tt(a,o){let l=o?.strict===void 0?!1:o.strict,d=o?.supportsStrictMode??!0,u=o?.supportsOpenAIGrammarTools??!1;return a.map((p)=>{let c=nr(p,u);if(c)return{type:"custom",name:p.name,description:p.description,format:{type:"grammar",syntax:c.format,definition:c.definition},...o?.toolSearchResult?{defer_loading:!0}:{}};let x=fe(p,d)??l,m={type:"function",name:p.name,description:p.description,parameters:be(p,x===!0),...o?.toolSearchResult?{defer_loading:!0}:{}};if(d)m.strict=x;return m})}function z(a){let o=a.customInput?.property;if(o===void 0)return"";let l=a.arguments[o];return typeof l==="string"?l:""}function O(a,o,l){let d=a.customInput;if(!d)return;let u=Hr(d.jsonBuffer,d.property,o,l);return a.arguments={[d.property]:o},u}async function pt(a,o,l,d,u){let p=!1,c=new Map,S=new Map,x=(t)=>{if(t.type==="message"&&t.phase==="final_answer")o.stopReason="stop"},m=(t,e)=>{let n=c.get(t);return n?.type===e?n:void 0},k=(t,e)=>{if(e===void 0)return;l.push({type:"toolcall_delta",contentIndex:t.contentIndex,delta:e,partial:o})},T=(t,e)=>{if(e.type==="reasoning"){let n={type:"thinking",thinking:""};o.content.push(n);let s={type:"thinking",block:n,contentIndex:o.content.length-1};return c.set(t,s),l.push({type:"thinking_start",contentIndex:s.contentIndex,partial:o}),s}if(e.type==="message"){x(e);let n={type:"text",text:""};o.content.push(n);let s={type:"text",block:n,contentIndex:o.content.length-1};return c.set(t,s),l.push({type:"text_start",contentIndex:s.contentIndex,partial:o}),s}if(e.type==="function_call"){let n={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:{},...e.namespace!==void 0?{namespace:e.namespace}:{},partialJson:e.arguments||""};o.content.push(n);let s={type:"toolCall",block:n,contentIndex:o.content.length-1};return c.set(t,s),l.push({type:"toolcall_start",contentIndex:s.contentIndex,partial:o}),s}if(e.type==="custom_tool_call"){let n=u?.grammarToolInputProperties?.get(e.name)??"input",s=e.input||"",i={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:{[n]:s},...e.namespace!==void 0?{namespace:e.namespace}:{},customInput:{property:n,jsonBuffer:{input:"",started:!1,closed:!1}}};o.content.push(i);let r={type:"toolCall",block:i,contentIndex:o.content.length-1};return c.set(t,r),l.push({type:"toolcall_start",contentIndex:r.contentIndex,partial:o}),r}return},R=(t,e)=>c.get(t)??T(t,e),C=(t)=>{for(let e of t){if(e.type!=="reasoning"||!e.encrypted_content)continue;let n=S.get(e.id);if(!n?.thinkingSignature)continue;let s=JSON.parse(n.thinkingSignature);if(s.encrypted_content)continue;n.thinkingSignature=JSON.stringify({...s,encrypted_content:e.encrypted_content})}},M=(t)=>{if(p=!0,C(t.output??[]),t?.id)o.responseId=t.id;if(t?.usage){let r=t.usage.input_tokens_details,g=r?.cached_tokens||0,h=r?.cache_write_tokens||0;o.usage={input:Math.max(0,(t.usage.input_tokens||0)-g-h),output:t.usage.output_tokens||0,cacheRead:g,cacheWrite:h,reasoning:t.usage.output_tokens_details?.reasoning_tokens||0,totalTokens:t.usage.total_tokens||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}if(Y(d,o.usage),u?.applyServiceTierPricing){let r=u.resolveServiceTier?u.resolveServiceTier(t?.service_tier,u.serviceTier):t?.service_tier??u.serviceTier;u.applyServiceTierPricing(o.usage,r)}let e=t?.status,n=t?.incomplete_details,s=typeof n?.reason==="string"?n.reason:void 0;o.rawStopReason=s?`${e}.${s}`:e;let i=B(e,s);if(o.stopReason=i.stopReason,i.errorMessage===void 0)delete o.errorMessage;else o.errorMessage=i.errorMessage;if(o.content.some((r)=>r.type==="toolCall")&&o.stopReason==="stop")o.stopReason="toolUse"};for await(let t of a)if(await u?.onProviderStreamEvent?.(t,d),t.type==="response.created")o.responseId=t.response.id;else if(t.type==="response.output_item.added")T(t.output_index,t.item);else if(t.type==="response.reasoning_summary_text.delta"){let e=m(t.output_index,"thinking");if(!e)continue;e.block.thinking+=t.delta,l.push({type:"thinking_delta",contentIndex:e.contentIndex,delta:t.delta,partial:o})}else if(t.type==="response.reasoning_summary_part.done"){let e=m(t.output_index,"thinking");if(!e)continue;e.block.thinking+=`
4
4
 
5
5
  `,l.push({type:"thinking_delta",contentIndex:e.contentIndex,delta:`
6
6
 
7
- `,partial:o})}else if(t.type==="response.reasoning_text.delta"){let e=m(t.output_index,"thinking");if(!e)continue;e.block.thinking+=t.delta,l.push({type:"thinking_delta",contentIndex:e.contentIndex,delta:t.delta,partial:o})}else if(t.type==="response.output_text.delta"){let e=m(t.output_index,"text");if(!e)continue;e.block.text+=t.delta,l.push({type:"text_delta",contentIndex:e.contentIndex,delta:t.delta,partial:o})}else if(t.type==="response.refusal.delta"){let e=m(t.output_index,"text");if(!e)continue;e.block.text+=t.delta,l.push({type:"text_delta",contentIndex:e.contentIndex,delta:t.delta,partial:o})}else if(t.type==="response.function_call_arguments.delta"){let e=m(t.output_index,"toolCall");if(!e||e.block.partialJson===void 0)continue;e.block.partialJson+=t.delta,e.block.arguments=W(e.block.partialJson),I(e,t.delta)}else if(t.type==="response.function_call_arguments.done"){let e=m(t.output_index,"toolCall");if(!e||e.block.partialJson===void 0)continue;let n=e.block.partialJson;if(e.block.partialJson=t.arguments,e.block.arguments=W(e.block.partialJson),t.arguments.startsWith(n)){let s=t.arguments.slice(n.length);if(s.length>0)I(e,s)}}else if(t.type==="response.custom_tool_call_input.delta"){let e=m(t.output_index,"toolCall");if(!e||!e.block.customInput)continue;I(e,O(e.block,z(e.block)+t.delta,!1))}else if(t.type==="response.custom_tool_call_input.done"){let e=m(t.output_index,"toolCall");if(!e||!e.block.customInput)continue;I(e,O(e.block,t.input,!0))}else if(t.type==="response.output_item.done"){let e=t.item;k(e);let n=C(t.output_index,e);if(e.type==="reasoning"&&n?.type==="thinking"){let s=e.summary?.map((r)=>r.text).join(`
7
+ `,partial:o})}else if(t.type==="response.reasoning_text.delta"){let e=m(t.output_index,"thinking");if(!e)continue;e.block.thinking+=t.delta,l.push({type:"thinking_delta",contentIndex:e.contentIndex,delta:t.delta,partial:o})}else if(t.type==="response.output_text.delta"){let e=m(t.output_index,"text");if(!e)continue;e.block.text+=t.delta,l.push({type:"text_delta",contentIndex:e.contentIndex,delta:t.delta,partial:o})}else if(t.type==="response.refusal.delta"){let e=m(t.output_index,"text");if(!e)continue;e.block.text+=t.delta,l.push({type:"text_delta",contentIndex:e.contentIndex,delta:t.delta,partial:o})}else if(t.type==="response.function_call_arguments.delta"){let e=m(t.output_index,"toolCall");if(!e||e.block.partialJson===void 0)continue;e.block.partialJson+=t.delta,e.block.arguments=G(e.block.partialJson),k(e,t.delta)}else if(t.type==="response.function_call_arguments.done"){let e=m(t.output_index,"toolCall");if(!e||e.block.partialJson===void 0)continue;let n=e.block.partialJson;if(e.block.partialJson=t.arguments,e.block.arguments=G(e.block.partialJson),t.arguments.startsWith(n)){let s=t.arguments.slice(n.length);if(s.length>0)k(e,s)}}else if(t.type==="response.custom_tool_call_input.delta"){let e=m(t.output_index,"toolCall");if(!e||!e.block.customInput)continue;k(e,O(e.block,z(e.block)+t.delta,!1))}else if(t.type==="response.custom_tool_call_input.done"){let e=m(t.output_index,"toolCall");if(!e||!e.block.customInput)continue;k(e,O(e.block,t.input,!0))}else if(t.type==="response.output_item.done"){let e=t.item;x(e);let n=R(t.output_index,e);if(e.type==="reasoning"&&n?.type==="thinking"){let s=e.summary?.map((r)=>r.text).join(`
8
8
 
9
9
  `)||"",i=e.content?.map((r)=>r.text).join(`
10
10
 
11
- `)||"";n.block.thinking=s||i||n.block.thinking,n.block.thinkingSignature=JSON.stringify(e),b.set(e.id,n.block),l.push({type:"thinking_end",contentIndex:n.contentIndex,content:n.block.thinking,partial:o}),c.delete(t.output_index)}else if(e.type==="message"&&n?.type==="text")n.block.text=e.content?.map((s)=>s.type==="output_text"?s.text:s.refusal).join("")||"",n.block.textSignature=j(e.id,e.phase??void 0),l.push({type:"text_end",contentIndex:n.contentIndex,content:n.block.text,partial:o}),c.delete(t.output_index);else if(e.type==="function_call"&&n?.type==="toolCall"&&n.block.partialJson!==void 0){if(n.block.arguments=W(e.arguments||n.block.partialJson||"{}"),e.namespace!==void 0)n.block.namespace=e.namespace;delete n.block.partialJson,l.push({type:"toolcall_end",contentIndex:n.contentIndex,toolCall:n.block,partial:o}),c.delete(t.output_index)}else if(e.type==="custom_tool_call"&&n?.type==="toolCall"&&n.block.customInput){if(I(n,O(n.block,e.input??z(n.block),!0)),e.namespace!==void 0)n.block.namespace=e.namespace;delete n.block.customInput,l.push({type:"toolcall_end",contentIndex:n.contentIndex,toolCall:n.block,partial:o}),c.delete(t.output_index)}}else if(t.type==="response.completed"||t.type==="response.incomplete")M(t.response);else if(t.type==="error")throw Error(`Error Code ${t.code}: ${t.message}`||"Unknown error");else if(t.type==="response.failed"){p=!0,o.rawStopReason=t.response?.status;let e=t.response?.error,n=t.response?.incomplete_details,s=e?`${e.code||"unknown"}: ${e.message||"no message"}`:n?.reason?`incomplete: ${n.reason}`:"Unknown error (no error details in response)";throw Error(s)}if(!p)throw Error("OpenAI Responses stream ended before a terminal response event");if(o.stopReason==="toolUse")for(let t of o.content){if(t.type!=="toolCall")continue;let e=t;if(e.partialJson!==void 0||e.customInput!==void 0)throw Error(`OpenAI Responses stream completed with an unfinished tool call: ${e.name} (${e.id})`)}}function B(a,o){if(!a)return{stopReason:"stop"};switch(a){case"completed":return{stopReason:"stop"};case"incomplete":if(o==="max_output_tokens")return{stopReason:"length"};return{stopReason:"error",errorMessage:o?`Response incomplete: ${o}`:"Response incomplete without a provider reason"};case"failed":case"cancelled":return{stopReason:"error"};case"in_progress":case"queued":return{stopReason:"stop"};default:throw Error(`Unhandled stop reason: ${a}`)}}
12
- export{at,Je,lt};
11
+ `)||"";n.block.thinking=s||i||n.block.thinking,n.block.thinkingSignature=JSON.stringify(e),S.set(e.id,n.block),l.push({type:"thinking_end",contentIndex:n.contentIndex,content:n.block.thinking,partial:o}),c.delete(t.output_index)}else if(e.type==="message"&&n?.type==="text")n.block.text=e.content?.map((s)=>s.type==="output_text"?s.text:s.refusal).join("")||"",n.block.textSignature=j(e.id,e.phase??void 0),l.push({type:"text_end",contentIndex:n.contentIndex,content:n.block.text,partial:o}),c.delete(t.output_index);else if(e.type==="function_call"&&n?.type==="toolCall"&&n.block.partialJson!==void 0){if(n.block.arguments=G(e.arguments||n.block.partialJson||"{}"),e.namespace!==void 0)n.block.namespace=e.namespace;delete n.block.partialJson,l.push({type:"toolcall_end",contentIndex:n.contentIndex,toolCall:n.block,partial:o}),c.delete(t.output_index)}else if(e.type==="custom_tool_call"&&n?.type==="toolCall"&&n.block.customInput){if(k(n,O(n.block,e.input??z(n.block),!0)),e.namespace!==void 0)n.block.namespace=e.namespace;delete n.block.customInput,l.push({type:"toolcall_end",contentIndex:n.contentIndex,toolCall:n.block,partial:o}),c.delete(t.output_index)}}else if(t.type==="response.completed"||t.type==="response.incomplete")M(t.response);else if(t.type==="error")throw Error(`Error Code ${t.code}: ${t.message}`||"Unknown error");else if(t.type==="response.failed"){p=!0,o.rawStopReason=t.response?.status;let e=t.response?.error,n=t.response?.incomplete_details,s=e?`${e.code||"unknown"}: ${e.message||"no message"}`:n?.reason?`incomplete: ${n.reason}`:"Unknown error (no error details in response)";throw Error(s)}if(!p)throw Error("OpenAI Responses stream ended before a terminal response event");if(o.stopReason==="toolUse")for(let t of o.content){if(t.type!=="toolCall")continue;let e=t;if(e.partialJson!==void 0||e.customInput!==void 0)throw Error(`OpenAI Responses stream completed with an unfinished tool call: ${e.name} (${e.id})`)}}function B(a,o){if(!a)return{stopReason:"stop"};switch(a){case"completed":return{stopReason:"stop"};case"incomplete":if(o==="max_output_tokens")return{stopReason:"length"};return{stopReason:"error",errorMessage:o?`Response incomplete: ${o}`:"Response incomplete without a provider reason"};case"failed":case"cancelled":return{stopReason:"error"};case"in_progress":case"queued":return{stopReason:"stop"};default:throw Error(`Unhandled stop reason: ${a}`)}}
12
+ export{ut,tt,pt};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{S}from"./chunk-15ve3nmv.js";import{v}from"./chunk-4rnmxtpx.js";import"./chunk-edbq461k.js";import{ut,tt,pt}from"./chunk-z0c8ek0j.js";import{Pt,Tt}from"./chunk-snz19yc2.js";import{Ke}from"./chunk-86yr2c0r.js";import{ne}from"./chunk-959z9efn.js";import{ue}from"./chunk-vqm94hz2.js";import{Re,dt,X}from"./chunk-2tf7qfbx.js";import{j,J}from"./chunk-rn3jwyh1.js";import{Q}from"./chunk-tfhp09nj.js";import{ie,xe,ve,V}from"./chunk-y4pvhes1.js";import{D}from"./chunk-szj85dqe.js";var P=new Set(["openai","openai-codex","opencode","chatgpt:subscription"]),O=16,E="https://chatgpt.com/settings/usage";function _(e,s){return(e.provider==="openai"||e.provider==="chatgpt:subscription")&&e.baseUrl==="https://api.openai.com/v1"&&s!==void 0&&!s.startsWith("sk-")}function h(e,s){if(!e)return!1;let r=s.toLowerCase();for(let[t,i]of Object.entries(e))if(t.toLowerCase()===r&&i!==null&&i.trim().length>0)return!0;return!1}function T(e,s,r){if(s)return s;if(h(r,"authorization")||h(r,"cf-aig-authorization"))return"unused";throw Error(`No API key for provider: ${e}`)}function I(e){return e.provider==="openrouter"||e.baseUrl.includes("openrouter.ai")?"openrouter":"openai"}function R(e,s){if(e)return e;if(v("PI_CACHE_RETENTION",s)==="long")return"long";return"short"}function d(e){return{supportsDeveloperRole:e.compat?.supportsDeveloperRole??!0,supportsMidConvoSystemMessages:e.compat?.supportsMidConvoSystemMessages??!1,sessionAffinityFormat:e.compat?.sessionAffinityFormat??I(e),supportsLongCacheRetention:e.compat?.supportsLongCacheRetention??!0,supportsStrictMode:e.compat?.supportsStrictMode??!1,supportsOpenAIGrammarTools:e.compat?.supportsOpenAIGrammarTools??!1,supportsAdditionalTools:e.compat?.supportsAdditionalTools??!1,supportsToolSearch:e.compat?.supportsToolSearch??!1,supportsExplicitPromptCacheMode:e.compat?.supportsExplicitPromptCacheMode??!1,supportsMaxOutputTokens:e.compat?.supportsMaxOutputTokens??!0}}function w(e,s){return s==="long"&&e.supportsLongCacheRetention&&!e.supportsExplicitPromptCacheMode?"24h":void 0}function x(e,s){if(!e.supportsExplicitPromptCacheMode)return;if(s==="none")return{mode:"explicit"};if(s==="long"&&e.supportsLongCacheRetention)return{ttl:"30m"};return}var b=(e,s,r)=>{let t=new D,i=ie(s,d(e).supportsMidConvoSystemMessages);return(async()=>{let o={role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()};try{let c=T(e.provider,r?.apiKey,r?.headers),p=R(r?.cacheRetention,r?.env)==="none"?void 0:r?.sessionId,n=d(e),u=Re(xe(i.messages),n.supportsOpenAIGrammarTools),l=k(e,i,c,r?.headers,r?.fetch,p),f=L(e,i,r,n,u),m=await r?.onPayload?.(f,e);if(m!==void 0)f=m;let y={...r?.signal?{signal:r.signal}:{},...r?.timeoutMs!==void 0?{timeout:r.timeoutMs}:{},maxRetries:0},{data:M,response:g}=await ue(()=>l.responses.create(f,y).withResponse(),{maxRetries:r?.maxRetries,maxRetryDelayMs:r?.maxRetryDelayMs,signal:r?.signal});if(await r?.onResponse?.({status:g.status,headers:Q(g.headers)},e),t.push({type:"start",partial:o}),await pt(M,o,t,e,{onProviderStreamEvent:r?.onProviderStreamEvent,serviceTier:r?.serviceTier,grammarToolInputProperties:u,applyServiceTierPricing:(C,A)=>U(C,A,e)}),r?.signal?.aborted)throw Error("Request was aborted");if(o.stopReason==="pending")throw Error("OpenAI Responses stream ended without a stop reason");if(o.stopReason==="aborted"||o.stopReason==="error")throw Error(o.errorMessage||"An unknown error occurred");t.push({type:"done",reason:o.stopReason,message:o}),t.end()}catch(c){for(let p of o.content)delete p.index,delete p.partialJson,delete p.customInput;o.stopReason=r?.signal?.aborted?"aborted":"error";let a=J(j(c),`${e.provider==="openai"?"OpenAI":e.provider} API error`);o.errorMessage=a.includes("subscription_sharing_usage_limit_exceeded")?`${a}
3
+ Check your ChatGPT usage: ${E}`:a,t.push({type:"error",reason:o.stopReason,error:o}),t.end()}})(),t},oe=(e,s,r)=>{T(e.provider,r?.apiKey,r?.headers);let t={...X(e,s,r,r?.apiKey),toolChoice:r?.toolChoice},i=r?.reasoning?V(e,r.reasoning):void 0;return b(e,s,{...t,reasoningEffort:i==="off"?void 0:i})};function k(e,s,r,t,i,o){let c=d(e),a={"User-Agent":ne(),...e.headers};if(e.provider==="github-copilot"){let p=Pt(s.messages),n=Tt({messages:s.messages,hasImages:p});Object.assign(a,n)}if(o)if(c.sessionAffinityFormat==="openrouter")a["x-session-id"]=o;else{if(c.sessionAffinityFormat==="openai")a.session_id=o;a["x-client-request-id"]=o}if(t)Object.assign(a,t);return new S({apiKey:r,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,fetch:i,defaultHeaders:a})}function L(e,s,r,t=d(e),i=Re(xe(s.messages),t.supportsOpenAIGrammarTools)){let o=ve(s.messages,t.supportsAdditionalTools||t.supportsToolSearch),c=ut(e,s,P,{grammarToolInputProperties:i,supportsMidConvoSystemMessages:t.supportsMidConvoSystemMessages,supportsAdditionalTools:t.supportsAdditionalTools,supportsToolSearch:t.supportsToolSearch,toolOptions:{supportsStrictMode:t.supportsStrictMode,supportsOpenAIGrammarTools:t.supportsOpenAIGrammarTools}}),a=R(r?.cacheRetention,r?.env),p=_(e,r?.apiKey),n={model:e.id,input:c,stream:!0,prompt_cache_key:a==="none"?void 0:Ke(r?.sessionId),prompt_cache_retention:p?void 0:w(t,a),prompt_cache_options:p?void 0:x(t,a),store:!1};if(r?.maxTokens&&t.supportsMaxOutputTokens&&!p)n.max_output_tokens=Math.max(r.maxTokens,O);if(r?.temperature!==void 0&&!p)n.temperature=r?.temperature;if(r?.serviceTier!==void 0)n.service_tier=r.serviceTier;if(o.requestTools.length>0)n.tools=tt(o.requestTools,{supportsStrictMode:t.supportsStrictMode,supportsOpenAIGrammarTools:t.supportsOpenAIGrammarTools});if(r?.toolChoice!==void 0)n.tool_choice=r.toolChoice;let u=r?.reasoningEffort??(r?.reasoningSummary?"medium":void 0);if(e.reasoning){if(u){let f=r?.reasoningEffort?e.thinkingLevelMap?.[r.reasoningEffort]??r.reasoningEffort:u;n.reasoning={effort:f,summary:r?.reasoningSummary||"auto"},n.include=["reasoning.encrypted_content"]}else if(e.provider!=="github-copilot"&&e.thinkingLevelMap?.off!==null)n.reasoning={effort:e.thinkingLevelMap?.off??"none"};if(e.provider==="xai")n.include=["reasoning.encrypted_content"]}let l=dt(e,u??"off",r?.samplingParams);if(l)Object.assign(n,l);return n}function G(e,s){switch(s){case"flex":return 0.5;case"priority":case"fast":return e.id==="gpt-5.5"?2.5:2;default:return 1}}function U(e,s,r){let t=G(r,s);if(t===1)return;e.cost.input*=t,e.cost.output*=t,e.cost.cacheRead*=t,e.cost.cacheWrite*=t,e.cost.total=e.cost.input+e.cost.output+e.cost.cacheRead+e.cost.cacheWrite}export{b as stream,oe as streamSimple};