claude-code-best 1.3.7 → 1.4.1

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 (378) hide show
  1. package/README.md +1 -0
  2. package/dist/{chunk-cdgv0k77.js → chunk-00vfg42v.js} +61 -59
  3. package/dist/{chunk-6ex0f5ej.js → chunk-01ysfcs0.js} +6 -8
  4. package/dist/{chunk-1vzb650a.js → chunk-04ws37gv.js} +6 -8
  5. package/dist/{chunk-7etmzq13.js → chunk-0b0fq180.js} +27 -27
  6. package/dist/{chunk-drsh1vv8.js → chunk-0cs46nj6.js} +63 -62
  7. package/dist/chunk-0fzcyd0s.js +116 -0
  8. package/dist/{chunk-7nebst32.js → chunk-0knhp7v5.js} +2 -2
  9. package/dist/{chunk-n42nvr59.js → chunk-0xth516w.js} +14 -14
  10. package/dist/{chunk-egcx83tp.js → chunk-0y6h57c5.js} +6 -6
  11. package/dist/{chunk-d267stxj.js → chunk-0z0m6mm5.js} +1 -1
  12. package/dist/{chunk-y10byvag.js → chunk-196qs1ty.js} +30 -29
  13. package/dist/chunk-1d39h7zf.js +57 -0
  14. package/dist/{chunk-antr836n.js → chunk-1k3ahc24.js} +59 -57
  15. package/dist/{chunk-5scrgrwv.js → chunk-1nhx3qpn.js} +2 -2
  16. package/dist/{chunk-zv5yt0g4.js → chunk-1qbype3e.js} +9 -9
  17. package/dist/{chunk-bkzs71af.js → chunk-1r70yykn.js} +3 -3
  18. package/dist/{chunk-tvnrwrg3.js → chunk-1x1wb96n.js} +62 -60
  19. package/dist/{chunk-j44ngncb.js → chunk-1yscv3t1.js} +7 -9
  20. package/dist/{chunk-zhe3rws3.js → chunk-27ppq985.js} +7 -9
  21. package/dist/{chunk-kbshq7zc.js → chunk-28a1ffp7.js} +59 -56
  22. package/dist/{chunk-m95fj0wm.js → chunk-2ag1bjqx.js} +4 -4
  23. package/dist/{chunk-2fx2x8qp.js → chunk-2cz1rwf3.js} +22 -21
  24. package/dist/{chunk-v1chtgnf.js → chunk-2m6jk78c.js} +1 -1
  25. package/dist/{chunk-nzchm0f2.js → chunk-2mhgyhns.js} +1 -1
  26. package/dist/{chunk-n5pe3jtt.js → chunk-2pjptqfa.js} +2 -2
  27. package/dist/{chunk-5r3wgr44.js → chunk-2qfb22ax.js} +29 -1399
  28. package/dist/{chunk-n0rn505k.js → chunk-2rcaw0yh.js} +4 -4
  29. package/dist/{chunk-wp9nwczx.js → chunk-2rtngpm1.js} +8 -10
  30. package/dist/{chunk-s2cwz71x.js → chunk-2tzmvvew.js} +60 -57
  31. package/dist/{chunk-ydraa9ey.js → chunk-2xrp0wp0.js} +70 -68
  32. package/dist/{chunk-jty4xkhc.js → chunk-313nbvgt.js} +5 -5
  33. package/dist/chunk-3e2a6c4k.js +33 -0
  34. package/dist/{chunk-hbf3y5tw.js → chunk-3fnhdnj6.js} +22 -21
  35. package/dist/{chunk-qahkzpj6.js → chunk-3g6kvmg4.js} +6 -8
  36. package/dist/{chunk-kz13d2bs.js → chunk-3mapywg0.js} +2 -2
  37. package/dist/{chunk-tw4tjc73.js → chunk-3rk983b5.js} +1 -1
  38. package/dist/chunk-3vc6mx77.js +119 -0
  39. package/dist/{chunk-nsxw7en4.js → chunk-3yzyedet.js} +23 -22
  40. package/dist/{chunk-1q82ecz5.js → chunk-40w1c21c.js} +58 -55
  41. package/dist/{chunk-bnvd1jc1.js → chunk-4brmjvph.js} +4 -4
  42. package/dist/{chunk-zwrt0s3s.js → chunk-4er46edn.js} +69 -141
  43. package/dist/{chunk-fsex4yt2.js → chunk-4h9ek408.js} +7 -9
  44. package/dist/chunk-4mdqm8b7.js +115 -0
  45. package/dist/{chunk-9p95042q.js → chunk-4qjh89qr.js} +1 -1
  46. package/dist/chunk-506gq3zq.js +104 -0
  47. package/dist/{chunk-w6rh4zpx.js → chunk-5158j5ph.js} +8 -10
  48. package/dist/{chunk-d969b8ne.js → chunk-524xgs6r.js} +7 -7
  49. package/dist/{chunk-76hrbqgr.js → chunk-52rnpp5t.js} +16 -18
  50. package/dist/{chunk-0a2qnsbr.js → chunk-54bwa086.js} +61 -57
  51. package/dist/{chunk-qn4cbm38.js → chunk-5famfv4a.js} +23 -22
  52. package/dist/{chunk-kmgp6prw.js → chunk-5khwvj1z.js} +112 -5
  53. package/dist/{chunk-9byk2a4b.js → chunk-5m7095hq.js} +25 -25
  54. package/dist/{chunk-g14ex9z0.js → chunk-5mv51kkx.js} +59 -56
  55. package/dist/{chunk-p2sww3pd.js → chunk-5vqwq0f9.js} +59 -56
  56. package/dist/{chunk-s26mv9yh.js → chunk-5zbp0a48.js} +7 -8
  57. package/dist/{chunk-pvtzf6vs.js → chunk-60xm3v9r.js} +3 -3
  58. package/dist/chunk-6356tyx5.js +32 -0
  59. package/dist/{chunk-1vzaw5f6.js → chunk-66s9m31j.js} +23 -22
  60. package/dist/{chunk-c1cm8km0.js → chunk-6ebb5ym0.js} +58 -55
  61. package/dist/{chunk-yp2yx0qj.js → chunk-6f0296p8.js} +5 -7
  62. package/dist/{chunk-m2cskgz4.js → chunk-6gftrxn5.js} +86 -81
  63. package/dist/{chunk-y95se10r.js → chunk-6h1reb8m.js} +22 -21
  64. package/dist/{chunk-fy6tp8zj.js → chunk-6pb9n4m3.js} +2 -2
  65. package/dist/{chunk-ardzdtan.js → chunk-6y2wszkc.js} +1 -1
  66. package/dist/{chunk-4ydmya8m.js → chunk-6y8e5c85.js} +24 -22
  67. package/dist/{chunk-rshk7m9c.js → chunk-718k4vsj.js} +62 -60
  68. package/dist/{chunk-tm4w23dp.js → chunk-72091jsk.js} +1 -1
  69. package/dist/{chunk-xtaw765g.js → chunk-760hjt0a.js} +3 -3
  70. package/dist/chunk-77dnrj5q.js +119 -0
  71. package/dist/{chunk-gz4r3k7a.js → chunk-77w9ffyy.js} +5 -5
  72. package/dist/{chunk-xaw4scep.js → chunk-78009jh9.js} +2 -2
  73. package/dist/{chunk-6xr5mayh.js → chunk-79vh2q13.js} +58 -55
  74. package/dist/{chunk-p7d5ms03.js → chunk-7ba2qns8.js} +22 -21
  75. package/dist/{chunk-6wrs3ahh.js → chunk-7dy65axk.js} +22 -21
  76. package/dist/{chunk-n35gnb9g.js → chunk-7hmy36fh.js} +121 -2
  77. package/dist/{chunk-erxndz83.js → chunk-7kfps7yt.js} +7 -9
  78. package/dist/chunk-7r3d9nyj.js +113 -0
  79. package/dist/{chunk-dne2ghq6.js → chunk-7yfxza07.js} +16 -22
  80. package/dist/chunk-7zw138yt.js +32 -0
  81. package/dist/{chunk-6ye6d9gw.js → chunk-81dxa3fd.js} +1 -1
  82. package/dist/{chunk-540608wh.js → chunk-86jhenxk.js} +66 -57
  83. package/dist/chunk-88mfsn97.js +115 -0
  84. package/dist/{chunk-zy4fsy90.js → chunk-8gs07wbw.js} +18 -18
  85. package/dist/{chunk-4ayhftnk.js → chunk-8h4gpg9r.js} +83 -119
  86. package/dist/{chunk-brnc96x6.js → chunk-8h7bg6q9.js} +203 -24
  87. package/dist/chunk-8mspr5sg.js +47 -0
  88. package/dist/{chunk-62dx37pf.js → chunk-8pskaz4y.js} +9 -11
  89. package/dist/{chunk-sn3wbs2w.js → chunk-8xbwczap.js} +58 -55
  90. package/dist/{chunk-tw2wjsnb.js → chunk-8xsjtkh4.js} +4 -4
  91. package/dist/{chunk-ky85ntn8.js → chunk-8y0ghcs4.js} +69 -66
  92. package/dist/chunk-8zzqydag.js +101 -0
  93. package/dist/{chunk-cpvn0j86.js → chunk-924n94wb.js} +22 -21
  94. package/dist/{chunk-0asd58w2.js → chunk-92p2k7yk.js} +11 -11
  95. package/dist/{chunk-qvywetwr.js → chunk-93cd0z7w.js} +66 -64
  96. package/dist/{chunk-db82mfh9.js → chunk-97svwq59.js} +73 -71
  97. package/dist/{chunk-3j857x3k.js → chunk-99cjjht1.js} +60 -58
  98. package/dist/{chunk-pedmqmrf.js → chunk-9awawyvh.js} +6 -6
  99. package/dist/{chunk-22rs73mh.js → chunk-9b6wqcyk.js} +60 -57
  100. package/dist/{chunk-cxf74p1t.js → chunk-9datyj43.js} +2 -2
  101. package/dist/{chunk-n1pa72ns.js → chunk-9qh5f9r3.js} +7 -12
  102. package/dist/{chunk-vb6w46m9.js → chunk-9revwk5g.js} +59 -56
  103. package/dist/{chunk-g71q1n7x.js → chunk-a0m994d6.js} +58 -55
  104. package/dist/{chunk-ftajx4gw.js → chunk-a0qhdfct.js} +49 -160
  105. package/dist/{chunk-0xq2bfvv.js → chunk-a5w8nyhg.js} +2 -2
  106. package/dist/{chunk-ms9225af.js → chunk-a85wqwq4.js} +58 -55
  107. package/dist/{chunk-3c81vb6k.js → chunk-a92eevfn.js} +6 -8
  108. package/dist/{chunk-2katyzq9.js → chunk-ab6gc90x.js} +3 -5
  109. package/dist/{chunk-j50zvssc.js → chunk-ad6rg8vz.js} +5 -5
  110. package/dist/{chunk-z7svjppe.js → chunk-admwpsa6.js} +10 -14
  111. package/dist/{chunk-v081mpyx.js → chunk-ahexmj4s.js} +24 -26
  112. package/dist/{chunk-7z0078sp.js → chunk-att0rknb.js} +2 -2
  113. package/dist/{chunk-prgsmrmy.js → chunk-axenqvc8.js} +2 -2
  114. package/dist/{chunk-mfzgqp0c.js → chunk-azq1qstz.js} +10 -14
  115. package/dist/{chunk-zajs1j2b.js → chunk-b125aa22.js} +59 -57
  116. package/dist/{chunk-9f01qpne.js → chunk-b4wfv4fx.js} +73 -71
  117. package/dist/{chunk-ns3babbs.js → chunk-b5wxetbv.js} +224 -1
  118. package/dist/chunk-b62vj92a.js +94 -0
  119. package/dist/{chunk-9v5bwvbm.js → chunk-b6drr9se.js} +63 -61
  120. package/dist/chunk-b7kfr260.js +168 -0
  121. package/dist/chunk-b9pqgq8z.js +37 -0
  122. package/dist/{chunk-c8rgc3hw.js → chunk-bevwqet9.js} +66 -64
  123. package/dist/{chunk-m2rx2dtd.js → chunk-bgf5zvvv.js} +91 -89
  124. package/dist/{chunk-fye86v7m.js → chunk-bq8zdg7m.js} +58 -55
  125. package/dist/chunk-bww2h6d4.js +114 -0
  126. package/dist/{chunk-m83vaktc.js → chunk-bx165r58.js} +1 -1
  127. package/dist/{chunk-4q5a5mjb.js → chunk-c092k38b.js} +3532 -1684
  128. package/dist/{chunk-163379k5.js → chunk-c0avjkfn.js} +58 -55
  129. package/dist/{chunk-ermvk1xn.js → chunk-c3s22pgw.js} +61 -58
  130. package/dist/{chunk-zahg0adp.js → chunk-c4g5qaey.js} +5 -5
  131. package/dist/{chunk-f6wypwa6.js → chunk-c6nthjxa.js} +6 -4
  132. package/dist/{chunk-wmd0v561.js → chunk-c7d1acex.js} +5 -7
  133. package/dist/{chunk-wmbpegg3.js → chunk-c7t69jmn.js} +1 -1
  134. package/dist/{chunk-vm0b9vaz.js → chunk-cg3bb5pe.js} +9 -9
  135. package/dist/{chunk-m8v1x99r.js → chunk-chzfw06n.js} +3 -5
  136. package/dist/chunk-cm2xfg7q.js +1394 -0
  137. package/dist/{chunk-4yxd0e7k.js → chunk-crj9bjh5.js} +58 -55
  138. package/dist/{chunk-v4nrk2f9.js → chunk-cstkqpd5.js} +7 -8
  139. package/dist/{chunk-3nwsgn73.js → chunk-ctj2ehwz.js} +59 -56
  140. package/dist/{chunk-mcbqmbp2.js → chunk-cwwfyvbq.js} +6 -4
  141. package/dist/{chunk-9nddm5c7.js → chunk-cxf9amp4.js} +2 -3
  142. package/dist/chunk-cxmyg49v.js +104 -0
  143. package/dist/{chunk-5wb5ym2h.js → chunk-cy1z66c2.js} +3 -5
  144. package/dist/{chunk-nbzntnkz.js → chunk-d2q17m4k.js} +60 -58
  145. package/dist/{chunk-ymtkahxp.js → chunk-d2wzkwws.js} +69 -66
  146. package/dist/{chunk-x4t0n8t3.js → chunk-d4qdesrx.js} +3 -4
  147. package/dist/chunk-d4zyytan.js +3802 -0
  148. package/dist/{chunk-8q4yg5pk.js → chunk-d57t992t.js} +9 -96
  149. package/dist/{chunk-g2tmm7k7.js → chunk-dafnbqhh.js} +76 -74
  150. package/dist/{chunk-tjbjxrqz.js → chunk-dfcm57ek.js} +6 -6
  151. package/dist/{chunk-ynjbppdn.js → chunk-dgnwk906.js} +60 -58
  152. package/dist/{chunk-7gxyarah.js → chunk-dhwpmz98.js} +61 -58
  153. package/dist/{chunk-yevbmk5g.js → chunk-djzvjzdg.js} +3 -3
  154. package/dist/chunk-dm5e2sj0.js +187 -0
  155. package/dist/{chunk-145d3809.js → chunk-dnpy3zcs.js} +63 -60
  156. package/dist/{chunk-h7ffkxg4.js → chunk-drvfxfe5.js} +26 -25
  157. package/dist/{chunk-c14sp904.js → chunk-dv4dsh0t.js} +7 -7
  158. package/dist/{chunk-9ejadhq8.js → chunk-dyp88vca.js} +64 -62
  159. package/dist/{chunk-xfft38wf.js → chunk-dytg8n15.js} +12 -12
  160. package/dist/{chunk-j3ctqpsn.js → chunk-e1bt4m2g.js} +2 -2
  161. package/dist/{chunk-vvm5az9j.js → chunk-e23snepr.js} +3 -3
  162. package/dist/{chunk-hgfw7nx2.js → chunk-e6sqr0av.js} +58 -55
  163. package/dist/{chunk-v7xwthvg.js → chunk-e9eyqwk5.js} +405 -283
  164. package/dist/{chunk-2wvxqpfc.js → chunk-efkjha6m.js} +8 -9
  165. package/dist/{chunk-3s2gjp2n.js → chunk-ekpm458a.js} +67 -65
  166. package/dist/{chunk-vf3etxnx.js → chunk-emxnq07z.js} +1 -1
  167. package/dist/{chunk-c4x4fb6d.js → chunk-erkssp71.js} +58 -55
  168. package/dist/chunk-es08rrda.js +112 -0
  169. package/dist/{chunk-c209ascy.js → chunk-ewxpkqxt.js} +9 -9
  170. package/dist/{chunk-1wykga1n.js → chunk-f25pnrvx.js} +4 -6
  171. package/dist/chunk-f2y3t9hh.js +295 -0
  172. package/dist/{chunk-427mfnyx.js → chunk-f31b63fd.js} +1 -1
  173. package/dist/{chunk-2dsqf7sp.js → chunk-f57cvf1d.js} +1 -1
  174. package/dist/{chunk-ry1jb15g.js → chunk-f872fekv.js} +58 -55
  175. package/dist/{chunk-r7s0jwb1.js → chunk-faey4sqw.js} +59 -56
  176. package/dist/{chunk-40ax4h54.js → chunk-fbbjchdz.js} +60 -58
  177. package/dist/{chunk-fskf0b3x.js → chunk-fbedkst6.js} +6 -8
  178. package/dist/{chunk-9msn8xwq.js → chunk-fckykghd.js} +2 -3
  179. package/dist/{chunk-ztrgnar4.js → chunk-fdbvcs34.js} +7 -9
  180. package/dist/{chunk-667f3w39.js → chunk-ffpz33kr.js} +23 -22
  181. package/dist/{chunk-0fpkjw2j.js → chunk-ffvja87d.js} +8 -10
  182. package/dist/{chunk-r6gyed9y.js → chunk-fjpdtr6s.js} +9 -9
  183. package/dist/{chunk-8y1zs48n.js → chunk-fnpd8cnq.js} +1 -1
  184. package/dist/{chunk-eef1npre.js → chunk-fxpsa506.js} +4 -6
  185. package/dist/{chunk-2z6bv21c.js → chunk-fxrrsvnw.js} +23 -27
  186. package/dist/chunk-fz4wmnm6.js +157 -0
  187. package/dist/{chunk-2c4jgf3n.js → chunk-g3dbfhxa.js} +5 -7
  188. package/dist/{chunk-s13m8efn.js → chunk-g86dg6h5.js} +5 -5
  189. package/dist/{chunk-h7mpryyc.js → chunk-gc4x22mt.js} +59 -56
  190. package/dist/{chunk-5s1bctjb.js → chunk-gfxebcsw.js} +28 -28
  191. package/dist/chunk-ghbtnfr2.js +117 -0
  192. package/dist/{chunk-gpk30ekc.js → chunk-gqftywrx.js} +23 -22
  193. package/dist/{chunk-z2aps7d9.js → chunk-gwrngewt.js} +3 -3
  194. package/dist/{chunk-psp1n9vg.js → chunk-gxfbedta.js} +1 -1
  195. package/dist/{chunk-fq1j9zm0.js → chunk-gybj15eh.js} +2 -3
  196. package/dist/chunk-h0vzd5vg.js +1012 -0
  197. package/dist/{chunk-0ahxmrws.js → chunk-h14dkna4.js} +23 -22
  198. package/dist/{chunk-x42kc5wj.js → chunk-h26xfh6d.js} +22 -21
  199. package/dist/{chunk-nwgkkhk7.js → chunk-h2vfn30x.js} +4 -4
  200. package/dist/{chunk-mh8752jz.js → chunk-h37gar4j.js} +1 -1
  201. package/dist/{chunk-n612gr22.js → chunk-h4k9kgjw.js} +59 -56
  202. package/dist/{chunk-1av0kkwh.js → chunk-hc1tkwfn.js} +3 -5
  203. package/dist/{chunk-h5dk6k0g.js → chunk-hf086e2e.js} +58 -55
  204. package/dist/{chunk-66j7fn6z.js → chunk-hhwqk5as.js} +58 -55
  205. package/dist/{chunk-e8zmtbry.js → chunk-hjw03d0k.js} +60 -58
  206. package/dist/{chunk-e1t8jh0t.js → chunk-hkh1vbm6.js} +58 -55
  207. package/dist/{chunk-81dq52pk.js → chunk-hnxmafvc.js} +2 -2
  208. package/dist/{chunk-cj8m3h8r.js → chunk-hqpzpr71.js} +2 -2
  209. package/dist/{chunk-s3aygngf.js → chunk-hrz2d28r.js} +62 -60
  210. package/dist/chunk-hxb3js2g.js +91 -0
  211. package/dist/{chunk-j06y02aw.js → chunk-hxc8e6wd.js} +1 -1
  212. package/dist/chunk-hyy2fcba.js +351 -0
  213. package/dist/{chunk-dvf5921w.js → chunk-hyz9tx05.js} +15 -17
  214. package/dist/{chunk-ag3hbrat.js → chunk-j34h8cfj.js} +23 -22
  215. package/dist/{chunk-b31v41mz.js → chunk-j5w0b4d2.js} +23 -22
  216. package/dist/{chunk-2tcznfv0.js → chunk-j66ragf9.js} +1 -1
  217. package/dist/chunk-j7b884wk.js +397 -0
  218. package/dist/{chunk-35xyzbd2.js → chunk-ja21qbpj.js} +65 -62
  219. package/dist/{chunk-dchgtage.js → chunk-ja3eb4h9.js} +3 -3
  220. package/dist/{chunk-2crz81z3.js → chunk-jac470kz.js} +1 -1
  221. package/dist/{chunk-9nydmbm4.js → chunk-jaqtnpbt.js} +2 -2
  222. package/dist/{chunk-e03zrq9n.js → chunk-jc5dtv57.js} +60 -58
  223. package/dist/{chunk-jg7na104.js → chunk-jda4vjad.js} +58 -55
  224. package/dist/{chunk-drnxbc1w.js → chunk-jeqt4y47.js} +2 -2
  225. package/dist/{chunk-r7r3jm3y.js → chunk-jga4j8jp.js} +59 -57
  226. package/dist/{chunk-58rg6rn2.js → chunk-jge10dbd.js} +4 -6
  227. package/dist/{chunk-9k2c5sxb.js → chunk-jhbj5mnf.js} +58 -55
  228. package/dist/{chunk-zh6xf1fd.js → chunk-jje04m6z.js} +2 -2
  229. package/dist/{chunk-qkrenskm.js → chunk-jnfd01as.js} +9 -11
  230. package/dist/chunk-jpbkdg47.js +131 -0
  231. package/dist/{chunk-xcq3rdb0.js → chunk-jwb3bqa7.js} +27 -31
  232. package/dist/{chunk-s1p2w5a5.js → chunk-jy4dnnjk.js} +5 -5
  233. package/dist/{chunk-c9p5eyxf.js → chunk-k27dq4vd.js} +60 -57
  234. package/dist/{chunk-kmcaa88h.js → chunk-k81zec2p.js} +1 -1
  235. package/dist/{chunk-fxqp3yt4.js → chunk-kb2b4rkg.js} +4 -5
  236. package/dist/{chunk-h6dqpbac.js → chunk-kbsckx2r.js} +3 -3
  237. package/dist/{chunk-451hjtv9.js → chunk-kvezjrjy.js} +58 -55
  238. package/dist/{chunk-zc1s4swn.js → chunk-kw2ymvyv.js} +6 -8
  239. package/dist/{chunk-9jg130e9.js → chunk-kymh4vxw.js} +58 -55
  240. package/dist/{chunk-z66q1nam.js → chunk-kz3q1ce0.js} +58 -55
  241. package/dist/chunk-m089kb0s.js +312 -0
  242. package/dist/{chunk-86tz7yxt.js → chunk-m1efbjqe.js} +58 -55
  243. package/dist/chunk-m1xw79dd.js +1757 -0
  244. package/dist/{chunk-k303kw9v.js → chunk-m365zhp8.js} +59 -56
  245. package/dist/{chunk-0h4sw1v3.js → chunk-m97dyxn0.js} +61 -60
  246. package/dist/{chunk-e4jqbn4d.js → chunk-m9w972ny.js} +2 -4
  247. package/dist/{chunk-eserktyd.js → chunk-mb93ek5j.js} +4 -6
  248. package/dist/{chunk-c96k89rp.js → chunk-mgjc0yj9.js} +59 -57
  249. package/dist/{chunk-qmckdcc4.js → chunk-mh2pdxpc.js} +60 -58
  250. package/dist/{chunk-hnx0eg6x.js → chunk-mkae8zj9.js} +3 -3
  251. package/dist/{chunk-h0s737p0.js → chunk-mmq55gyp.js} +4 -4
  252. package/dist/{chunk-5k4kh5n9.js → chunk-ndrn50x0.js} +59 -57
  253. package/dist/{chunk-0pxmxyxv.js → chunk-ng2xq7ey.js} +3 -3
  254. package/dist/{chunk-gdb6dvba.js → chunk-nsbpzpmf.js} +61 -59
  255. package/dist/{chunk-18mm4jf8.js → chunk-nz7sgbbr.js} +5 -5
  256. package/dist/{chunk-t0b0bas5.js → chunk-nzfwsrd7.js} +3 -3
  257. package/dist/{chunk-rhxtttx1.js → chunk-p3zbzfbn.js} +3 -3
  258. package/dist/{chunk-9tc901nb.js → chunk-p5jssxha.js} +24 -24
  259. package/dist/{chunk-zmpygkz6.js → chunk-p7es39d1.js} +47 -122
  260. package/dist/{chunk-qwj4n799.js → chunk-p7pj6wf8.js} +1 -1
  261. package/dist/{chunk-855katq2.js → chunk-p9f12fp9.js} +60 -57
  262. package/dist/chunk-pb73zgyd.js +55 -0
  263. package/dist/chunk-prpjmapz.js +117 -0
  264. package/dist/{chunk-379rspd7.js → chunk-ps01q3n9.js} +64 -63
  265. package/dist/{chunk-ay9wm3tf.js → chunk-q19p9j0v.js} +5 -5
  266. package/dist/{chunk-536fmbtq.js → chunk-q7e12ymw.js} +4 -4
  267. package/dist/{chunk-w65283w4.js → chunk-qgajfxr7.js} +7 -7
  268. package/dist/{chunk-24qcj0k5.js → chunk-qgnsf30p.js} +24 -23
  269. package/dist/{chunk-xvjdbsfa.js → chunk-qs2atqgy.js} +60 -58
  270. package/dist/chunk-r469z4mx.js +183 -0
  271. package/dist/chunk-r5mqktt5.js +100 -0
  272. package/dist/chunk-r854e43q.js +25 -0
  273. package/dist/{chunk-fx6ghdvg.js → chunk-rbgr86hh.js} +59 -57
  274. package/dist/{chunk-qxv21mcq.js → chunk-rbvawtdz.js} +59 -56
  275. package/dist/chunk-rce8gj2b.js +93 -0
  276. package/dist/{chunk-t0twk3e5.js → chunk-rd2884ff.js} +1 -1
  277. package/dist/{chunk-c2ktjyc0.js → chunk-reqz49y3.js} +336 -1149
  278. package/dist/{chunk-b4twmt0s.js → chunk-rhjb0dgd.js} +24 -23
  279. package/dist/{chunk-bpmw0wp2.js → chunk-rq1nfp7x.js} +60 -58
  280. package/dist/{chunk-qhbchv06.js → chunk-rsr0mksm.js} +61 -59
  281. package/dist/{chunk-txeekahj.js → chunk-rz3rq0gt.js} +4 -6
  282. package/dist/{chunk-14mkqwft.js → chunk-rz69sqyh.js} +70 -68
  283. package/dist/{chunk-gfk81w5r.js → chunk-s2n5kxm0.js} +5 -5
  284. package/dist/{chunk-3b9ar57s.js → chunk-s39ksgef.js} +4 -6
  285. package/dist/{chunk-3er4wswe.js → chunk-s70z817q.js} +197 -196
  286. package/dist/{chunk-5h17d17z.js → chunk-se153zng.js} +1 -1
  287. package/dist/chunk-spqq5qf1.js +116 -0
  288. package/dist/{chunk-xjd32sva.js → chunk-srnstx2s.js} +23 -22
  289. package/dist/{chunk-s9nr589x.js → chunk-sv7afh51.js} +6 -8
  290. package/dist/{chunk-b6whrv9m.js → chunk-swzfr1f5.js} +24 -23
  291. package/dist/{chunk-2h06sph0.js → chunk-t2822cex.js} +63 -60
  292. package/dist/{chunk-h93tjx98.js → chunk-t2re5hhc.js} +125 -119
  293. package/dist/{chunk-r325sbz7.js → chunk-t7e9etws.js} +23 -25
  294. package/dist/{chunk-59mg8c5k.js → chunk-tnx1zk9t.js} +62 -59
  295. package/dist/{chunk-rgpxnjx4.js → chunk-tw24rz1x.js} +11 -13
  296. package/dist/{chunk-r8m19xnp.js → chunk-v038k0we.js} +4 -6
  297. package/dist/chunk-v2qqkqxp.js +116 -0
  298. package/dist/{chunk-fjne3x6c.js → chunk-v4qke3cz.js} +8 -8
  299. package/dist/{chunk-qwa5erw8.js → chunk-v6p3019x.js} +24 -23
  300. package/dist/{chunk-4stgesb0.js → chunk-vatz6gan.js} +25 -27
  301. package/dist/chunk-vfmx405p.js +14 -0
  302. package/dist/{chunk-x639j7py.js → chunk-vnn4x6jw.js} +62 -59
  303. package/dist/{chunk-b4btw5kv.js → chunk-vpe2s4eq.js} +7 -9
  304. package/dist/{chunk-2t5ve6ev.js → chunk-vsbyhpfy.js} +1 -1
  305. package/dist/{chunk-52evx0rm.js → chunk-w0pf4mvz.js} +12 -16
  306. package/dist/chunk-w5j0dhpp.js +14 -0
  307. package/dist/{chunk-vqawqpkx.js → chunk-w7zp9j8v.js} +72 -70
  308. package/dist/{chunk-d2vb6m9e.js → chunk-wd8mqz95.js} +3 -5
  309. package/dist/chunk-wj0c0zfa.js +36 -0
  310. package/dist/{chunk-ps5rsyxe.js → chunk-wqdr8v9x.js} +58 -55
  311. package/dist/{chunk-vpp13z80.js → chunk-wxa2hdfg.js} +2 -2
  312. package/dist/{chunk-kh04yrpx.js → chunk-wy3f5b81.js} +59 -56
  313. package/dist/{chunk-5dn1m1r7.js → chunk-x0ym1db4.js} +2 -4
  314. package/dist/{chunk-d73t8nhj.js → chunk-x1t80e36.js} +39 -39
  315. package/dist/{chunk-08a6n2pp.js → chunk-x63c39tp.js} +5 -7
  316. package/dist/{chunk-q890kpff.js → chunk-x6622cb2.js} +23 -22
  317. package/dist/{chunk-wcxc5m91.js → chunk-x95fhbwq.js} +1 -1
  318. package/dist/{chunk-px27vhxx.js → chunk-x9gbnheg.js} +8 -10
  319. package/dist/{chunk-9gypgvd7.js → chunk-xahpt5e2.js} +3 -5
  320. package/dist/{chunk-y3rg86fk.js → chunk-xct1m4sf.js} +23 -22
  321. package/dist/chunk-xee276gg.js +367 -0
  322. package/dist/{chunk-n8whv674.js → chunk-xfkf8q6w.js} +5 -6
  323. package/dist/chunk-xhesahm0.js +15 -0
  324. package/dist/{chunk-tbma29g4.js → chunk-xk1wdwxq.js} +60 -57
  325. package/dist/{chunk-gwah3f17.js → chunk-xpj4qca4.js} +58 -55
  326. package/dist/{chunk-h6wkvzrd.js → chunk-xqk8srdh.js} +6 -8
  327. package/dist/{chunk-39zy97qa.js → chunk-xsc3ccj0.js} +3 -3
  328. package/dist/{chunk-y82s03p7.js → chunk-xwc8e4yv.js} +2 -2
  329. package/dist/{chunk-8wv29424.js → chunk-xxmxv448.js} +8 -9
  330. package/dist/{chunk-symd8dvh.js → chunk-xz7cf7fa.js} +69 -66
  331. package/dist/{chunk-h7bkf3h2.js → chunk-y3qdyf8r.js} +28 -27
  332. package/dist/{chunk-j5eb93j4.js → chunk-y48wfwm4.js} +1 -517
  333. package/dist/{chunk-6qexrv9a.js → chunk-y7vzcjyn.js} +60 -58
  334. package/dist/chunk-yb03gvd8.js +271 -0
  335. package/dist/chunk-yem3ge7z.js +182 -0
  336. package/dist/{chunk-vmpcmvqq.js → chunk-yf5qwpnp.js} +3 -3
  337. package/dist/{chunk-awwfrm4f.js → chunk-yrnbgtk0.js} +26 -25
  338. package/dist/{chunk-64mwy58c.js → chunk-yrs92qya.js} +5 -7
  339. package/dist/{chunk-y29pdynp.js → chunk-ys6cza46.js} +7 -9
  340. package/dist/{chunk-kcp8svja.js → chunk-yvgmpc5z.js} +5 -5
  341. package/dist/{chunk-3avnvgnv.js → chunk-yxr0yf6h.js} +4 -4
  342. package/dist/{chunk-ar8awa36.js → chunk-yyc1yvnr.js} +59 -57
  343. package/dist/{chunk-kmzv85ze.js → chunk-z0vk43bt.js} +69 -66
  344. package/dist/chunk-z1seyvya.js +110 -0
  345. package/dist/{chunk-2pdcq92c.js → chunk-z6hqga26.js} +3 -4
  346. package/dist/{chunk-5ccpwbk7.js → chunk-z7hv619f.js} +58 -55
  347. package/dist/{chunk-1ez8vf1y.js → chunk-zb0mctxm.js} +6 -6
  348. package/dist/{chunk-49n22kr8.js → chunk-zhyc7npp.js} +58 -55
  349. package/dist/{chunk-9r28w6ye.js → chunk-zttmdag3.js} +1 -1
  350. package/dist/{chunk-p1af059d.js → chunk-zvegtrc4.js} +63 -60
  351. package/dist/{chunk-n2gc23dm.js → chunk-zwsrj2yy.js} +9 -11
  352. package/dist/cli.js +58 -22
  353. package/package.json +12 -4
  354. package/dist/chunk-0731m51q.js +0 -8
  355. package/dist/chunk-2fwze72g.js +0 -24
  356. package/dist/chunk-3ev51j3h.js +0 -117
  357. package/dist/chunk-5cc50ecq.js +0 -116
  358. package/dist/chunk-74v2mh4t.js +0 -40
  359. package/dist/chunk-9b0btjar.js +0 -114
  360. package/dist/chunk-bhvmpf9m.js +0 -113
  361. package/dist/chunk-bzps3qec.js +0 -113
  362. package/dist/chunk-e6nenv5n.js +0 -112
  363. package/dist/chunk-ez958w7j.js +0 -110
  364. package/dist/chunk-fve53rbk.js +0 -22
  365. package/dist/chunk-g5rf37hh.js +0 -116
  366. package/dist/chunk-ga2vcmhy.js +0 -111
  367. package/dist/chunk-k5c76pvm.js +0 -114
  368. package/dist/chunk-npf5eh3g.js +0 -8
  369. package/dist/chunk-ppwjyveh.js +0 -8
  370. package/dist/chunk-t38536jf.js +0 -254
  371. package/dist/chunk-tf8gr3bs.js +0 -112
  372. package/dist/chunk-vam5at9t.js +0 -175
  373. package/dist/chunk-vxnvzfnv.js +0 -233
  374. package/dist/chunk-wef34bk5.js +0 -107
  375. package/dist/chunk-wkjjv1jr.js +0 -1026
  376. package/dist/chunk-wkx2xsed.js +0 -113
  377. package/dist/chunk-x6r4v44b.js +0 -8
  378. package/dist/chunk-xwhmcc3g.js +0 -109
@@ -0,0 +1,1757 @@
1
+ // @bun
2
+ import {
3
+ CCR_SESSION_INGRESS_TOKEN_PATH,
4
+ init_authFileDescriptor,
5
+ maybePersistTokenForSubprocesses,
6
+ readTokenFromWellKnownFile
7
+ } from "./chunk-p7es39d1.js";
8
+ import {
9
+ init_diagLogs,
10
+ logForDiagnosticsNoPII
11
+ } from "./chunk-9awawyvh.js";
12
+ import {
13
+ errorMessage,
14
+ getFsImplementation,
15
+ init_cleanupRegistry,
16
+ init_debug,
17
+ init_errors,
18
+ init_fsOperations,
19
+ logForDebugging,
20
+ registerCleanup
21
+ } from "./chunk-5khwvj1z.js";
22
+ import {
23
+ getSessionIngressToken,
24
+ init_state,
25
+ setSessionIngressToken
26
+ } from "./chunk-gzp6rza1.js";
27
+ import {
28
+ init_envUtils,
29
+ isEnvTruthy
30
+ } from "./chunk-hxhwzgnn.js";
31
+ import {
32
+ __esm
33
+ } from "./chunk-qp2qdcda.js";
34
+
35
+ // packages/@ant/model-provider/src/types/usage.ts
36
+ var EMPTY_USAGE;
37
+ var init_usage = __esm(() => {
38
+ EMPTY_USAGE = {
39
+ input_tokens: 0,
40
+ cache_creation_input_tokens: 0,
41
+ cache_read_input_tokens: 0,
42
+ output_tokens: 0,
43
+ server_tool_use: { web_search_requests: 0, web_fetch_requests: 0 },
44
+ service_tier: "standard",
45
+ cache_creation: {
46
+ ephemeral_1h_input_tokens: 0,
47
+ ephemeral_5m_input_tokens: 0
48
+ },
49
+ inference_geo: "",
50
+ iterations: [],
51
+ speed: "standard"
52
+ };
53
+ });
54
+
55
+ // packages/@ant/model-provider/src/types/systemPrompt.ts
56
+ function asSystemPrompt(value) {
57
+ return value;
58
+ }
59
+ var init_systemPrompt = () => {};
60
+
61
+ // packages/@ant/model-provider/src/providers/openai/modelMapping.ts
62
+ function getModelFamily(model) {
63
+ if (/haiku/i.test(model))
64
+ return "haiku";
65
+ if (/opus/i.test(model))
66
+ return "opus";
67
+ if (/sonnet/i.test(model))
68
+ return "sonnet";
69
+ return null;
70
+ }
71
+ function resolveOpenAIModel(anthropicModel) {
72
+ if (process.env.OPENAI_MODEL) {
73
+ return process.env.OPENAI_MODEL;
74
+ }
75
+ const cleanModel = anthropicModel.replace(/\[1m\]$/, "");
76
+ const family = getModelFamily(cleanModel);
77
+ if (family) {
78
+ const openaiEnvVar = `OPENAI_DEFAULT_${family.toUpperCase()}_MODEL`;
79
+ const openaiOverride = process.env[openaiEnvVar];
80
+ if (openaiOverride)
81
+ return openaiOverride;
82
+ const anthropicEnvVar = `ANTHROPIC_DEFAULT_${family.toUpperCase()}_MODEL`;
83
+ const anthropicOverride = process.env[anthropicEnvVar];
84
+ if (anthropicOverride)
85
+ return anthropicOverride;
86
+ }
87
+ return DEFAULT_MODEL_MAP[cleanModel] ?? cleanModel;
88
+ }
89
+ var DEFAULT_MODEL_MAP;
90
+ var init_modelMapping = __esm(() => {
91
+ DEFAULT_MODEL_MAP = {
92
+ "claude-sonnet-4-20250514": "gpt-4o",
93
+ "claude-sonnet-4-5-20250929": "gpt-4o",
94
+ "claude-sonnet-4-6": "gpt-4o",
95
+ "claude-opus-4-20250514": "o3",
96
+ "claude-opus-4-1-20250805": "o3",
97
+ "claude-opus-4-5-20251101": "o3",
98
+ "claude-opus-4-6": "o3",
99
+ "claude-haiku-4-5-20251001": "gpt-4o-mini",
100
+ "claude-3-5-haiku-20241022": "gpt-4o-mini",
101
+ "claude-3-7-sonnet-20250219": "gpt-4o",
102
+ "claude-3-5-sonnet-20241022": "gpt-4o"
103
+ };
104
+ });
105
+
106
+ // packages/@ant/model-provider/src/providers/grok/modelMapping.ts
107
+ function getModelFamily2(model) {
108
+ if (/haiku/i.test(model))
109
+ return "haiku";
110
+ if (/opus/i.test(model))
111
+ return "opus";
112
+ if (/sonnet/i.test(model))
113
+ return "sonnet";
114
+ return null;
115
+ }
116
+ function getUserModelMap() {
117
+ const raw = process.env.GROK_MODEL_MAP;
118
+ if (!raw)
119
+ return null;
120
+ try {
121
+ const parsed = JSON.parse(raw);
122
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
123
+ return parsed;
124
+ }
125
+ } catch {}
126
+ return null;
127
+ }
128
+ function resolveGrokModel(anthropicModel) {
129
+ if (process.env.GROK_MODEL) {
130
+ return process.env.GROK_MODEL;
131
+ }
132
+ const cleanModel = anthropicModel.replace(/\[1m\]$/, "");
133
+ const family = getModelFamily2(cleanModel);
134
+ const userMap = getUserModelMap();
135
+ if (userMap && family && userMap[family]) {
136
+ return userMap[family];
137
+ }
138
+ if (family) {
139
+ const grokEnvVar = `GROK_DEFAULT_${family.toUpperCase()}_MODEL`;
140
+ const grokOverride = process.env[grokEnvVar];
141
+ if (grokOverride)
142
+ return grokOverride;
143
+ const anthropicEnvVar = `ANTHROPIC_DEFAULT_${family.toUpperCase()}_MODEL`;
144
+ const anthropicOverride = process.env[anthropicEnvVar];
145
+ if (anthropicOverride)
146
+ return anthropicOverride;
147
+ }
148
+ if (DEFAULT_MODEL_MAP2[cleanModel]) {
149
+ return DEFAULT_MODEL_MAP2[cleanModel];
150
+ }
151
+ if (family && DEFAULT_FAMILY_MAP[family]) {
152
+ return DEFAULT_FAMILY_MAP[family];
153
+ }
154
+ return cleanModel;
155
+ }
156
+ var DEFAULT_MODEL_MAP2, DEFAULT_FAMILY_MAP;
157
+ var init_modelMapping2 = __esm(() => {
158
+ DEFAULT_MODEL_MAP2 = {
159
+ "claude-sonnet-4-20250514": "grok-3-mini-fast",
160
+ "claude-sonnet-4-5-20250929": "grok-3-mini-fast",
161
+ "claude-sonnet-4-6": "grok-3-mini-fast",
162
+ "claude-opus-4-20250514": "grok-4.20-reasoning",
163
+ "claude-opus-4-1-20250805": "grok-4.20-reasoning",
164
+ "claude-opus-4-5-20251101": "grok-4.20-reasoning",
165
+ "claude-opus-4-6": "grok-4.20-reasoning",
166
+ "claude-haiku-4-5-20251001": "grok-3-mini-fast",
167
+ "claude-3-5-haiku-20241022": "grok-3-mini-fast",
168
+ "claude-3-7-sonnet-20250219": "grok-3-mini-fast",
169
+ "claude-3-5-sonnet-20241022": "grok-3-mini-fast"
170
+ };
171
+ DEFAULT_FAMILY_MAP = {
172
+ opus: "grok-4.20-reasoning",
173
+ sonnet: "grok-3-mini-fast",
174
+ haiku: "grok-3-mini-fast"
175
+ };
176
+ });
177
+
178
+ // packages/@ant/model-provider/src/providers/gemini/modelMapping.ts
179
+ function getModelFamily3(model) {
180
+ if (/haiku/i.test(model))
181
+ return "haiku";
182
+ if (/opus/i.test(model))
183
+ return "opus";
184
+ if (/sonnet/i.test(model))
185
+ return "sonnet";
186
+ return null;
187
+ }
188
+ function resolveGeminiModel(anthropicModel) {
189
+ if (process.env.GEMINI_MODEL) {
190
+ return process.env.GEMINI_MODEL;
191
+ }
192
+ const cleanModel = anthropicModel.replace(/\[1m\]$/i, "");
193
+ const family = getModelFamily3(cleanModel);
194
+ if (!family) {
195
+ return cleanModel;
196
+ }
197
+ const geminiEnvVar = `GEMINI_DEFAULT_${family.toUpperCase()}_MODEL`;
198
+ const geminiModel = process.env[geminiEnvVar];
199
+ if (geminiModel) {
200
+ return geminiModel;
201
+ }
202
+ const sharedEnvVar = `ANTHROPIC_DEFAULT_${family.toUpperCase()}_MODEL`;
203
+ const resolvedModel = process.env[sharedEnvVar];
204
+ if (resolvedModel) {
205
+ return resolvedModel;
206
+ }
207
+ throw new Error(`Gemini provider requires GEMINI_MODEL or ${geminiEnvVar} (or ${sharedEnvVar} for backward compatibility) to be configured.`);
208
+ }
209
+ var init_modelMapping3 = () => {};
210
+
211
+ // packages/@ant/model-provider/src/providers/gemini/types.ts
212
+ var GEMINI_THOUGHT_SIGNATURE_FIELD = "_geminiThoughtSignature";
213
+ var init_types = () => {};
214
+
215
+ // packages/@ant/model-provider/src/providers/gemini/convertMessages.ts
216
+ function safeParseJSON(json) {
217
+ if (!json)
218
+ return null;
219
+ try {
220
+ return JSON.parse(json);
221
+ } catch {
222
+ return null;
223
+ }
224
+ }
225
+ function anthropicMessagesToGemini(messages, systemPrompt) {
226
+ const contents = [];
227
+ const toolNamesById = new Map;
228
+ for (const msg of messages) {
229
+ if (msg.type === "assistant") {
230
+ const content = convertInternalAssistantMessage(msg);
231
+ if (content.parts.length > 0) {
232
+ contents.push(content);
233
+ }
234
+ const assistantContent = msg.message.content;
235
+ if (Array.isArray(assistantContent)) {
236
+ for (const block of assistantContent) {
237
+ if (typeof block !== "string" && block.type === "tool_use") {
238
+ toolNamesById.set(block.id, block.name);
239
+ }
240
+ }
241
+ }
242
+ continue;
243
+ }
244
+ if (msg.type === "user") {
245
+ const content = convertInternalUserMessage(msg, toolNamesById);
246
+ if (content.parts.length > 0) {
247
+ contents.push(content);
248
+ }
249
+ }
250
+ }
251
+ const systemText = systemPromptToText(systemPrompt);
252
+ return {
253
+ contents,
254
+ ...systemText ? {
255
+ systemInstruction: {
256
+ parts: [{ text: systemText }]
257
+ }
258
+ } : {}
259
+ };
260
+ }
261
+ function systemPromptToText(systemPrompt) {
262
+ if (!systemPrompt || systemPrompt.length === 0)
263
+ return "";
264
+ return systemPrompt.filter(Boolean).join(`
265
+
266
+ `);
267
+ }
268
+ function convertInternalUserMessage(msg, toolNamesById) {
269
+ const content = msg.message.content;
270
+ if (typeof content === "string") {
271
+ return {
272
+ role: "user",
273
+ parts: createTextGeminiParts(content)
274
+ };
275
+ }
276
+ if (!Array.isArray(content)) {
277
+ return { role: "user", parts: [] };
278
+ }
279
+ return {
280
+ role: "user",
281
+ parts: content.flatMap((block) => convertUserContentBlockToGeminiParts(block, toolNamesById))
282
+ };
283
+ }
284
+ function convertUserContentBlockToGeminiParts(block, toolNamesById) {
285
+ if (typeof block === "string") {
286
+ return createTextGeminiParts(block);
287
+ }
288
+ if (block.type === "text") {
289
+ return createTextGeminiParts(block.text);
290
+ }
291
+ if (block.type === "tool_result") {
292
+ const toolResult = block;
293
+ return [
294
+ {
295
+ functionResponse: {
296
+ name: toolNamesById.get(toolResult.tool_use_id) ?? toolResult.tool_use_id,
297
+ response: toolResultToResponseObject(toolResult)
298
+ }
299
+ }
300
+ ];
301
+ }
302
+ if (block.type === "image") {
303
+ const source = block.source;
304
+ if (source?.type === "base64" && typeof source.data === "string") {
305
+ const mediaType = source.media_type || "image/png";
306
+ return [
307
+ {
308
+ inlineData: {
309
+ mimeType: mediaType,
310
+ data: source.data
311
+ }
312
+ }
313
+ ];
314
+ }
315
+ if (source?.type === "url" && typeof source.url === "string") {
316
+ return createTextGeminiParts(`[image: ${source.url}]`);
317
+ }
318
+ }
319
+ return [];
320
+ }
321
+ function convertInternalAssistantMessage(msg) {
322
+ const content = msg.message.content;
323
+ if (typeof content === "string") {
324
+ return {
325
+ role: "model",
326
+ parts: createTextGeminiParts(content)
327
+ };
328
+ }
329
+ if (!Array.isArray(content)) {
330
+ return { role: "model", parts: [] };
331
+ }
332
+ const parts = [];
333
+ for (const block of content) {
334
+ if (typeof block === "string") {
335
+ parts.push(...createTextGeminiParts(block));
336
+ continue;
337
+ }
338
+ if (block.type === "text") {
339
+ parts.push(...createTextGeminiParts(block.text, getGeminiThoughtSignature(block)));
340
+ continue;
341
+ }
342
+ if (block.type === "thinking") {
343
+ const thinkingPart = createThinkingGeminiPart(block.thinking, block.signature);
344
+ if (thinkingPart) {
345
+ parts.push(thinkingPart);
346
+ }
347
+ continue;
348
+ }
349
+ if (block.type === "tool_use") {
350
+ const toolUse = block;
351
+ parts.push({
352
+ functionCall: {
353
+ name: toolUse.name,
354
+ args: normalizeToolUseInput(toolUse.input)
355
+ },
356
+ ...getGeminiThoughtSignature(block) && {
357
+ thoughtSignature: getGeminiThoughtSignature(block)
358
+ }
359
+ });
360
+ }
361
+ }
362
+ return { role: "model", parts };
363
+ }
364
+ function createTextGeminiParts(value, thoughtSignature) {
365
+ if (typeof value !== "string" || value.length === 0) {
366
+ return [];
367
+ }
368
+ return [
369
+ {
370
+ text: value,
371
+ ...thoughtSignature && { thoughtSignature }
372
+ }
373
+ ];
374
+ }
375
+ function createThinkingGeminiPart(value, thoughtSignature) {
376
+ if (typeof value !== "string" || value.length === 0) {
377
+ return;
378
+ }
379
+ return {
380
+ text: value,
381
+ thought: true,
382
+ ...thoughtSignature && { thoughtSignature }
383
+ };
384
+ }
385
+ function normalizeToolUseInput(input) {
386
+ if (typeof input === "string") {
387
+ const parsed = safeParseJSON(input);
388
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
389
+ return parsed;
390
+ }
391
+ return parsed === null ? {} : { value: parsed };
392
+ }
393
+ if (input && typeof input === "object" && !Array.isArray(input)) {
394
+ return input;
395
+ }
396
+ return input === undefined ? {} : { value: input };
397
+ }
398
+ function toolResultToResponseObject(block) {
399
+ const result = normalizeToolResultContent(block.content);
400
+ if (result && typeof result === "object" && !Array.isArray(result)) {
401
+ return block.is_error ? { ...result, is_error: true } : result;
402
+ }
403
+ return {
404
+ result,
405
+ ...block.is_error ? { is_error: true } : {}
406
+ };
407
+ }
408
+ function normalizeToolResultContent(content) {
409
+ if (typeof content === "string") {
410
+ const parsed = safeParseJSON(content);
411
+ return parsed ?? content;
412
+ }
413
+ if (Array.isArray(content)) {
414
+ const text = content.map((part) => {
415
+ if (typeof part === "string")
416
+ return part;
417
+ if (part && typeof part === "object" && "text" in part && typeof part.text === "string") {
418
+ return part.text;
419
+ }
420
+ return "";
421
+ }).filter(Boolean).join(`
422
+ `);
423
+ const parsed = safeParseJSON(text);
424
+ return parsed ?? text;
425
+ }
426
+ return content ?? "";
427
+ }
428
+ function getGeminiThoughtSignature(block) {
429
+ const signature = block[GEMINI_THOUGHT_SIGNATURE_FIELD];
430
+ return typeof signature === "string" && signature.length > 0 ? signature : undefined;
431
+ }
432
+ var init_convertMessages = __esm(() => {
433
+ init_types();
434
+ });
435
+
436
+ // packages/@ant/model-provider/src/providers/gemini/convertTools.ts
437
+ function normalizeGeminiJsonSchemaType(value) {
438
+ if (typeof value === "string") {
439
+ return GEMINI_JSON_SCHEMA_TYPES.has(value) ? value : undefined;
440
+ }
441
+ if (Array.isArray(value)) {
442
+ const normalized = value.filter((item) => typeof item === "string" && GEMINI_JSON_SCHEMA_TYPES.has(item));
443
+ const unique = Array.from(new Set(normalized));
444
+ if (unique.length === 0)
445
+ return;
446
+ return unique.length === 1 ? unique[0] : unique;
447
+ }
448
+ return;
449
+ }
450
+ function inferGeminiJsonSchemaTypeFromValue(value) {
451
+ if (value === null)
452
+ return "null";
453
+ if (Array.isArray(value))
454
+ return "array";
455
+ if (typeof value === "string")
456
+ return "string";
457
+ if (typeof value === "boolean")
458
+ return "boolean";
459
+ if (typeof value === "number") {
460
+ return Number.isInteger(value) ? "integer" : "number";
461
+ }
462
+ if (typeof value === "object")
463
+ return "object";
464
+ return;
465
+ }
466
+ function inferGeminiJsonSchemaTypeFromEnum(values) {
467
+ const inferred = values.map(inferGeminiJsonSchemaTypeFromValue).filter((value) => value !== undefined);
468
+ const unique = Array.from(new Set(inferred));
469
+ if (unique.length === 0)
470
+ return;
471
+ return unique.length === 1 ? unique[0] : unique;
472
+ }
473
+ function addNullToGeminiJsonSchemaType(value) {
474
+ if (value === undefined)
475
+ return ["null"];
476
+ if (Array.isArray(value)) {
477
+ return value.includes("null") ? value : [...value, "null"];
478
+ }
479
+ return value === "null" ? value : [value, "null"];
480
+ }
481
+ function sanitizeGeminiJsonSchemaProperties(value) {
482
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
483
+ return;
484
+ }
485
+ const sanitizedEntries = Object.entries(value).map(([key, schema]) => [key, sanitizeGeminiJsonSchema(schema)]).filter(([, schema]) => Object.keys(schema).length > 0);
486
+ if (sanitizedEntries.length === 0) {
487
+ return;
488
+ }
489
+ return Object.fromEntries(sanitizedEntries);
490
+ }
491
+ function sanitizeGeminiJsonSchemaArray(value) {
492
+ if (!Array.isArray(value))
493
+ return;
494
+ const sanitized = value.map((item) => sanitizeGeminiJsonSchema(item)).filter((item) => Object.keys(item).length > 0);
495
+ return sanitized.length > 0 ? sanitized : undefined;
496
+ }
497
+ function sanitizeGeminiJsonSchema(schema) {
498
+ if (!schema || typeof schema !== "object" || Array.isArray(schema)) {
499
+ return {};
500
+ }
501
+ const source = schema;
502
+ const result = {};
503
+ let type = normalizeGeminiJsonSchemaType(source.type);
504
+ if (source.const !== undefined) {
505
+ result.enum = [source.const];
506
+ type = type ?? inferGeminiJsonSchemaTypeFromValue(source.const);
507
+ } else if (Array.isArray(source.enum) && source.enum.length > 0) {
508
+ result.enum = source.enum;
509
+ type = type ?? inferGeminiJsonSchemaTypeFromEnum(source.enum);
510
+ }
511
+ if (!type) {
512
+ if (source.properties && typeof source.properties === "object") {
513
+ type = "object";
514
+ } else if (source.items !== undefined || source.prefixItems !== undefined) {
515
+ type = "array";
516
+ }
517
+ }
518
+ if (source.nullable === true) {
519
+ type = addNullToGeminiJsonSchemaType(type);
520
+ }
521
+ if (type) {
522
+ result.type = type;
523
+ }
524
+ if (typeof source.title === "string") {
525
+ result.title = source.title;
526
+ }
527
+ if (typeof source.description === "string") {
528
+ result.description = source.description;
529
+ }
530
+ if (typeof source.format === "string") {
531
+ result.format = source.format;
532
+ }
533
+ if (typeof source.pattern === "string") {
534
+ result.pattern = source.pattern;
535
+ }
536
+ if (typeof source.minimum === "number") {
537
+ result.minimum = source.minimum;
538
+ } else if (typeof source.exclusiveMinimum === "number") {
539
+ result.minimum = source.exclusiveMinimum;
540
+ }
541
+ if (typeof source.maximum === "number") {
542
+ result.maximum = source.maximum;
543
+ } else if (typeof source.exclusiveMaximum === "number") {
544
+ result.maximum = source.exclusiveMaximum;
545
+ }
546
+ if (typeof source.minItems === "number") {
547
+ result.minItems = source.minItems;
548
+ }
549
+ if (typeof source.maxItems === "number") {
550
+ result.maxItems = source.maxItems;
551
+ }
552
+ if (typeof source.minLength === "number") {
553
+ result.minLength = source.minLength;
554
+ }
555
+ if (typeof source.maxLength === "number") {
556
+ result.maxLength = source.maxLength;
557
+ }
558
+ if (typeof source.minProperties === "number") {
559
+ result.minProperties = source.minProperties;
560
+ }
561
+ if (typeof source.maxProperties === "number") {
562
+ result.maxProperties = source.maxProperties;
563
+ }
564
+ const properties = sanitizeGeminiJsonSchemaProperties(source.properties);
565
+ if (properties) {
566
+ result.properties = properties;
567
+ result.propertyOrdering = Object.keys(properties);
568
+ }
569
+ if (Array.isArray(source.required)) {
570
+ const required = source.required.filter((item) => typeof item === "string");
571
+ if (required.length > 0) {
572
+ result.required = required;
573
+ }
574
+ }
575
+ if (typeof source.additionalProperties === "boolean") {
576
+ result.additionalProperties = source.additionalProperties;
577
+ } else {
578
+ const additionalProperties = sanitizeGeminiJsonSchema(source.additionalProperties);
579
+ if (Object.keys(additionalProperties).length > 0) {
580
+ result.additionalProperties = additionalProperties;
581
+ }
582
+ }
583
+ const items = sanitizeGeminiJsonSchema(source.items);
584
+ if (Object.keys(items).length > 0) {
585
+ result.items = items;
586
+ }
587
+ const prefixItems = sanitizeGeminiJsonSchemaArray(source.prefixItems);
588
+ if (prefixItems) {
589
+ result.prefixItems = prefixItems;
590
+ }
591
+ const anyOf = sanitizeGeminiJsonSchemaArray(source.anyOf ?? source.oneOf);
592
+ if (anyOf) {
593
+ result.anyOf = anyOf;
594
+ }
595
+ return result;
596
+ }
597
+ function sanitizeGeminiFunctionParameters(schema) {
598
+ const sanitized = sanitizeGeminiJsonSchema(schema);
599
+ if (Object.keys(sanitized).length > 0) {
600
+ return sanitized;
601
+ }
602
+ return {
603
+ type: "object",
604
+ properties: {}
605
+ };
606
+ }
607
+ function anthropicToolsToGemini(tools) {
608
+ const functionDeclarations = tools.filter((tool) => {
609
+ const toolType = tool.type;
610
+ return tool.type === "custom" || !("type" in tool) || toolType !== "server";
611
+ }).map((tool) => {
612
+ const anyTool = tool;
613
+ const name = anyTool.name || "";
614
+ const description = anyTool.description || "";
615
+ const inputSchema = anyTool.input_schema ?? {
616
+ type: "object",
617
+ properties: {}
618
+ };
619
+ return {
620
+ name,
621
+ description,
622
+ parametersJsonSchema: sanitizeGeminiFunctionParameters(inputSchema)
623
+ };
624
+ });
625
+ return functionDeclarations.length > 0 ? [{ functionDeclarations }] : [];
626
+ }
627
+ function anthropicToolChoiceToGemini(toolChoice) {
628
+ if (!toolChoice || typeof toolChoice !== "object")
629
+ return;
630
+ const tc = toolChoice;
631
+ const type = tc.type;
632
+ switch (type) {
633
+ case "auto":
634
+ return { mode: "AUTO" };
635
+ case "any":
636
+ return { mode: "ANY" };
637
+ case "tool":
638
+ return {
639
+ mode: "ANY",
640
+ allowedFunctionNames: typeof tc.name === "string" ? [tc.name] : undefined
641
+ };
642
+ default:
643
+ return;
644
+ }
645
+ }
646
+ var GEMINI_JSON_SCHEMA_TYPES;
647
+ var init_convertTools = __esm(() => {
648
+ GEMINI_JSON_SCHEMA_TYPES = new Set([
649
+ "string",
650
+ "number",
651
+ "integer",
652
+ "boolean",
653
+ "object",
654
+ "array",
655
+ "null"
656
+ ]);
657
+ });
658
+
659
+ // packages/@ant/model-provider/src/providers/gemini/streamAdapter.ts
660
+ import { randomUUID } from "crypto";
661
+ async function* adaptGeminiStreamToAnthropic(stream, model) {
662
+ const messageId = `msg_${randomUUID().replace(/-/g, "").slice(0, 24)}`;
663
+ let started = false;
664
+ let stopped = false;
665
+ let nextContentIndex = 0;
666
+ let openTextLikeBlock = null;
667
+ let sawToolUse = false;
668
+ let finishReason;
669
+ let inputTokens = 0;
670
+ let outputTokens = 0;
671
+ for await (const chunk of stream) {
672
+ const usage = chunk.usageMetadata;
673
+ if (usage) {
674
+ inputTokens = usage.promptTokenCount ?? inputTokens;
675
+ outputTokens = (usage.candidatesTokenCount ?? 0) + (usage.thoughtsTokenCount ?? 0);
676
+ }
677
+ if (!started) {
678
+ started = true;
679
+ yield {
680
+ type: "message_start",
681
+ message: {
682
+ id: messageId,
683
+ type: "message",
684
+ role: "assistant",
685
+ content: [],
686
+ model,
687
+ stop_reason: null,
688
+ stop_sequence: null,
689
+ usage: {
690
+ input_tokens: inputTokens,
691
+ output_tokens: 0,
692
+ cache_creation_input_tokens: 0,
693
+ cache_read_input_tokens: 0
694
+ }
695
+ }
696
+ };
697
+ }
698
+ const candidate = chunk.candidates?.[0];
699
+ const parts = candidate?.content?.parts ?? [];
700
+ for (const part of parts) {
701
+ if (part.functionCall) {
702
+ if (openTextLikeBlock) {
703
+ yield {
704
+ type: "content_block_stop",
705
+ index: openTextLikeBlock.index
706
+ };
707
+ openTextLikeBlock = null;
708
+ }
709
+ sawToolUse = true;
710
+ const toolIndex = nextContentIndex++;
711
+ const toolId = `toolu_${randomUUID().replace(/-/g, "").slice(0, 24)}`;
712
+ yield {
713
+ type: "content_block_start",
714
+ index: toolIndex,
715
+ content_block: {
716
+ type: "tool_use",
717
+ id: toolId,
718
+ name: part.functionCall.name || "",
719
+ input: {}
720
+ }
721
+ };
722
+ if (part.thoughtSignature) {
723
+ yield {
724
+ type: "content_block_delta",
725
+ index: toolIndex,
726
+ delta: {
727
+ type: "signature_delta",
728
+ signature: part.thoughtSignature
729
+ }
730
+ };
731
+ }
732
+ if (part.functionCall.args && Object.keys(part.functionCall.args).length > 0) {
733
+ yield {
734
+ type: "content_block_delta",
735
+ index: toolIndex,
736
+ delta: {
737
+ type: "input_json_delta",
738
+ partial_json: JSON.stringify(part.functionCall.args)
739
+ }
740
+ };
741
+ }
742
+ yield {
743
+ type: "content_block_stop",
744
+ index: toolIndex
745
+ };
746
+ continue;
747
+ }
748
+ const textLikeType = getTextLikeBlockType(part);
749
+ if (textLikeType) {
750
+ if (!openTextLikeBlock || openTextLikeBlock.type !== textLikeType) {
751
+ if (openTextLikeBlock) {
752
+ yield {
753
+ type: "content_block_stop",
754
+ index: openTextLikeBlock.index
755
+ };
756
+ }
757
+ openTextLikeBlock = {
758
+ index: nextContentIndex++,
759
+ type: textLikeType
760
+ };
761
+ yield {
762
+ type: "content_block_start",
763
+ index: openTextLikeBlock.index,
764
+ content_block: textLikeType === "thinking" ? {
765
+ type: "thinking",
766
+ thinking: "",
767
+ signature: ""
768
+ } : {
769
+ type: "text",
770
+ text: ""
771
+ }
772
+ };
773
+ }
774
+ if (part.text) {
775
+ yield {
776
+ type: "content_block_delta",
777
+ index: openTextLikeBlock.index,
778
+ delta: textLikeType === "thinking" ? {
779
+ type: "thinking_delta",
780
+ thinking: part.text
781
+ } : {
782
+ type: "text_delta",
783
+ text: part.text
784
+ }
785
+ };
786
+ }
787
+ if (part.thoughtSignature) {
788
+ yield {
789
+ type: "content_block_delta",
790
+ index: openTextLikeBlock.index,
791
+ delta: {
792
+ type: "signature_delta",
793
+ signature: part.thoughtSignature
794
+ }
795
+ };
796
+ }
797
+ continue;
798
+ }
799
+ if (part.thoughtSignature && openTextLikeBlock) {
800
+ yield {
801
+ type: "content_block_delta",
802
+ index: openTextLikeBlock.index,
803
+ delta: {
804
+ type: "signature_delta",
805
+ signature: part.thoughtSignature
806
+ }
807
+ };
808
+ }
809
+ }
810
+ if (candidate?.finishReason) {
811
+ finishReason = candidate.finishReason;
812
+ }
813
+ }
814
+ if (!started) {
815
+ return;
816
+ }
817
+ if (openTextLikeBlock) {
818
+ yield {
819
+ type: "content_block_stop",
820
+ index: openTextLikeBlock.index
821
+ };
822
+ }
823
+ if (!stopped) {
824
+ yield {
825
+ type: "message_delta",
826
+ delta: {
827
+ stop_reason: mapGeminiFinishReason(finishReason, sawToolUse),
828
+ stop_sequence: null
829
+ },
830
+ usage: {
831
+ output_tokens: outputTokens
832
+ }
833
+ };
834
+ yield {
835
+ type: "message_stop"
836
+ };
837
+ stopped = true;
838
+ }
839
+ }
840
+ function getTextLikeBlockType(part) {
841
+ if (typeof part.text !== "string") {
842
+ return null;
843
+ }
844
+ return part.thought ? "thinking" : "text";
845
+ }
846
+ function mapGeminiFinishReason(reason, sawToolUse) {
847
+ switch (reason) {
848
+ case "MAX_TOKENS":
849
+ return "max_tokens";
850
+ case "STOP":
851
+ case "FINISH_REASON_UNSPECIFIED":
852
+ case "SAFETY":
853
+ case "RECITATION":
854
+ case "BLOCKLIST":
855
+ case "PROHIBITED_CONTENT":
856
+ case "SPII":
857
+ case "MALFORMED_FUNCTION_CALL":
858
+ default:
859
+ return sawToolUse ? "tool_use" : "end_turn";
860
+ }
861
+ }
862
+ var init_streamAdapter = () => {};
863
+
864
+ // packages/@ant/model-provider/src/errorUtils.ts
865
+ function extractConnectionErrorDetails(error) {
866
+ if (!error || typeof error !== "object") {
867
+ return null;
868
+ }
869
+ let current = error;
870
+ const maxDepth = 5;
871
+ let depth = 0;
872
+ while (current && depth < maxDepth) {
873
+ if (current instanceof Error && "code" in current && typeof current.code === "string") {
874
+ const code = current.code;
875
+ const isSSLError = SSL_ERROR_CODES.has(code);
876
+ return {
877
+ code,
878
+ message: current.message,
879
+ isSSLError
880
+ };
881
+ }
882
+ if (current instanceof Error && "cause" in current && current.cause !== current) {
883
+ current = current.cause;
884
+ depth++;
885
+ } else {
886
+ break;
887
+ }
888
+ }
889
+ return null;
890
+ }
891
+ function getSSLErrorHint(error) {
892
+ const details = extractConnectionErrorDetails(error);
893
+ if (!details?.isSSLError) {
894
+ return null;
895
+ }
896
+ return `SSL certificate error (${details.code}). If you are behind a corporate proxy or TLS-intercepting firewall, set NODE_EXTRA_CA_CERTS to your CA bundle path, or ask IT to allowlist *.anthropic.com. Run /doctor for details.`;
897
+ }
898
+ function sanitizeMessageHTML(message) {
899
+ if (message.includes("<!DOCTYPE html") || message.includes("<html")) {
900
+ const titleMatch = message.match(/<title>([^<]+)<\/title>/);
901
+ if (titleMatch && titleMatch[1]) {
902
+ return titleMatch[1].trim();
903
+ }
904
+ return "";
905
+ }
906
+ return message;
907
+ }
908
+ function sanitizeAPIError(apiError) {
909
+ const message = apiError.message;
910
+ if (!message) {
911
+ return "";
912
+ }
913
+ return sanitizeMessageHTML(message);
914
+ }
915
+ function hasNestedError(value) {
916
+ return typeof value === "object" && value !== null && "error" in value && typeof value.error === "object" && value.error !== null;
917
+ }
918
+ function extractNestedErrorMessage(error) {
919
+ if (!hasNestedError(error)) {
920
+ return null;
921
+ }
922
+ const narrowed = error;
923
+ const nested = narrowed.error;
924
+ const deepMsg = nested?.error?.message;
925
+ if (typeof deepMsg === "string" && deepMsg.length > 0) {
926
+ const sanitized = sanitizeMessageHTML(deepMsg);
927
+ if (sanitized.length > 0) {
928
+ return sanitized;
929
+ }
930
+ }
931
+ const msg = nested?.message;
932
+ if (typeof msg === "string" && msg.length > 0) {
933
+ const sanitized = sanitizeMessageHTML(msg);
934
+ if (sanitized.length > 0) {
935
+ return sanitized;
936
+ }
937
+ }
938
+ return null;
939
+ }
940
+ function formatAPIError(error) {
941
+ const connectionDetails = extractConnectionErrorDetails(error);
942
+ if (connectionDetails) {
943
+ const { code, isSSLError } = connectionDetails;
944
+ if (code === "ETIMEDOUT") {
945
+ return "Request timed out. Check your internet connection and proxy settings";
946
+ }
947
+ if (isSSLError) {
948
+ switch (code) {
949
+ case "UNABLE_TO_VERIFY_LEAF_SIGNATURE":
950
+ case "UNABLE_TO_GET_ISSUER_CERT":
951
+ case "UNABLE_TO_GET_ISSUER_CERT_LOCALLY":
952
+ return "Unable to connect to API: SSL certificate verification failed. Check your proxy or corporate SSL certificates";
953
+ case "CERT_HAS_EXPIRED":
954
+ return "Unable to connect to API: SSL certificate has expired";
955
+ case "CERT_REVOKED":
956
+ return "Unable to connect to API: SSL certificate has been revoked";
957
+ case "DEPTH_ZERO_SELF_SIGNED_CERT":
958
+ case "SELF_SIGNED_CERT_IN_CHAIN":
959
+ return "Unable to connect to API: Self-signed certificate detected. Check your proxy or corporate SSL certificates";
960
+ case "ERR_TLS_CERT_ALTNAME_INVALID":
961
+ case "HOSTNAME_MISMATCH":
962
+ return "Unable to connect to API: SSL certificate hostname mismatch";
963
+ case "CERT_NOT_YET_VALID":
964
+ return "Unable to connect to API: SSL certificate is not yet valid";
965
+ default:
966
+ return `Unable to connect to API: SSL error (${code})`;
967
+ }
968
+ }
969
+ }
970
+ if (error.message === "Connection error.") {
971
+ if (connectionDetails?.code) {
972
+ return `Unable to connect to API (${connectionDetails.code})`;
973
+ }
974
+ return "Unable to connect to API. Check your internet connection";
975
+ }
976
+ if (!error.message) {
977
+ return extractNestedErrorMessage(error) ?? `API error (status ${error.status ?? "unknown"})`;
978
+ }
979
+ const sanitizedMessage = sanitizeAPIError(error);
980
+ return sanitizedMessage !== error.message && sanitizedMessage.length > 0 ? sanitizedMessage : error.message;
981
+ }
982
+ var SSL_ERROR_CODES;
983
+ var init_errorUtils = __esm(() => {
984
+ SSL_ERROR_CODES = new Set([
985
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
986
+ "UNABLE_TO_GET_ISSUER_CERT",
987
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
988
+ "CERT_SIGNATURE_FAILURE",
989
+ "CERT_NOT_YET_VALID",
990
+ "CERT_HAS_EXPIRED",
991
+ "CERT_REVOKED",
992
+ "CERT_REJECTED",
993
+ "CERT_UNTRUSTED",
994
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
995
+ "SELF_SIGNED_CERT_IN_CHAIN",
996
+ "CERT_CHAIN_TOO_LONG",
997
+ "PATH_LENGTH_EXCEEDED",
998
+ "ERR_TLS_CERT_ALTNAME_INVALID",
999
+ "HOSTNAME_MISMATCH",
1000
+ "ERR_TLS_HANDSHAKE_TIMEOUT",
1001
+ "ERR_SSL_WRONG_VERSION_NUMBER",
1002
+ "ERR_SSL_DECRYPTION_FAILED_OR_BAD_RECORD_MAC"
1003
+ ]);
1004
+ });
1005
+
1006
+ // packages/@ant/model-provider/src/shared/openaiConvertMessages.ts
1007
+ function anthropicMessagesToOpenAI(messages, systemPrompt, options) {
1008
+ const result = [];
1009
+ const enableThinking = options?.enableThinking ?? false;
1010
+ const systemText = systemPromptToText2(systemPrompt);
1011
+ if (systemText) {
1012
+ result.push({
1013
+ role: "system",
1014
+ content: systemText
1015
+ });
1016
+ }
1017
+ const turnBoundaries = new Set;
1018
+ if (enableThinking) {
1019
+ let hasSeenAssistant = false;
1020
+ for (let i = 0;i < messages.length; i++) {
1021
+ const msg = messages[i];
1022
+ if (msg.type === "assistant") {
1023
+ hasSeenAssistant = true;
1024
+ }
1025
+ if (msg.type === "user" && hasSeenAssistant) {
1026
+ const content = msg.message.content;
1027
+ const startsNewUserTurn = typeof content === "string" ? content.length > 0 : Array.isArray(content) && content.some((b) => typeof b === "string" || b && typeof b === "object" && ("type" in b) && b.type !== "tool_result");
1028
+ if (startsNewUserTurn) {
1029
+ turnBoundaries.add(i);
1030
+ }
1031
+ }
1032
+ }
1033
+ }
1034
+ for (let i = 0;i < messages.length; i++) {
1035
+ const msg = messages[i];
1036
+ switch (msg.type) {
1037
+ case "user":
1038
+ result.push(...convertInternalUserMessage2(msg));
1039
+ break;
1040
+ case "assistant":
1041
+ const preserveReasoning = enableThinking && !isBeforeAnyTurnBoundary(i, turnBoundaries);
1042
+ result.push(...convertInternalAssistantMessage2(msg, preserveReasoning));
1043
+ break;
1044
+ default:
1045
+ break;
1046
+ }
1047
+ }
1048
+ return result;
1049
+ }
1050
+ function systemPromptToText2(systemPrompt) {
1051
+ if (!systemPrompt || systemPrompt.length === 0)
1052
+ return "";
1053
+ return systemPrompt.filter(Boolean).join(`
1054
+
1055
+ `);
1056
+ }
1057
+ function isBeforeAnyTurnBoundary(i, boundaries) {
1058
+ for (const b of boundaries) {
1059
+ if (i < b)
1060
+ return true;
1061
+ }
1062
+ return false;
1063
+ }
1064
+ function convertInternalUserMessage2(msg) {
1065
+ const result = [];
1066
+ const content = msg.message.content;
1067
+ if (typeof content === "string") {
1068
+ result.push({
1069
+ role: "user",
1070
+ content
1071
+ });
1072
+ } else if (Array.isArray(content)) {
1073
+ const textParts = [];
1074
+ const toolResults = [];
1075
+ const imageParts = [];
1076
+ for (const block of content) {
1077
+ if (typeof block === "string") {
1078
+ textParts.push(block);
1079
+ } else if (block.type === "text") {
1080
+ textParts.push(block.text);
1081
+ } else if (block.type === "tool_result") {
1082
+ toolResults.push(block);
1083
+ } else if (block.type === "image") {
1084
+ const imagePart = convertImageBlockToOpenAI(block);
1085
+ if (imagePart) {
1086
+ imageParts.push(imagePart);
1087
+ }
1088
+ }
1089
+ }
1090
+ for (const tr of toolResults) {
1091
+ result.push(convertToolResult(tr));
1092
+ }
1093
+ if (imageParts.length > 0) {
1094
+ const multiContent = [];
1095
+ if (textParts.length > 0) {
1096
+ multiContent.push({ type: "text", text: textParts.join(`
1097
+ `) });
1098
+ }
1099
+ multiContent.push(...imageParts);
1100
+ result.push({
1101
+ role: "user",
1102
+ content: multiContent
1103
+ });
1104
+ } else if (textParts.length > 0) {
1105
+ result.push({
1106
+ role: "user",
1107
+ content: textParts.join(`
1108
+ `)
1109
+ });
1110
+ }
1111
+ }
1112
+ return result;
1113
+ }
1114
+ function convertToolResult(block) {
1115
+ let content;
1116
+ if (typeof block.content === "string") {
1117
+ content = block.content;
1118
+ } else if (Array.isArray(block.content)) {
1119
+ content = block.content.map((c) => {
1120
+ if (typeof c === "string")
1121
+ return c;
1122
+ if ("text" in c)
1123
+ return c.text;
1124
+ return "";
1125
+ }).filter(Boolean).join(`
1126
+ `);
1127
+ } else {
1128
+ content = "";
1129
+ }
1130
+ return {
1131
+ role: "tool",
1132
+ tool_call_id: block.tool_use_id,
1133
+ content
1134
+ };
1135
+ }
1136
+ function convertInternalAssistantMessage2(msg, preserveReasoning = false) {
1137
+ const content = msg.message.content;
1138
+ if (typeof content === "string") {
1139
+ return [
1140
+ {
1141
+ role: "assistant",
1142
+ content
1143
+ }
1144
+ ];
1145
+ }
1146
+ if (!Array.isArray(content)) {
1147
+ return [
1148
+ {
1149
+ role: "assistant",
1150
+ content: ""
1151
+ }
1152
+ ];
1153
+ }
1154
+ const textParts = [];
1155
+ const toolCalls = [];
1156
+ const reasoningParts = [];
1157
+ for (const block of content) {
1158
+ if (typeof block === "string") {
1159
+ textParts.push(block);
1160
+ } else if (block.type === "text") {
1161
+ textParts.push(block.text);
1162
+ } else if (block.type === "tool_use") {
1163
+ const tu = block;
1164
+ toolCalls.push({
1165
+ id: tu.id,
1166
+ type: "function",
1167
+ function: {
1168
+ name: tu.name,
1169
+ arguments: typeof tu.input === "string" ? tu.input : JSON.stringify(tu.input)
1170
+ }
1171
+ });
1172
+ } else if (block.type === "thinking" && preserveReasoning) {
1173
+ const thinkingText = block.thinking;
1174
+ if (typeof thinkingText === "string" && thinkingText) {
1175
+ reasoningParts.push(thinkingText);
1176
+ }
1177
+ }
1178
+ }
1179
+ const result = {
1180
+ role: "assistant",
1181
+ content: textParts.length > 0 ? textParts.join(`
1182
+ `) : null,
1183
+ ...toolCalls.length > 0 && { tool_calls: toolCalls },
1184
+ ...reasoningParts.length > 0 && { reasoning_content: reasoningParts.join(`
1185
+ `) }
1186
+ };
1187
+ return [result];
1188
+ }
1189
+ function convertImageBlockToOpenAI(block) {
1190
+ const source = block.source;
1191
+ if (!source)
1192
+ return null;
1193
+ if (source.type === "base64" && typeof source.data === "string") {
1194
+ const mediaType = source.media_type || "image/png";
1195
+ return {
1196
+ type: "image_url",
1197
+ image_url: {
1198
+ url: `data:${mediaType};base64,${source.data}`
1199
+ }
1200
+ };
1201
+ }
1202
+ if (source.type === "url" && typeof source.url === "string") {
1203
+ return {
1204
+ type: "image_url",
1205
+ image_url: {
1206
+ url: source.url
1207
+ }
1208
+ };
1209
+ }
1210
+ return null;
1211
+ }
1212
+ var init_openaiConvertMessages = () => {};
1213
+
1214
+ // packages/@ant/model-provider/src/shared/openaiConvertTools.ts
1215
+ function anthropicToolsToOpenAI(tools) {
1216
+ return tools.filter((tool) => {
1217
+ const toolType = tool.type;
1218
+ return tool.type === "custom" || !("type" in tool) || toolType !== "server";
1219
+ }).map((tool) => {
1220
+ const anyTool = tool;
1221
+ const name = anyTool.name || "";
1222
+ const description = anyTool.description || "";
1223
+ const inputSchema = anyTool.input_schema;
1224
+ return {
1225
+ type: "function",
1226
+ function: {
1227
+ name,
1228
+ description,
1229
+ parameters: sanitizeJsonSchema(inputSchema || { type: "object", properties: {} })
1230
+ }
1231
+ };
1232
+ });
1233
+ }
1234
+ function sanitizeJsonSchema(schema) {
1235
+ if (!schema || typeof schema !== "object")
1236
+ return schema;
1237
+ const result = { ...schema };
1238
+ if ("const" in result) {
1239
+ result.enum = [result.const];
1240
+ delete result.const;
1241
+ }
1242
+ const objectKeys = ["properties", "definitions", "$defs", "patternProperties"];
1243
+ for (const key of objectKeys) {
1244
+ const nested = result[key];
1245
+ if (nested && typeof nested === "object") {
1246
+ const sanitized = {};
1247
+ for (const [k, v] of Object.entries(nested)) {
1248
+ sanitized[k] = v && typeof v === "object" ? sanitizeJsonSchema(v) : v;
1249
+ }
1250
+ result[key] = sanitized;
1251
+ }
1252
+ }
1253
+ const singleKeys = ["items", "additionalProperties", "not", "if", "then", "else", "contains", "propertyNames"];
1254
+ for (const key of singleKeys) {
1255
+ const nested = result[key];
1256
+ if (nested && typeof nested === "object" && !Array.isArray(nested)) {
1257
+ result[key] = sanitizeJsonSchema(nested);
1258
+ }
1259
+ }
1260
+ const arrayKeys = ["anyOf", "oneOf", "allOf"];
1261
+ for (const key of arrayKeys) {
1262
+ const nested = result[key];
1263
+ if (Array.isArray(nested)) {
1264
+ result[key] = nested.map((item) => item && typeof item === "object" ? sanitizeJsonSchema(item) : item);
1265
+ }
1266
+ }
1267
+ return result;
1268
+ }
1269
+ function anthropicToolChoiceToOpenAI(toolChoice) {
1270
+ if (!toolChoice || typeof toolChoice !== "object")
1271
+ return;
1272
+ const tc = toolChoice;
1273
+ const type = tc.type;
1274
+ switch (type) {
1275
+ case "auto":
1276
+ return "auto";
1277
+ case "any":
1278
+ return "required";
1279
+ case "tool":
1280
+ return {
1281
+ type: "function",
1282
+ function: { name: tc.name }
1283
+ };
1284
+ default:
1285
+ return;
1286
+ }
1287
+ }
1288
+ var init_openaiConvertTools = () => {};
1289
+
1290
+ // packages/@ant/model-provider/src/shared/openaiStreamAdapter.ts
1291
+ import { randomUUID as randomUUID2 } from "crypto";
1292
+ async function* adaptOpenAIStreamToAnthropic(stream, model) {
1293
+ const messageId = `msg_${randomUUID2().replace(/-/g, "").slice(0, 24)}`;
1294
+ let started = false;
1295
+ let currentContentIndex = -1;
1296
+ const toolBlocks = new Map;
1297
+ let thinkingBlockOpen = false;
1298
+ let textBlockOpen = false;
1299
+ let inputTokens = 0;
1300
+ let outputTokens = 0;
1301
+ let cachedReadTokens = 0;
1302
+ const openBlockIndices = new Set;
1303
+ let pendingFinishReason = null;
1304
+ let pendingHasToolCalls = false;
1305
+ for await (const chunk of stream) {
1306
+ const choice = chunk.choices?.[0];
1307
+ const delta = choice?.delta;
1308
+ if (chunk.usage) {
1309
+ inputTokens = chunk.usage.prompt_tokens ?? inputTokens;
1310
+ outputTokens = chunk.usage.completion_tokens ?? outputTokens;
1311
+ const details = chunk.usage.prompt_tokens_details;
1312
+ if (details?.cached_tokens != null) {
1313
+ cachedReadTokens = details.cached_tokens;
1314
+ }
1315
+ }
1316
+ if (!started) {
1317
+ started = true;
1318
+ yield {
1319
+ type: "message_start",
1320
+ message: {
1321
+ id: messageId,
1322
+ type: "message",
1323
+ role: "assistant",
1324
+ content: [],
1325
+ model,
1326
+ stop_reason: null,
1327
+ stop_sequence: null,
1328
+ usage: {
1329
+ input_tokens: inputTokens,
1330
+ output_tokens: 0,
1331
+ cache_creation_input_tokens: 0,
1332
+ cache_read_input_tokens: cachedReadTokens
1333
+ }
1334
+ }
1335
+ };
1336
+ }
1337
+ if (!delta)
1338
+ continue;
1339
+ const reasoningContent = delta.reasoning_content;
1340
+ if (reasoningContent != null && reasoningContent !== "") {
1341
+ if (!thinkingBlockOpen) {
1342
+ currentContentIndex++;
1343
+ thinkingBlockOpen = true;
1344
+ openBlockIndices.add(currentContentIndex);
1345
+ yield {
1346
+ type: "content_block_start",
1347
+ index: currentContentIndex,
1348
+ content_block: {
1349
+ type: "thinking",
1350
+ thinking: "",
1351
+ signature: ""
1352
+ }
1353
+ };
1354
+ }
1355
+ yield {
1356
+ type: "content_block_delta",
1357
+ index: currentContentIndex,
1358
+ delta: {
1359
+ type: "thinking_delta",
1360
+ thinking: reasoningContent
1361
+ }
1362
+ };
1363
+ }
1364
+ if (delta.content != null && delta.content !== "") {
1365
+ if (!textBlockOpen) {
1366
+ if (thinkingBlockOpen) {
1367
+ yield {
1368
+ type: "content_block_stop",
1369
+ index: currentContentIndex
1370
+ };
1371
+ openBlockIndices.delete(currentContentIndex);
1372
+ thinkingBlockOpen = false;
1373
+ }
1374
+ currentContentIndex++;
1375
+ textBlockOpen = true;
1376
+ openBlockIndices.add(currentContentIndex);
1377
+ yield {
1378
+ type: "content_block_start",
1379
+ index: currentContentIndex,
1380
+ content_block: {
1381
+ type: "text",
1382
+ text: ""
1383
+ }
1384
+ };
1385
+ }
1386
+ yield {
1387
+ type: "content_block_delta",
1388
+ index: currentContentIndex,
1389
+ delta: {
1390
+ type: "text_delta",
1391
+ text: delta.content
1392
+ }
1393
+ };
1394
+ }
1395
+ if (delta.tool_calls) {
1396
+ for (const tc of delta.tool_calls) {
1397
+ const tcIndex = tc.index;
1398
+ if (!toolBlocks.has(tcIndex)) {
1399
+ if (thinkingBlockOpen) {
1400
+ yield {
1401
+ type: "content_block_stop",
1402
+ index: currentContentIndex
1403
+ };
1404
+ openBlockIndices.delete(currentContentIndex);
1405
+ thinkingBlockOpen = false;
1406
+ }
1407
+ if (textBlockOpen) {
1408
+ yield {
1409
+ type: "content_block_stop",
1410
+ index: currentContentIndex
1411
+ };
1412
+ openBlockIndices.delete(currentContentIndex);
1413
+ textBlockOpen = false;
1414
+ }
1415
+ currentContentIndex++;
1416
+ const toolId = tc.id || `toolu_${randomUUID2().replace(/-/g, "").slice(0, 24)}`;
1417
+ const toolName = tc.function?.name || "";
1418
+ toolBlocks.set(tcIndex, {
1419
+ contentIndex: currentContentIndex,
1420
+ id: toolId,
1421
+ name: toolName,
1422
+ arguments: ""
1423
+ });
1424
+ openBlockIndices.add(currentContentIndex);
1425
+ yield {
1426
+ type: "content_block_start",
1427
+ index: currentContentIndex,
1428
+ content_block: {
1429
+ type: "tool_use",
1430
+ id: toolId,
1431
+ name: toolName,
1432
+ input: {}
1433
+ }
1434
+ };
1435
+ }
1436
+ const argFragment = tc.function?.arguments;
1437
+ if (argFragment) {
1438
+ toolBlocks.get(tcIndex).arguments += argFragment;
1439
+ yield {
1440
+ type: "content_block_delta",
1441
+ index: toolBlocks.get(tcIndex).contentIndex,
1442
+ delta: {
1443
+ type: "input_json_delta",
1444
+ partial_json: argFragment
1445
+ }
1446
+ };
1447
+ }
1448
+ }
1449
+ }
1450
+ if (choice?.finish_reason) {
1451
+ if (thinkingBlockOpen) {
1452
+ yield {
1453
+ type: "content_block_stop",
1454
+ index: currentContentIndex
1455
+ };
1456
+ openBlockIndices.delete(currentContentIndex);
1457
+ thinkingBlockOpen = false;
1458
+ }
1459
+ if (textBlockOpen) {
1460
+ yield {
1461
+ type: "content_block_stop",
1462
+ index: currentContentIndex
1463
+ };
1464
+ openBlockIndices.delete(currentContentIndex);
1465
+ textBlockOpen = false;
1466
+ }
1467
+ for (const [, block] of toolBlocks) {
1468
+ if (openBlockIndices.has(block.contentIndex)) {
1469
+ yield {
1470
+ type: "content_block_stop",
1471
+ index: block.contentIndex
1472
+ };
1473
+ openBlockIndices.delete(block.contentIndex);
1474
+ }
1475
+ }
1476
+ pendingFinishReason = choice.finish_reason;
1477
+ pendingHasToolCalls = toolBlocks.size > 0;
1478
+ }
1479
+ }
1480
+ for (const idx of openBlockIndices) {
1481
+ yield {
1482
+ type: "content_block_stop",
1483
+ index: idx
1484
+ };
1485
+ }
1486
+ if (pendingFinishReason !== null) {
1487
+ const stopReason = pendingFinishReason === "length" ? "max_tokens" : pendingHasToolCalls ? "tool_use" : mapFinishReason(pendingFinishReason);
1488
+ yield {
1489
+ type: "message_delta",
1490
+ delta: {
1491
+ stop_reason: stopReason,
1492
+ stop_sequence: null
1493
+ },
1494
+ usage: {
1495
+ input_tokens: inputTokens,
1496
+ output_tokens: outputTokens,
1497
+ cache_read_input_tokens: cachedReadTokens,
1498
+ cache_creation_input_tokens: 0
1499
+ }
1500
+ };
1501
+ yield {
1502
+ type: "message_stop"
1503
+ };
1504
+ }
1505
+ }
1506
+ function mapFinishReason(reason) {
1507
+ switch (reason) {
1508
+ case "stop":
1509
+ return "end_turn";
1510
+ case "tool_calls":
1511
+ return "tool_use";
1512
+ case "length":
1513
+ return "max_tokens";
1514
+ case "content_filter":
1515
+ return "end_turn";
1516
+ default:
1517
+ return "end_turn";
1518
+ }
1519
+ }
1520
+ var init_openaiStreamAdapter = () => {};
1521
+
1522
+ // packages/@ant/model-provider/src/hooks/index.ts
1523
+ var init_hooks = () => {};
1524
+
1525
+ // packages/@ant/model-provider/src/client/index.ts
1526
+ var init_client = () => {};
1527
+
1528
+ // packages/@ant/model-provider/src/types/message.ts
1529
+ var init_message = () => {};
1530
+
1531
+ // packages/@ant/model-provider/src/types/errors.ts
1532
+ var init_errors2 = () => {};
1533
+
1534
+ // packages/@ant/model-provider/src/types/index.ts
1535
+ var init_types2 = __esm(() => {
1536
+ init_message();
1537
+ init_usage();
1538
+ init_errors2();
1539
+ init_systemPrompt();
1540
+ });
1541
+
1542
+ // packages/@ant/model-provider/src/index.ts
1543
+ var init_src = __esm(() => {
1544
+ init_hooks();
1545
+ init_client();
1546
+ init_modelMapping();
1547
+ init_modelMapping2();
1548
+ init_modelMapping3();
1549
+ init_convertMessages();
1550
+ init_convertTools();
1551
+ init_streamAdapter();
1552
+ init_types();
1553
+ init_errorUtils();
1554
+ init_openaiConvertMessages();
1555
+ init_openaiConvertTools();
1556
+ init_openaiStreamAdapter();
1557
+ init_types2();
1558
+ });
1559
+
1560
+ // src/utils/sessionIngressAuth.ts
1561
+ function getTokenFromFileDescriptor() {
1562
+ const cachedToken = getSessionIngressToken();
1563
+ if (cachedToken !== undefined) {
1564
+ return cachedToken;
1565
+ }
1566
+ const fdEnv = process.env.CLAUDE_CODE_WEBSOCKET_AUTH_FILE_DESCRIPTOR;
1567
+ if (!fdEnv) {
1568
+ const path = process.env.CLAUDE_SESSION_INGRESS_TOKEN_FILE ?? CCR_SESSION_INGRESS_TOKEN_PATH;
1569
+ const fromFile = readTokenFromWellKnownFile(path, "session ingress token");
1570
+ setSessionIngressToken(fromFile);
1571
+ return fromFile;
1572
+ }
1573
+ const fd = parseInt(fdEnv, 10);
1574
+ if (Number.isNaN(fd)) {
1575
+ logForDebugging(`CLAUDE_CODE_WEBSOCKET_AUTH_FILE_DESCRIPTOR must be a valid file descriptor number, got: ${fdEnv}`, { level: "error" });
1576
+ setSessionIngressToken(null);
1577
+ return null;
1578
+ }
1579
+ try {
1580
+ const fsOps = getFsImplementation();
1581
+ const fdPath = process.platform === "darwin" || process.platform === "freebsd" ? `/dev/fd/${fd}` : `/proc/self/fd/${fd}`;
1582
+ const token = fsOps.readFileSync(fdPath, { encoding: "utf8" }).trim();
1583
+ if (!token) {
1584
+ logForDebugging("File descriptor contained empty token", {
1585
+ level: "error"
1586
+ });
1587
+ setSessionIngressToken(null);
1588
+ return null;
1589
+ }
1590
+ logForDebugging(`Successfully read token from file descriptor ${fd}`);
1591
+ setSessionIngressToken(token);
1592
+ maybePersistTokenForSubprocesses(CCR_SESSION_INGRESS_TOKEN_PATH, token, "session ingress token");
1593
+ return token;
1594
+ } catch (error) {
1595
+ logForDebugging(`Failed to read token from file descriptor ${fd}: ${errorMessage(error)}`, { level: "error" });
1596
+ const path = process.env.CLAUDE_SESSION_INGRESS_TOKEN_FILE ?? CCR_SESSION_INGRESS_TOKEN_PATH;
1597
+ const fromFile = readTokenFromWellKnownFile(path, "session ingress token");
1598
+ setSessionIngressToken(fromFile);
1599
+ return fromFile;
1600
+ }
1601
+ }
1602
+ function getSessionIngressAuthToken() {
1603
+ const envToken = process.env.CLAUDE_CODE_SESSION_ACCESS_TOKEN;
1604
+ if (envToken) {
1605
+ return envToken;
1606
+ }
1607
+ return getTokenFromFileDescriptor();
1608
+ }
1609
+ function getSessionIngressAuthHeaders() {
1610
+ const token = getSessionIngressAuthToken();
1611
+ if (!token)
1612
+ return {};
1613
+ if (token.startsWith("sk-ant-sid")) {
1614
+ const headers = {
1615
+ Cookie: `sessionKey=${token}`
1616
+ };
1617
+ const orgUuid = process.env.CLAUDE_CODE_ORGANIZATION_UUID;
1618
+ if (orgUuid) {
1619
+ headers["X-Organization-Uuid"] = orgUuid;
1620
+ }
1621
+ return headers;
1622
+ }
1623
+ return { Authorization: `Bearer ${token}` };
1624
+ }
1625
+ function updateSessionIngressAuthToken(token) {
1626
+ process.env.CLAUDE_CODE_SESSION_ACCESS_TOKEN = token;
1627
+ }
1628
+ var init_sessionIngressAuth = __esm(() => {
1629
+ init_state();
1630
+ init_authFileDescriptor();
1631
+ init_debug();
1632
+ init_errors();
1633
+ init_fsOperations();
1634
+ });
1635
+
1636
+ // src/utils/sessionActivity.ts
1637
+ function startHeartbeatTimer() {
1638
+ clearIdleTimer();
1639
+ heartbeatTimer = setInterval(() => {
1640
+ logForDiagnosticsNoPII("debug", "session_keepalive_heartbeat", {
1641
+ refcount
1642
+ });
1643
+ if (isEnvTruthy(process.env.CLAUDE_CODE_REMOTE_SEND_KEEPALIVES)) {
1644
+ activityCallback?.();
1645
+ }
1646
+ }, SESSION_ACTIVITY_INTERVAL_MS);
1647
+ }
1648
+ function startIdleTimer() {
1649
+ clearIdleTimer();
1650
+ if (activityCallback === null) {
1651
+ return;
1652
+ }
1653
+ idleTimer = setTimeout(() => {
1654
+ logForDiagnosticsNoPII("info", "session_idle_30s");
1655
+ idleTimer = null;
1656
+ }, SESSION_ACTIVITY_INTERVAL_MS);
1657
+ }
1658
+ function clearIdleTimer() {
1659
+ if (idleTimer !== null) {
1660
+ clearTimeout(idleTimer);
1661
+ idleTimer = null;
1662
+ }
1663
+ }
1664
+ function registerSessionActivityCallback(cb) {
1665
+ activityCallback = cb;
1666
+ if (refcount > 0 && heartbeatTimer === null) {
1667
+ startHeartbeatTimer();
1668
+ }
1669
+ }
1670
+ function unregisterSessionActivityCallback() {
1671
+ activityCallback = null;
1672
+ if (heartbeatTimer !== null) {
1673
+ clearInterval(heartbeatTimer);
1674
+ heartbeatTimer = null;
1675
+ }
1676
+ clearIdleTimer();
1677
+ }
1678
+ function sendSessionActivitySignal() {
1679
+ if (isEnvTruthy(process.env.CLAUDE_CODE_REMOTE_SEND_KEEPALIVES)) {
1680
+ activityCallback?.();
1681
+ }
1682
+ }
1683
+ function isSessionActivityTrackingActive() {
1684
+ return activityCallback !== null;
1685
+ }
1686
+ function startSessionActivity(reason) {
1687
+ refcount++;
1688
+ activeReasons.set(reason, (activeReasons.get(reason) ?? 0) + 1);
1689
+ if (refcount === 1) {
1690
+ oldestActivityStartedAt = Date.now();
1691
+ if (activityCallback !== null && heartbeatTimer === null) {
1692
+ startHeartbeatTimer();
1693
+ }
1694
+ }
1695
+ if (!cleanupRegistered) {
1696
+ cleanupRegistered = true;
1697
+ registerCleanup(async () => {
1698
+ logForDiagnosticsNoPII("info", "session_activity_at_shutdown", {
1699
+ refcount,
1700
+ active: Object.fromEntries(activeReasons),
1701
+ oldest_activity_ms: refcount > 0 && oldestActivityStartedAt !== null ? Date.now() - oldestActivityStartedAt : null
1702
+ });
1703
+ });
1704
+ }
1705
+ }
1706
+ function stopSessionActivity(reason) {
1707
+ if (refcount > 0) {
1708
+ refcount--;
1709
+ }
1710
+ const n = (activeReasons.get(reason) ?? 0) - 1;
1711
+ if (n > 0)
1712
+ activeReasons.set(reason, n);
1713
+ else
1714
+ activeReasons.delete(reason);
1715
+ if (refcount === 0 && heartbeatTimer !== null) {
1716
+ clearInterval(heartbeatTimer);
1717
+ heartbeatTimer = null;
1718
+ startIdleTimer();
1719
+ }
1720
+ }
1721
+ var SESSION_ACTIVITY_INTERVAL_MS = 30000, activityCallback = null, refcount = 0, activeReasons, oldestActivityStartedAt = null, heartbeatTimer = null, idleTimer = null, cleanupRegistered = false;
1722
+ var init_sessionActivity = __esm(() => {
1723
+ init_cleanupRegistry();
1724
+ init_diagLogs();
1725
+ init_envUtils();
1726
+ activeReasons = new Map;
1727
+ });
1728
+
1729
+ // src/bridge/rcDebugLog.ts
1730
+ import { appendFileSync, mkdirSync, existsSync } from "fs";
1731
+ import { homedir } from "os";
1732
+ import { join } from "path";
1733
+ function ensureLogDir() {
1734
+ const dir = join(homedir(), ".claude");
1735
+ if (!existsSync(dir))
1736
+ mkdirSync(dir, { recursive: true });
1737
+ }
1738
+ function rcLog(msg) {
1739
+ try {
1740
+ if (!headerWritten) {
1741
+ ensureLogDir();
1742
+ appendFileSync(LOG_PATH, `
1743
+ ===== RC-DEBUG session ${new Date().toISOString()} =====
1744
+ `);
1745
+ headerWritten = true;
1746
+ }
1747
+ const ts = new Date().toISOString().slice(11, 23);
1748
+ appendFileSync(LOG_PATH, `[${ts}] ${msg}
1749
+ `);
1750
+ } catch {}
1751
+ }
1752
+ var LOG_PATH, headerWritten = false;
1753
+ var init_rcDebugLog = __esm(() => {
1754
+ LOG_PATH = join(homedir(), ".claude", "rc-debug.log");
1755
+ });
1756
+
1757
+ export { EMPTY_USAGE, asSystemPrompt, resolveOpenAIModel, resolveGrokModel, resolveGeminiModel, GEMINI_THOUGHT_SIGNATURE_FIELD, anthropicMessagesToGemini, anthropicToolsToGemini, anthropicToolChoiceToGemini, adaptGeminiStreamToAnthropic, extractConnectionErrorDetails, getSSLErrorHint, formatAPIError, anthropicMessagesToOpenAI, anthropicToolsToOpenAI, anthropicToolChoiceToOpenAI, adaptOpenAIStreamToAnthropic, init_src, getSessionIngressAuthToken, getSessionIngressAuthHeaders, updateSessionIngressAuthToken, init_sessionIngressAuth, registerSessionActivityCallback, unregisterSessionActivityCallback, sendSessionActivitySignal, isSessionActivityTrackingActive, startSessionActivity, stopSessionActivity, init_sessionActivity, rcLog, init_rcDebugLog };