@caspian2026/agent-sdk 0.0.24 → 0.0.26

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 (362) hide show
  1. package/dist/gateway/index.js +98 -22
  2. package/dist/gateway/worker.js +196 -47
  3. package/dist/sdk/query.cjs +2 -362
  4. package/dist/sdk/query.js +2 -367
  5. package/package.json +4 -6
  6. package/dist/chunk-05kvhzd7.js +0 -3561
  7. package/dist/chunk-07069jq1.js +0 -30
  8. package/dist/chunk-0731m51q.js +0 -8
  9. package/dist/chunk-08bspa4b.js +0 -673
  10. package/dist/chunk-0brkf8q8.js +0 -89
  11. package/dist/chunk-0n843xh7.js +0 -261
  12. package/dist/chunk-0nbp5jwx.js +0 -8583
  13. package/dist/chunk-0nj16az9.js +0 -169
  14. package/dist/chunk-0paqc2yw.js +0 -15
  15. package/dist/chunk-0q6b50ps.js +0 -111
  16. package/dist/chunk-0r5bb9j4.js +0 -477
  17. package/dist/chunk-0rpz1wgn.js +0 -1030
  18. package/dist/chunk-0t81d427.js +0 -41
  19. package/dist/chunk-0vaw02wq.js +0 -24
  20. package/dist/chunk-0vkfrmqm.js +0 -690
  21. package/dist/chunk-0vp3wfab.js +0 -12
  22. package/dist/chunk-0vr10742.js +0 -1809
  23. package/dist/chunk-0xjaqda8.js +0 -1124
  24. package/dist/chunk-13ehyphg.js +0 -223
  25. package/dist/chunk-15jsw9bb.js +0 -349
  26. package/dist/chunk-16m7eyyw.js +0 -1385
  27. package/dist/chunk-1ae3nt9j.js +0 -31
  28. package/dist/chunk-1gq4r3v1.js +0 -308
  29. package/dist/chunk-1gx78081.js +0 -66
  30. package/dist/chunk-1h2famwb.js +0 -49
  31. package/dist/chunk-1n546sfg.js +0 -200
  32. package/dist/chunk-1qg06d60.js +0 -494
  33. package/dist/chunk-1t0rqstn.js +0 -146
  34. package/dist/chunk-1z8p2eqd.js +0 -40
  35. package/dist/chunk-1zjh9cc5.js +0 -266
  36. package/dist/chunk-20ahkkrb.js +0 -132
  37. package/dist/chunk-21pbfch8.js +0 -105
  38. package/dist/chunk-26wtxbdc.js +0 -13870
  39. package/dist/chunk-2fwze72g.js +0 -24
  40. package/dist/chunk-2gcbr1c7.js +0 -107
  41. package/dist/chunk-2grc1yr8.js +0 -654
  42. package/dist/chunk-2gzv8nrw.js +0 -205
  43. package/dist/chunk-2r212cvt.js +0 -253
  44. package/dist/chunk-2s74bt6e.js +0 -317
  45. package/dist/chunk-2v385w7r.js +0 -7422
  46. package/dist/chunk-2wtkvpp2.js +0 -167
  47. package/dist/chunk-31rsspfr.js +0 -418
  48. package/dist/chunk-3c25bcsw.js +0 -17
  49. package/dist/chunk-3jm08aaw.js +0 -91
  50. package/dist/chunk-3mgywd32.js +0 -8
  51. package/dist/chunk-3nk79af8.js +0 -8
  52. package/dist/chunk-3v4sk2py.js +0 -101
  53. package/dist/chunk-3vwft0eh.js +0 -349
  54. package/dist/chunk-3vy1jt9p.js +0 -1010
  55. package/dist/chunk-3wvqzq9w.js +0 -92
  56. package/dist/chunk-3wvv2s8d.js +0 -336
  57. package/dist/chunk-4060b3s2.js +0 -108
  58. package/dist/chunk-434e0vh4.js +0 -275
  59. package/dist/chunk-46dm23zs.js +0 -344
  60. package/dist/chunk-4bh4qs70.js +0 -209
  61. package/dist/chunk-4cxzbqws.js +0 -94
  62. package/dist/chunk-4jm600zv.js +0 -13
  63. package/dist/chunk-4k9d7gxv.js +0 -118
  64. package/dist/chunk-4nc3t6ms.js +0 -396
  65. package/dist/chunk-4pbx3g7s.js +0 -26
  66. package/dist/chunk-4qhh8bpa.js +0 -54
  67. package/dist/chunk-4v63px9y.js +0 -133
  68. package/dist/chunk-4xnnzt3j.js +0 -74
  69. package/dist/chunk-4zchh01h.js +0 -201
  70. package/dist/chunk-5216fha8.js +0 -1163
  71. package/dist/chunk-55raexh7.js +0 -14358
  72. package/dist/chunk-5bffhf64.js +0 -81
  73. package/dist/chunk-5ccdsxgy.js +0 -74
  74. package/dist/chunk-5ddh2hyn.js +0 -91
  75. package/dist/chunk-5e6ncq5j.js +0 -61
  76. package/dist/chunk-5ekyhb1w.js +0 -422
  77. package/dist/chunk-5fy4r8rv.js +0 -52
  78. package/dist/chunk-5h5kx2jd.js +0 -34
  79. package/dist/chunk-5mbgdvyz.js +0 -847
  80. package/dist/chunk-5n1jc02d.js +0 -87
  81. package/dist/chunk-5pysjah8.js +0 -1543
  82. package/dist/chunk-5ssfz438.js +0 -323
  83. package/dist/chunk-5z28bqne.js +0 -6748
  84. package/dist/chunk-603y0mmg.js +0 -50
  85. package/dist/chunk-62v5kkff.js +0 -90
  86. package/dist/chunk-64c1avct.js +0 -13
  87. package/dist/chunk-64r16v22.js +0 -162
  88. package/dist/chunk-64smdx4a.js +0 -418
  89. package/dist/chunk-66zry909.js +0 -11
  90. package/dist/chunk-68ffk5qa.js +0 -14
  91. package/dist/chunk-69n11zng.js +0 -436
  92. package/dist/chunk-6dj5t602.js +0 -341
  93. package/dist/chunk-6dngjwkh.js +0 -63
  94. package/dist/chunk-6nsd9606.js +0 -790
  95. package/dist/chunk-6pkh8frk.js +0 -253
  96. package/dist/chunk-6qcmt5eb.js +0 -251
  97. package/dist/chunk-6ww7451s.js +0 -60
  98. package/dist/chunk-6xgb0kqz.js +0 -90
  99. package/dist/chunk-72ys9m07.js +0 -121
  100. package/dist/chunk-741sgvtx.js +0 -121
  101. package/dist/chunk-7aw745vx.js +0 -40175
  102. package/dist/chunk-7c8b8cfb.js +0 -219
  103. package/dist/chunk-7mwt4e1z.js +0 -234
  104. package/dist/chunk-7sgtxrsc.js +0 -1059
  105. package/dist/chunk-7wm5s02e.js +0 -216
  106. package/dist/chunk-7xyswgjh.js +0 -8
  107. package/dist/chunk-80a197ez.js +0 -1438
  108. package/dist/chunk-83hfzbx3.js +0 -10
  109. package/dist/chunk-8akrsgad.js +0 -55
  110. package/dist/chunk-8g5pe1gr.js +0 -37
  111. package/dist/chunk-8s07t4k7.js +0 -40
  112. package/dist/chunk-8yhf030a.js +0 -69
  113. package/dist/chunk-928tzaa8.js +0 -107
  114. package/dist/chunk-949pjzj9.js +0 -266
  115. package/dist/chunk-9aycd4z9.js +0 -490
  116. package/dist/chunk-9bzqvsz5.js +0 -211
  117. package/dist/chunk-9q3xfy27.js +0 -460
  118. package/dist/chunk-9vzg1360.js +0 -153
  119. package/dist/chunk-9wbh8n1y.js +0 -63
  120. package/dist/chunk-9x5zgy22.js +0 -12
  121. package/dist/chunk-9zdj4ypz.js +0 -206
  122. package/dist/chunk-a0bvcgyd.js +0 -127
  123. package/dist/chunk-a4m3yr2q.js +0 -117
  124. package/dist/chunk-a8jd4gee.js +0 -227
  125. package/dist/chunk-ase86y73.js +0 -15
  126. package/dist/chunk-atfzpm6r.js +0 -325
  127. package/dist/chunk-awqsddp2.js +0 -338
  128. package/dist/chunk-awrgzpk6.js +0 -29
  129. package/dist/chunk-b0kf00ff.js +0 -637
  130. package/dist/chunk-b1kcd3ss.js +0 -27
  131. package/dist/chunk-b4hy21c4.js +0 -140
  132. package/dist/chunk-b9mkm8mg.js +0 -111
  133. package/dist/chunk-bdjx14rd.js +0 -594
  134. package/dist/chunk-bfb41q9h.js +0 -295
  135. package/dist/chunk-bg4x9ex0.js +0 -21
  136. package/dist/chunk-bh5zqvyc.js +0 -36
  137. package/dist/chunk-bn0zv2y2.js +0 -1154
  138. package/dist/chunk-bn7t681c.js +0 -2669
  139. package/dist/chunk-br4wgffc.js +0 -393
  140. package/dist/chunk-brjd9zmk.js +0 -42
  141. package/dist/chunk-byfawrfx.js +0 -121
  142. package/dist/chunk-c6sjhj89.js +0 -1284
  143. package/dist/chunk-c7jwbe76.js +0 -29030
  144. package/dist/chunk-cdef9v7b.js +0 -27
  145. package/dist/chunk-cdz5yb0r.js +0 -57
  146. package/dist/chunk-cevq1787.js +0 -2718
  147. package/dist/chunk-cgfdkzhb.js +0 -12
  148. package/dist/chunk-cgqw4x5z.js +0 -155
  149. package/dist/chunk-cmmmc8e0.js +0 -212
  150. package/dist/chunk-cnsj3vq2.js +0 -35
  151. package/dist/chunk-cxrktb5g.js +0 -51
  152. package/dist/chunk-cyhrb0bk.js +0 -251
  153. package/dist/chunk-d23rmn8r.js +0 -62
  154. package/dist/chunk-d4mdda98.js +0 -94
  155. package/dist/chunk-dcwp94cj.js +0 -152
  156. package/dist/chunk-ddsjkqs4.js +0 -39
  157. package/dist/chunk-ddv56j39.js +0 -148
  158. package/dist/chunk-dfq6pbq7.js +0 -5822
  159. package/dist/chunk-dfzkwynj.js +0 -5368
  160. package/dist/chunk-dkgkd8b7.js +0 -516
  161. package/dist/chunk-dpnmf0pq.js +0 -312
  162. package/dist/chunk-dygx7vcc.js +0 -226
  163. package/dist/chunk-e0abab5b.js +0 -445
  164. package/dist/chunk-e5qhvhjy.js +0 -168
  165. package/dist/chunk-e60y6r1n.js +0 -20
  166. package/dist/chunk-e68kgvcq.js +0 -79
  167. package/dist/chunk-e9w9zc0g.js +0 -392
  168. package/dist/chunk-ecj9w6tm.js +0 -558
  169. package/dist/chunk-ehtwnxpg.js +0 -1591
  170. package/dist/chunk-eqp1rfft.js +0 -17
  171. package/dist/chunk-etdt1xz3.js +0 -19
  172. package/dist/chunk-ewadzrm8.js +0 -103
  173. package/dist/chunk-f03s83vj.js +0 -91
  174. package/dist/chunk-f3kk0p3s.js +0 -150
  175. package/dist/chunk-f3pjerx4.js +0 -4265
  176. package/dist/chunk-f6h5weh6.js +0 -61
  177. package/dist/chunk-fajg8x36.js +0 -8158
  178. package/dist/chunk-fbv4apne.js +0 -51
  179. package/dist/chunk-fcynwjpm.js +0 -1072
  180. package/dist/chunk-fdvaf6nn.js +0 -20
  181. package/dist/chunk-feyzykye.js +0 -10
  182. package/dist/chunk-ff85rwvc.js +0 -180
  183. package/dist/chunk-fqak69ft.js +0 -458
  184. package/dist/chunk-fxdkbabd.js +0 -195
  185. package/dist/chunk-fyc5fepv.js +0 -10
  186. package/dist/chunk-g78c6ztj.js +0 -89
  187. package/dist/chunk-g8ee7yza.js +0 -105
  188. package/dist/chunk-g9f19ttm.js +0 -15
  189. package/dist/chunk-gcktsbxb.js +0 -77
  190. package/dist/chunk-gdwdqewd.js +0 -19
  191. package/dist/chunk-gg55fns0.js +0 -6440
  192. package/dist/chunk-gnpt1t6q.js +0 -209364
  193. package/dist/chunk-gsbw2j2b.js +0 -276
  194. package/dist/chunk-gybt680f.js +0 -9114
  195. package/dist/chunk-gz1e8y1w.js +0 -33
  196. package/dist/chunk-gz7vn2gg.js +0 -114
  197. package/dist/chunk-h0d5eat0.js +0 -101
  198. package/dist/chunk-h27tjbp3.js +0 -33118
  199. package/dist/chunk-h2yy8k4c.js +0 -58
  200. package/dist/chunk-h5acpdqt.js +0 -103
  201. package/dist/chunk-h63r8vps.js +0 -2840
  202. package/dist/chunk-h64x5b04.js +0 -860
  203. package/dist/chunk-h92snc84.js +0 -420
  204. package/dist/chunk-h9n54swm.js +0 -27
  205. package/dist/chunk-hafcrnpc.js +0 -145
  206. package/dist/chunk-hakdhagh.js +0 -16606
  207. package/dist/chunk-hk4phsaw.js +0 -388
  208. package/dist/chunk-hph1bmqw.js +0 -65
  209. package/dist/chunk-hvnztnp3.js +0 -71
  210. package/dist/chunk-hwfknpxv.js +0 -39
  211. package/dist/chunk-j2xxd002.js +0 -1052
  212. package/dist/chunk-j3qbygme.js +0 -105
  213. package/dist/chunk-j5bth84e.js +0 -97
  214. package/dist/chunk-j64ga6ta.js +0 -8035
  215. package/dist/chunk-jbwgyskk.js +0 -385
  216. package/dist/chunk-jd32zbps.js +0 -15
  217. package/dist/chunk-jdhkh2bb.js +0 -618
  218. package/dist/chunk-jeqcwgt7.js +0 -177
  219. package/dist/chunk-jf75p9ap.js +0 -445
  220. package/dist/chunk-jgvk0za1.js +0 -260
  221. package/dist/chunk-jhpaevah.js +0 -565
  222. package/dist/chunk-jmjwrbwd.js +0 -635
  223. package/dist/chunk-jpdbfwvq.js +0 -100
  224. package/dist/chunk-jps4m6sz.js +0 -183
  225. package/dist/chunk-jwf0s51s.js +0 -867
  226. package/dist/chunk-jxge4dgh.js +0 -83
  227. package/dist/chunk-jz71gv95.js +0 -1161
  228. package/dist/chunk-jzthz1bx.js +0 -15
  229. package/dist/chunk-jzvd2ycp.js +0 -120
  230. package/dist/chunk-k0p9w03v.js +0 -4957
  231. package/dist/chunk-k4dcreh0.js +0 -442
  232. package/dist/chunk-k7akhwkn.js +0 -151
  233. package/dist/chunk-k8vp0atq.js +0 -2331
  234. package/dist/chunk-kgd7gfvk.js +0 -407
  235. package/dist/chunk-km5ycg1j.js +0 -87
  236. package/dist/chunk-kvyrxzj8.js +0 -26
  237. package/dist/chunk-kwekc97v.js +0 -18
  238. package/dist/chunk-ky1z78ve.js +0 -119
  239. package/dist/chunk-mcws22k3.js +0 -42
  240. package/dist/chunk-mjazvyd8.js +0 -528
  241. package/dist/chunk-mswx2nma.js +0 -103
  242. package/dist/chunk-mz6a0phh.js +0 -2962
  243. package/dist/chunk-n2tg12hg.js +0 -374
  244. package/dist/chunk-n3fv4ya7.js +0 -146
  245. package/dist/chunk-n4eabmqd.js +0 -93
  246. package/dist/chunk-n4tx7baq.js +0 -193
  247. package/dist/chunk-n6g4jbeh.js +0 -289
  248. package/dist/chunk-n6wzfxf1.js +0 -100
  249. package/dist/chunk-ndcmqfkv.js +0 -244
  250. package/dist/chunk-netzwgv1.js +0 -154
  251. package/dist/chunk-nhcg04jt.js +0 -120
  252. package/dist/chunk-nhsm3ntd.js +0 -439
  253. package/dist/chunk-njev89d1.js +0 -2335
  254. package/dist/chunk-nmgj86tt.js +0 -24
  255. package/dist/chunk-ns7x6xam.js +0 -22820
  256. package/dist/chunk-p7vkh4wx.js +0 -15
  257. package/dist/chunk-p8na2wwp.js +0 -14
  258. package/dist/chunk-p97fd5af.js +0 -684
  259. package/dist/chunk-pe3rkfp2.js +0 -74
  260. package/dist/chunk-pgtnj1mt.js +0 -705
  261. package/dist/chunk-phmnkw9y.js +0 -283
  262. package/dist/chunk-pnds7g1q.js +0 -130
  263. package/dist/chunk-ppwjyveh.js +0 -8
  264. package/dist/chunk-pqqxdk5f.js +0 -543
  265. package/dist/chunk-ps49ymvj.js +0 -43
  266. package/dist/chunk-pwwa7s62.js +0 -11
  267. package/dist/chunk-q3hfrat2.js +0 -313
  268. package/dist/chunk-qajrkk97.js +0 -298
  269. package/dist/chunk-qatfdxvd.js +0 -34
  270. package/dist/chunk-qb5qcctj.js +0 -206
  271. package/dist/chunk-qb6k2afy.js +0 -153
  272. package/dist/chunk-qgk93a75.js +0 -85
  273. package/dist/chunk-qkczt8cr.js +0 -24
  274. package/dist/chunk-qn1be1vf.js +0 -267
  275. package/dist/chunk-qnfx3qtx.js +0 -617
  276. package/dist/chunk-qnwne2m4.js +0 -87
  277. package/dist/chunk-qp2qdcda.js +0 -100
  278. package/dist/chunk-qpp3wwh5.js +0 -697
  279. package/dist/chunk-r0bx1gc7.js +0 -174
  280. package/dist/chunk-radnwk8x.js +0 -107
  281. package/dist/chunk-rkv5jq0y.js +0 -71
  282. package/dist/chunk-rmbbmd3s.js +0 -68
  283. package/dist/chunk-rmgbs5an.js +0 -640
  284. package/dist/chunk-rn0v1hk8.js +0 -34
  285. package/dist/chunk-rnxctq9p.js +0 -1646
  286. package/dist/chunk-rtd39n81.js +0 -95
  287. package/dist/chunk-s8gy4ky9.js +0 -122
  288. package/dist/chunk-s8kj6ajy.js +0 -32
  289. package/dist/chunk-sd36yzx8.js +0 -954
  290. package/dist/chunk-sdenh194.js +0 -121
  291. package/dist/chunk-sdtqp75c.js +0 -55
  292. package/dist/chunk-sedbc8ep.js +0 -212
  293. package/dist/chunk-sfrb15b2.js +0 -321
  294. package/dist/chunk-sgpmpn90.js +0 -35
  295. package/dist/chunk-sh02d2qn.js +0 -38
  296. package/dist/chunk-shd4yhsf.js +0 -32
  297. package/dist/chunk-shkycj1q.js +0 -178
  298. package/dist/chunk-sk7h93je.js +0 -153
  299. package/dist/chunk-sm8g6fsm.js +0 -122
  300. package/dist/chunk-snrjy66h.js +0 -671
  301. package/dist/chunk-sq4a0yjh.js +0 -116
  302. package/dist/chunk-sr3t4thh.js +0 -895
  303. package/dist/chunk-srj6qnf6.js +0 -107
  304. package/dist/chunk-sz62n77p.js +0 -155
  305. package/dist/chunk-szj5wvdy.js +0 -28
  306. package/dist/chunk-t29a6zb5.js +0 -45
  307. package/dist/chunk-t2ecddwj.js +0 -731
  308. package/dist/chunk-t33hmmmm.js +0 -113
  309. package/dist/chunk-t4khqff1.js +0 -16
  310. package/dist/chunk-t9p85zff.js +0 -24
  311. package/dist/chunk-ta3jyvxs.js +0 -984
  312. package/dist/chunk-tkx5eec8.js +0 -54
  313. package/dist/chunk-v1kzp02e.js +0 -785
  314. package/dist/chunk-v4t6dyyh.js +0 -9076
  315. package/dist/chunk-v78fj8by.js +0 -145
  316. package/dist/chunk-v8kjswxt.js +0 -61
  317. package/dist/chunk-v9smspw2.js +0 -4301
  318. package/dist/chunk-vf612n57.js +0 -472
  319. package/dist/chunk-vkhrrvfq.js +0 -44
  320. package/dist/chunk-vt5wm07k.js +0 -74
  321. package/dist/chunk-vvvrv61g.js +0 -875
  322. package/dist/chunk-vyjeh50y.js +0 -2149
  323. package/dist/chunk-w0kxcv73.js +0 -97
  324. package/dist/chunk-w6m6trzq.js +0 -58
  325. package/dist/chunk-wa8yn2p0.js +0 -2007
  326. package/dist/chunk-wb18cecv.js +0 -995
  327. package/dist/chunk-wgk9sxk7.js +0 -329
  328. package/dist/chunk-wh0ev1bw.js +0 -111
  329. package/dist/chunk-wka1647p.js +0 -98
  330. package/dist/chunk-wnwfwyj4.js +0 -90
  331. package/dist/chunk-wpdchyy2.js +0 -97
  332. package/dist/chunk-x3g44n7k.js +0 -114
  333. package/dist/chunk-x47h283a.js +0 -56
  334. package/dist/chunk-x6r4v44b.js +0 -8
  335. package/dist/chunk-x7fdwq3d.js +0 -33
  336. package/dist/chunk-x8d2ehd7.js +0 -19
  337. package/dist/chunk-xbeg2hej.js +0 -257
  338. package/dist/chunk-xeb6075z.js +0 -3435
  339. package/dist/chunk-xhfmdq1y.js +0 -147
  340. package/dist/chunk-xhscn33a.js +0 -138
  341. package/dist/chunk-xv3era3s.js +0 -8
  342. package/dist/chunk-xz5gbhc3.js +0 -93
  343. package/dist/chunk-y1784krc.js +0 -19
  344. package/dist/chunk-y1vyezct.js +0 -123
  345. package/dist/chunk-y45ecntg.js +0 -942
  346. package/dist/chunk-y4ca9kqz.js +0 -3830
  347. package/dist/chunk-y9bhjjdz.js +0 -145
  348. package/dist/chunk-yb3bxv3w.js +0 -30
  349. package/dist/chunk-ye2q9gqj.js +0 -332
  350. package/dist/chunk-yfg3adfq.js +0 -88
  351. package/dist/chunk-yst0wmgw.js +0 -269
  352. package/dist/chunk-ywe9dbnz.js +0 -460
  353. package/dist/chunk-yyex5gsf.js +0 -269
  354. package/dist/chunk-yz2kzqk5.js +0 -439
  355. package/dist/chunk-z263ehpg.js +0 -131
  356. package/dist/chunk-z2dp53wn.js +0 -17
  357. package/dist/chunk-zaq348h2.js +0 -281
  358. package/dist/chunk-zr0qx9q0.js +0 -642
  359. package/dist/chunk-zxh62ved.js +0 -31
  360. package/dist/chunk-zy5vn8sd.js +0 -329
  361. package/dist/chunk-zzm33q8x.js +0 -8
  362. package/dist/cli.js +0 -91
@@ -1,1543 +0,0 @@
1
- // @bun
2
- import {
3
- getProxyFetchOptions,
4
- init_proxy
5
- } from "./chunk-pgtnj1mt.js";
6
- import {
7
- LIGHTNING_BOLT,
8
- capitalize,
9
- getAnthropicApiKey,
10
- getApiKeyFromApiKeyHelper,
11
- getFeatureValue_CACHED_MAY_BE_STALE,
12
- getGlobalConfig,
13
- getInitialSettings,
14
- getSettingsForSource,
15
- getSettings_DEPRECATED,
16
- getUserAgent,
17
- init_auth,
18
- init_config,
19
- init_figures,
20
- init_growthbook,
21
- init_http,
22
- init_isEqual,
23
- init_settings1 as init_settings,
24
- init_stringUtils,
25
- isEqual_default,
26
- saveGlobalConfig,
27
- updateSettingsForSource
28
- } from "./chunk-dfq6pbq7.js";
29
- import {
30
- init_json,
31
- safeParseJSON
32
- } from "./chunk-rnxctq9p.js";
33
- import {
34
- init_lazySchema,
35
- lazySchema
36
- } from "./chunk-64c1avct.js";
37
- import {
38
- init_v4
39
- } from "./chunk-4pbx3g7s.js";
40
- import {
41
- exports_external
42
- } from "./chunk-26wtxbdc.js";
43
- import {
44
- getApiConfig,
45
- init_apiConfig,
46
- init_bundledMode,
47
- isInBundledMode
48
- } from "./chunk-5ekyhb1w.js";
49
- import {
50
- init_analytics,
51
- logEvent
52
- } from "./chunk-x8d2ehd7.js";
53
- import {
54
- Anthropic,
55
- init_debug,
56
- init_privacyLevel,
57
- init_sdk,
58
- init_slowOperations,
59
- isDebugToStdErr,
60
- isEssentialTrafficOnly,
61
- jsonStringify,
62
- logForDebugging
63
- } from "./chunk-gg55fns0.js";
64
- import {
65
- getClaudeConfigHomeDir,
66
- init_envUtils,
67
- isEnvTruthy
68
- } from "./chunk-5n1jc02d.js";
69
- import {
70
- createSignal,
71
- getIsNonInteractiveSession,
72
- getKairosActive,
73
- getMainLoopModelOverride,
74
- getModelStrings,
75
- getSessionId,
76
- init_signal,
77
- init_state,
78
- preferThirdPartyAuthentication,
79
- setHasUnknownModelCost,
80
- setModelStrings
81
- } from "./chunk-k8vp0atq.js";
82
- import {
83
- init_memoize,
84
- memoize_default
85
- } from "./chunk-vf612n57.js";
86
- import {
87
- axios_default,
88
- init_axios
89
- } from "./chunk-55raexh7.js";
90
- import {
91
- __esm
92
- } from "./chunk-qp2qdcda.js";
93
-
94
- // src/utils/model/providers.ts
95
- function getAPIProvider() {
96
- const modelType = getInitialSettings().modelType;
97
- if (modelType === "openai")
98
- return "openai";
99
- if (isEnvTruthy(process.env.CLAUDE_CODE_USE_OPENAI))
100
- return "openai";
101
- return "firstParty";
102
- }
103
- function getAPIProviderForStatsig() {
104
- return getAPIProvider();
105
- }
106
- function isFirstPartyAnthropicBaseUrl() {
107
- if (getAPIProvider() !== "firstParty")
108
- return false;
109
- const baseUrl = process.env.ANTHROPIC_BASE_URL;
110
- if (!baseUrl) {
111
- return true;
112
- }
113
- try {
114
- const host = new URL(baseUrl).host;
115
- const allowedHosts = ["api.anthropic.com"];
116
- if (process.env.USER_TYPE === "ant") {
117
- allowedHosts.push("api-staging.anthropic.com");
118
- }
119
- return allowedHosts.includes(host);
120
- } catch {
121
- return false;
122
- }
123
- }
124
- var init_providers = __esm(() => {
125
- init_settings();
126
- init_envUtils();
127
- });
128
-
129
- // src/services/api/client.ts
130
- import { randomUUID } from "crypto";
131
- function createStderrLogger() {
132
- return {
133
- error: (msg, ...args) => console.error("[Anthropic SDK ERROR]", msg, ...args),
134
- warn: (msg, ...args) => console.error("[Anthropic SDK WARN]", msg, ...args),
135
- info: (msg, ...args) => console.error("[Anthropic SDK INFO]", msg, ...args),
136
- debug: (msg, ...args) => console.error("[Anthropic SDK DEBUG]", msg, ...args)
137
- };
138
- }
139
- async function getAnthropicClient({
140
- apiKey,
141
- maxRetries,
142
- model,
143
- fetchOverride,
144
- source
145
- }) {
146
- const containerId = process.env.CLAUDE_CODE_CONTAINER_ID;
147
- const remoteSessionId = process.env.CLAUDE_CODE_REMOTE_SESSION_ID;
148
- const clientApp = process.env.CLAUDE_AGENT_SDK_CLIENT_APP;
149
- const customHeaders = getCustomHeaders();
150
- const defaultHeaders = {
151
- "x-app": "cli",
152
- "User-Agent": getUserAgent(),
153
- "X-Claude-Code-Session-Id": getSessionId(),
154
- ...customHeaders,
155
- ...containerId ? { "x-claude-remote-container-id": containerId } : {},
156
- ...remoteSessionId ? { "x-claude-remote-session-id": remoteSessionId } : {},
157
- ...clientApp ? { "x-client-app": clientApp } : {}
158
- };
159
- logForDebugging(`[API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: ${!!process.env.ANTHROPIC_CUSTOM_HEADERS}, has Authorization header: ${!!customHeaders["Authorization"]}`);
160
- const additionalProtectionEnabled = isEnvTruthy(process.env.CLAUDE_CODE_ADDITIONAL_PROTECTION);
161
- if (additionalProtectionEnabled) {
162
- defaultHeaders["x-anthropic-additional-protection"] = "true";
163
- }
164
- logForDebugging("[API:auth] Configuring API key headers");
165
- await configureApiKeyHeaders(defaultHeaders, getIsNonInteractiveSession());
166
- const resolvedFetch = buildFetch(fetchOverride, source);
167
- const ARGS = {
168
- defaultHeaders,
169
- maxRetries,
170
- timeout: parseInt(process.env.API_TIMEOUT_MS || String(600 * 1000), 10),
171
- dangerouslyAllowBrowser: true,
172
- fetchOptions: getProxyFetchOptions({
173
- forAnthropicAPI: true
174
- }),
175
- ...resolvedFetch && {
176
- fetch: resolvedFetch
177
- }
178
- };
179
- const clientConfig = {
180
- apiKey: apiKey || getAnthropicApiKey(),
181
- ...ARGS,
182
- ...isDebugToStdErr() && { logger: createStderrLogger() }
183
- };
184
- return new Anthropic(clientConfig);
185
- }
186
- async function configureApiKeyHeaders(headers, isNonInteractiveSession) {
187
- const token = process.env.ANTHROPIC_AUTH_TOKEN || await getApiKeyFromApiKeyHelper(isNonInteractiveSession);
188
- if (token) {
189
- headers["Authorization"] = `Bearer ${token}`;
190
- }
191
- }
192
- function getCustomHeaders() {
193
- const customHeaders = {};
194
- const customHeadersEnv = process.env.ANTHROPIC_CUSTOM_HEADERS;
195
- if (!customHeadersEnv)
196
- return customHeaders;
197
- const headerStrings = customHeadersEnv.split(/\n|\r\n/);
198
- for (const headerString of headerStrings) {
199
- if (!headerString.trim())
200
- continue;
201
- const colonIdx = headerString.indexOf(":");
202
- if (colonIdx === -1)
203
- continue;
204
- const name = headerString.slice(0, colonIdx).trim();
205
- const value = headerString.slice(colonIdx + 1).trim();
206
- if (name) {
207
- customHeaders[name] = value;
208
- }
209
- }
210
- return customHeaders;
211
- }
212
- function buildFetch(fetchOverride, source) {
213
- const inner = fetchOverride ?? globalThis.fetch;
214
- const injectClientRequestId = getAPIProvider() === "firstParty" && isFirstPartyAnthropicBaseUrl();
215
- return (input, init) => {
216
- const headers = new Headers(init?.headers);
217
- if (injectClientRequestId && !headers.has(CLIENT_REQUEST_ID_HEADER)) {
218
- headers.set(CLIENT_REQUEST_ID_HEADER, randomUUID());
219
- }
220
- try {
221
- const url = input instanceof Request ? input.url : String(input);
222
- const id = headers.get(CLIENT_REQUEST_ID_HEADER);
223
- logForDebugging(`[API REQUEST] ${new URL(url).pathname}${id ? ` ${CLIENT_REQUEST_ID_HEADER}=${id}` : ""} source=${source ?? "unknown"}`);
224
- } catch {}
225
- return inner(input, { ...init, headers });
226
- };
227
- }
228
- var CLIENT_REQUEST_ID_HEADER = "x-client-request-id";
229
- var init_client = __esm(() => {
230
- init_sdk();
231
- init_auth();
232
- init_http();
233
- init_providers();
234
- init_proxy();
235
- init_state();
236
- init_debug();
237
- init_envUtils();
238
- });
239
-
240
- // src/utils/model/modelCapabilities.ts
241
- import { readFileSync } from "fs";
242
- import { mkdir, writeFile } from "fs/promises";
243
- import { join } from "path";
244
- function getCacheDir() {
245
- return join(getClaudeConfigHomeDir(), "cache");
246
- }
247
- function getCachePath() {
248
- return join(getCacheDir(), "model-capabilities.json");
249
- }
250
- function isModelCapabilitiesEligible() {
251
- if (process.env.USER_TYPE !== "ant")
252
- return false;
253
- if (getAPIProvider() !== "firstParty")
254
- return false;
255
- if (!isFirstPartyAnthropicBaseUrl())
256
- return false;
257
- return true;
258
- }
259
- function sortForMatching(models) {
260
- return [...models].sort((a, b) => b.id.length - a.id.length || a.id.localeCompare(b.id));
261
- }
262
- function getModelCapability(model) {
263
- if (!isModelCapabilitiesEligible())
264
- return;
265
- const cached = loadCache(getCachePath());
266
- if (!cached || cached.length === 0)
267
- return;
268
- const m = model.toLowerCase();
269
- const exact = cached.find((c) => c.id.toLowerCase() === m);
270
- if (exact)
271
- return exact;
272
- return cached.find((c) => m.includes(c.id.toLowerCase()));
273
- }
274
- async function refreshModelCapabilities() {
275
- if (!isModelCapabilitiesEligible())
276
- return;
277
- if (isEssentialTrafficOnly())
278
- return;
279
- try {
280
- const anthropic = await getAnthropicClient({ maxRetries: 1 });
281
- const betas = undefined;
282
- const parsed = [];
283
- for await (const entry of anthropic.models.list({ betas })) {
284
- const result = ModelCapabilitySchema().safeParse(entry);
285
- if (result.success)
286
- parsed.push(result.data);
287
- }
288
- if (parsed.length === 0)
289
- return;
290
- const path = getCachePath();
291
- const models = sortForMatching(parsed);
292
- if (isEqual_default(loadCache(path), models)) {
293
- logForDebugging("[modelCapabilities] cache unchanged, skipping write");
294
- return;
295
- }
296
- await mkdir(getCacheDir(), { recursive: true });
297
- await writeFile(path, jsonStringify({ models, timestamp: Date.now() }), {
298
- encoding: "utf-8",
299
- mode: 384
300
- });
301
- loadCache.cache.delete(path);
302
- logForDebugging(`[modelCapabilities] cached ${models.length} models`);
303
- } catch (error) {
304
- logForDebugging(`[modelCapabilities] fetch failed: ${error instanceof Error ? error.message : "unknown"}`);
305
- }
306
- }
307
- var ModelCapabilitySchema, CacheFileSchema, loadCache;
308
- var init_modelCapabilities = __esm(() => {
309
- init_isEqual();
310
- init_memoize();
311
- init_v4();
312
- init_client();
313
- init_debug();
314
- init_envUtils();
315
- init_json();
316
- init_lazySchema();
317
- init_privacyLevel();
318
- init_slowOperations();
319
- init_providers();
320
- ModelCapabilitySchema = lazySchema(() => exports_external.object({
321
- id: exports_external.string(),
322
- max_input_tokens: exports_external.number().optional(),
323
- max_tokens: exports_external.number().optional()
324
- }).strip());
325
- CacheFileSchema = lazySchema(() => exports_external.object({
326
- models: exports_external.array(ModelCapabilitySchema()),
327
- timestamp: exports_external.number()
328
- }));
329
- loadCache = memoize_default((path) => {
330
- try {
331
- const raw = readFileSync(path, "utf-8");
332
- const parsed = CacheFileSchema().safeParse(safeParseJSON(raw, false));
333
- return parsed.success ? parsed.data.models : null;
334
- } catch {
335
- return null;
336
- }
337
- }, (path) => path);
338
- });
339
-
340
- // src/constants/betas.ts
341
- var CLAUDE_CODE_20250219_BETA_HEADER = "claude-code-20250219", INTERLEAVED_THINKING_BETA_HEADER = "interleaved-thinking-2025-05-14", CONTEXT_1M_BETA_HEADER = "context-1m-2025-08-07", CONTEXT_MANAGEMENT_BETA_HEADER = "context-management-2025-06-27", STRUCTURED_OUTPUTS_BETA_HEADER = "structured-outputs-2025-12-15", TOOL_SEARCH_BETA_HEADER_1P = "advanced-tool-use-2025-11-20", EFFORT_BETA_HEADER = "effort-2025-11-24", TASK_BUDGETS_BETA_HEADER = "task-budgets-2026-03-13", PROMPT_CACHING_SCOPE_BETA_HEADER = "prompt-caching-scope-2026-01-05", FAST_MODE_BETA_HEADER = "fast-mode-2026-02-01", REDACT_THINKING_BETA_HEADER = "redact-thinking-2026-02-12", TOKEN_EFFICIENT_TOOLS_BETA_HEADER = "token-efficient-tools-2026-03-28", AFK_MODE_BETA_HEADER = "", CLI_INTERNAL_BETA_HEADER, ADVISOR_BETA_HEADER = "advisor-tool-2026-03-01";
342
- var init_betas = __esm(() => {
343
- CLI_INTERNAL_BETA_HEADER = process.env.USER_TYPE === "ant" ? "cli-internal-2026-02-09" : "";
344
- });
345
-
346
- // src/utils/model/antModels.ts
347
- function getAntModelOverrideConfig() {
348
- if (process.env.USER_TYPE !== "ant") {
349
- return null;
350
- }
351
- return getFeatureValue_CACHED_MAY_BE_STALE("tengu_ant_model_override", null);
352
- }
353
- function getAntModels() {
354
- if (process.env.USER_TYPE !== "ant") {
355
- return [];
356
- }
357
- return getAntModelOverrideConfig()?.antModels ?? [];
358
- }
359
- function resolveAntModel(model) {
360
- if (process.env.USER_TYPE !== "ant") {
361
- return;
362
- }
363
- if (model === undefined) {
364
- return;
365
- }
366
- const lower = model.toLowerCase();
367
- return getAntModels().find((m) => m.alias === model || lower.includes(m.model.toLowerCase()));
368
- }
369
- var init_antModels = __esm(() => {
370
- init_growthbook();
371
- });
372
-
373
- // src/utils/model/configs.ts
374
- var CLAUDE_3_7_SONNET_CONFIG, CLAUDE_3_5_V2_SONNET_CONFIG, CLAUDE_3_5_HAIKU_CONFIG, CLAUDE_HAIKU_4_5_CONFIG, CLAUDE_SONNET_4_CONFIG, CLAUDE_SONNET_4_5_CONFIG, CLAUDE_OPUS_4_CONFIG, CLAUDE_OPUS_4_1_CONFIG, CLAUDE_OPUS_4_5_CONFIG, CLAUDE_OPUS_4_6_CONFIG, CLAUDE_SONNET_4_6_CONFIG, ALL_MODEL_CONFIGS, CANONICAL_MODEL_IDS, CANONICAL_ID_TO_KEY;
375
- var init_configs = __esm(() => {
376
- CLAUDE_3_7_SONNET_CONFIG = {
377
- firstParty: "claude-3-7-sonnet-20250219",
378
- openai: "claude-3-7-sonnet-20250219"
379
- };
380
- CLAUDE_3_5_V2_SONNET_CONFIG = {
381
- firstParty: "claude-3-5-sonnet-20241022",
382
- openai: "claude-3-5-sonnet-20241022"
383
- };
384
- CLAUDE_3_5_HAIKU_CONFIG = {
385
- firstParty: "claude-3-5-haiku-20241022",
386
- openai: "claude-3-5-haiku-20241022"
387
- };
388
- CLAUDE_HAIKU_4_5_CONFIG = {
389
- firstParty: "claude-haiku-4-5-20251001",
390
- openai: "claude-haiku-4-5-20251001"
391
- };
392
- CLAUDE_SONNET_4_CONFIG = {
393
- firstParty: "claude-sonnet-4-20250514",
394
- openai: "claude-sonnet-4-20250514"
395
- };
396
- CLAUDE_SONNET_4_5_CONFIG = {
397
- firstParty: "claude-sonnet-4-5-20250929",
398
- openai: "claude-sonnet-4-5-20250929"
399
- };
400
- CLAUDE_OPUS_4_CONFIG = {
401
- firstParty: "claude-opus-4-20250514",
402
- openai: "claude-opus-4-20250514"
403
- };
404
- CLAUDE_OPUS_4_1_CONFIG = {
405
- firstParty: "claude-opus-4-1-20250805",
406
- openai: "claude-opus-4-1-20250805"
407
- };
408
- CLAUDE_OPUS_4_5_CONFIG = {
409
- firstParty: "claude-opus-4-5-20251101",
410
- openai: "claude-opus-4-5-20251101"
411
- };
412
- CLAUDE_OPUS_4_6_CONFIG = {
413
- firstParty: "claude-opus-4-6",
414
- openai: "claude-opus-4-6"
415
- };
416
- CLAUDE_SONNET_4_6_CONFIG = {
417
- firstParty: "claude-sonnet-4-6",
418
- openai: "claude-sonnet-4-6"
419
- };
420
- ALL_MODEL_CONFIGS = {
421
- haiku35: CLAUDE_3_5_HAIKU_CONFIG,
422
- haiku45: CLAUDE_HAIKU_4_5_CONFIG,
423
- sonnet35: CLAUDE_3_5_V2_SONNET_CONFIG,
424
- sonnet37: CLAUDE_3_7_SONNET_CONFIG,
425
- sonnet40: CLAUDE_SONNET_4_CONFIG,
426
- sonnet45: CLAUDE_SONNET_4_5_CONFIG,
427
- sonnet46: CLAUDE_SONNET_4_6_CONFIG,
428
- opus40: CLAUDE_OPUS_4_CONFIG,
429
- opus41: CLAUDE_OPUS_4_1_CONFIG,
430
- opus45: CLAUDE_OPUS_4_5_CONFIG,
431
- opus46: CLAUDE_OPUS_4_6_CONFIG
432
- };
433
- CANONICAL_MODEL_IDS = Object.values(ALL_MODEL_CONFIGS).map((c) => c.firstParty);
434
- CANONICAL_ID_TO_KEY = Object.fromEntries(Object.entries(ALL_MODEL_CONFIGS).map(([key, cfg]) => [cfg.firstParty, key]));
435
- });
436
-
437
- // src/utils/model/modelStrings.ts
438
- function getBuiltinModelStrings(provider) {
439
- const out = {};
440
- for (const key of MODEL_KEYS) {
441
- out[key] = ALL_MODEL_CONFIGS[key][provider];
442
- }
443
- return out;
444
- }
445
- function applyModelOverrides(ms) {
446
- const overrides = getInitialSettings().modelOverrides;
447
- if (!overrides) {
448
- return ms;
449
- }
450
- const out = { ...ms };
451
- for (const [canonicalId, override] of Object.entries(overrides)) {
452
- const key = CANONICAL_ID_TO_KEY[canonicalId];
453
- if (key && override) {
454
- out[key] = override;
455
- }
456
- }
457
- return out;
458
- }
459
- function resolveOverriddenModel(modelId) {
460
- let overrides;
461
- try {
462
- overrides = getInitialSettings().modelOverrides;
463
- } catch {
464
- return modelId;
465
- }
466
- if (!overrides) {
467
- return modelId;
468
- }
469
- for (const [canonicalId, override] of Object.entries(overrides)) {
470
- if (override === modelId) {
471
- return canonicalId;
472
- }
473
- }
474
- return modelId;
475
- }
476
- function initModelStrings() {
477
- const ms = getModelStrings();
478
- if (ms !== null) {
479
- return;
480
- }
481
- setModelStrings(getBuiltinModelStrings(getAPIProvider()));
482
- }
483
- function getModelStrings2() {
484
- const ms = getModelStrings();
485
- if (ms === null) {
486
- initModelStrings();
487
- return applyModelOverrides(getBuiltinModelStrings(getAPIProvider()));
488
- }
489
- return applyModelOverrides(ms);
490
- }
491
- async function ensureModelStringsInitialized() {
492
- const ms = getModelStrings();
493
- if (ms !== null) {
494
- return;
495
- }
496
- setModelStrings(getBuiltinModelStrings(getAPIProvider()));
497
- }
498
- var MODEL_KEYS;
499
- var init_modelStrings = __esm(() => {
500
- init_state();
501
- init_settings();
502
- init_configs();
503
- init_providers();
504
- MODEL_KEYS = Object.keys(ALL_MODEL_CONFIGS);
505
- });
506
-
507
- // src/utils/fastMode.ts
508
- function isFastModeEnabled() {
509
- return !isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_FAST_MODE);
510
- }
511
- function isFastModeAvailable() {
512
- if (!isFastModeEnabled()) {
513
- return false;
514
- }
515
- return getFastModeUnavailableReason() === null;
516
- }
517
- function getDisabledReasonMessage(disabledReason) {
518
- switch (disabledReason) {
519
- case "free":
520
- return "Fast mode unavailable during evaluation. Please purchase credits.";
521
- case "preference":
522
- return "Fast mode has been disabled by your organization";
523
- case "extra_usage_disabled":
524
- return "Fast mode requires extra usage billing \xB7 /extra-usage to enable";
525
- case "network_error":
526
- return "Fast mode unavailable due to network connectivity issues";
527
- case "unknown":
528
- return "Fast mode is currently unavailable";
529
- }
530
- }
531
- function getFastModeUnavailableReason() {
532
- if (!isFastModeEnabled()) {
533
- return "Fast mode is not available";
534
- }
535
- const statigReason = getFeatureValue_CACHED_MAY_BE_STALE("tengu_penguins_off", null);
536
- if (statigReason !== null) {
537
- logForDebugging(`Fast mode unavailable: ${statigReason}`);
538
- return statigReason;
539
- }
540
- if (!isInBundledMode() && getFeatureValue_CACHED_MAY_BE_STALE("tengu_marble_sandcastle", false)) {
541
- return "Fast mode requires the native binary \xB7 Install from: https://claude.com/product/claude-code";
542
- }
543
- if (getIsNonInteractiveSession() && preferThirdPartyAuthentication() && !getKairosActive()) {
544
- const flagFastMode = getSettingsForSource("flagSettings")?.fastMode;
545
- if (!flagFastMode) {
546
- const reason = "Fast mode is not available in the Agent SDK";
547
- logForDebugging(`Fast mode unavailable: ${reason}`);
548
- return reason;
549
- }
550
- }
551
- if (getAPIProvider() !== "firstParty") {
552
- const reason = "Fast mode is not available on Bedrock, Vertex, or Foundry";
553
- logForDebugging(`Fast mode unavailable: ${reason}`);
554
- return reason;
555
- }
556
- if (orgStatus.status === "disabled") {
557
- if (orgStatus.reason === "network_error" || orgStatus.reason === "unknown") {
558
- if (isEnvTruthy(process.env.CLAUDE_CODE_SKIP_FAST_MODE_NETWORK_ERRORS)) {
559
- return null;
560
- }
561
- }
562
- const reason = getDisabledReasonMessage(orgStatus.reason);
563
- logForDebugging(`Fast mode unavailable: ${reason}`);
564
- return reason;
565
- }
566
- return null;
567
- }
568
- function getFastModeModel() {
569
- return "opus" + (isOpus1mMergeEnabled() ? "[1m]" : "");
570
- }
571
- function getInitialFastModeSetting(model) {
572
- if (!isFastModeEnabled()) {
573
- return false;
574
- }
575
- if (!isFastModeAvailable()) {
576
- return false;
577
- }
578
- if (!isFastModeSupportedByModel(model)) {
579
- return false;
580
- }
581
- const settings = getInitialSettings();
582
- if (settings.fastModePerSessionOptIn) {
583
- return false;
584
- }
585
- return settings.fastMode === true;
586
- }
587
- function isFastModeSupportedByModel(modelSetting) {
588
- if (!isFastModeEnabled()) {
589
- return false;
590
- }
591
- const model = modelSetting ?? getDefaultMainLoopModelSetting();
592
- const parsedModel = parseUserSpecifiedModel(model);
593
- return parsedModel.toLowerCase().includes("opus-4-6");
594
- }
595
- function getFastModeRuntimeState() {
596
- if (runtimeState.status === "cooldown" && Date.now() >= runtimeState.resetAt) {
597
- if (isFastModeEnabled() && !hasLoggedCooldownExpiry) {
598
- logForDebugging("Fast mode cooldown expired, re-enabling fast mode");
599
- hasLoggedCooldownExpiry = true;
600
- cooldownExpired.emit();
601
- }
602
- runtimeState = { status: "active" };
603
- }
604
- return runtimeState;
605
- }
606
- function triggerFastModeCooldown(resetTimestamp, reason) {
607
- if (!isFastModeEnabled()) {
608
- return;
609
- }
610
- runtimeState = { status: "cooldown", resetAt: resetTimestamp, reason };
611
- hasLoggedCooldownExpiry = false;
612
- const cooldownDurationMs = resetTimestamp - Date.now();
613
- logForDebugging(`Fast mode cooldown triggered (${reason}), duration ${Math.round(cooldownDurationMs / 1000)}s`);
614
- logEvent("tengu_fast_mode_fallback_triggered", {
615
- cooldown_duration_ms: cooldownDurationMs,
616
- cooldown_reason: reason
617
- });
618
- cooldownTriggered.emit(resetTimestamp, reason);
619
- }
620
- function clearFastModeCooldown() {
621
- runtimeState = { status: "active" };
622
- }
623
- function handleFastModeRejectedByAPI() {
624
- if (orgStatus.status === "disabled") {
625
- return;
626
- }
627
- orgStatus = { status: "disabled", reason: "preference" };
628
- updateSettingsForSource("userSettings", { fastMode: undefined });
629
- saveGlobalConfig((current) => ({
630
- ...current,
631
- penguinModeOrgEnabled: false
632
- }));
633
- orgFastModeChange.emit(false);
634
- }
635
- function getOverageDisabledMessage(reason) {
636
- switch (reason) {
637
- case "out_of_credits":
638
- return "Fast mode disabled \xB7 extra usage credits exhausted";
639
- case "org_level_disabled":
640
- case "org_service_level_disabled":
641
- return "Fast mode disabled \xB7 extra usage disabled by your organization";
642
- case "org_level_disabled_until":
643
- return "Fast mode disabled \xB7 extra usage spending cap reached";
644
- case "member_level_disabled":
645
- return "Fast mode disabled \xB7 extra usage disabled for your account";
646
- case "seat_tier_level_disabled":
647
- case "seat_tier_zero_credit_limit":
648
- case "member_zero_credit_limit":
649
- return "Fast mode disabled \xB7 extra usage not available for your plan";
650
- case "overage_not_provisioned":
651
- case "no_limits_configured":
652
- return "Fast mode requires extra usage billing \xB7 /extra-usage to enable";
653
- default:
654
- return "Fast mode disabled \xB7 extra usage not available";
655
- }
656
- }
657
- function isOutOfCreditsReason(reason) {
658
- return reason === "org_level_disabled_until" || reason === "out_of_credits";
659
- }
660
- function handleFastModeOverageRejection(reason) {
661
- const message = getOverageDisabledMessage(reason);
662
- logForDebugging(`Fast mode overage rejection: ${reason ?? "unknown"} \u2014 ${message}`);
663
- logEvent("tengu_fast_mode_overage_rejected", {
664
- overage_disabled_reason: reason ?? "unknown"
665
- });
666
- if (!isOutOfCreditsReason(reason)) {
667
- updateSettingsForSource("userSettings", { fastMode: undefined });
668
- saveGlobalConfig((current) => ({
669
- ...current,
670
- penguinModeOrgEnabled: false
671
- }));
672
- }
673
- overageRejection.emit(message);
674
- }
675
- function isFastModeCooldown() {
676
- return getFastModeRuntimeState().status === "cooldown";
677
- }
678
- function getFastModeState(model, fastModeUserEnabled) {
679
- const enabled = isFastModeEnabled() && isFastModeAvailable() && !!fastModeUserEnabled && isFastModeSupportedByModel(model);
680
- if (enabled && isFastModeCooldown()) {
681
- return "cooldown";
682
- }
683
- if (enabled) {
684
- return "on";
685
- }
686
- return "off";
687
- }
688
- async function fetchFastModeStatus(auth) {
689
- const endpoint = `${getApiConfig().BASE_API_URL}/api/claude_code_penguin_mode`;
690
- const headers = { "x-api-key": auth.apiKey };
691
- const response = await axios_default.get(endpoint, { headers });
692
- return response.data;
693
- }
694
- function resolveFastModeStatusFromCache() {
695
- if (!isFastModeEnabled()) {
696
- return;
697
- }
698
- if (orgStatus.status !== "pending") {
699
- return;
700
- }
701
- const isAnt = process.env.USER_TYPE === "ant";
702
- const cachedEnabled = getGlobalConfig().penguinModeOrgEnabled === true;
703
- orgStatus = isAnt || cachedEnabled ? { status: "enabled" } : { status: "disabled", reason: "unknown" };
704
- }
705
- async function prefetchFastModeStatus() {
706
- if (isEssentialTrafficOnly()) {
707
- return;
708
- }
709
- if (!isFastModeEnabled()) {
710
- return;
711
- }
712
- if (inflightPrefetch) {
713
- logForDebugging("Fast mode prefetch in progress, returning in-flight promise");
714
- return inflightPrefetch;
715
- }
716
- const apiKey = getAnthropicApiKey();
717
- if (!apiKey) {
718
- const isAnt = process.env.USER_TYPE === "ant";
719
- const cachedEnabled = getGlobalConfig().penguinModeOrgEnabled === true;
720
- orgStatus = isAnt || cachedEnabled ? { status: "enabled" } : { status: "disabled", reason: "preference" };
721
- return;
722
- }
723
- const now = Date.now();
724
- if (now - lastPrefetchAt < PREFETCH_MIN_INTERVAL_MS) {
725
- logForDebugging("Skipping fast mode prefetch, fetched recently");
726
- return;
727
- }
728
- lastPrefetchAt = now;
729
- const fetchWithCurrentAuth = async () => {
730
- if (!apiKey) {
731
- throw new Error("No auth available");
732
- }
733
- return fetchFastModeStatus({ apiKey });
734
- };
735
- async function doFetch() {
736
- try {
737
- const status = await fetchWithCurrentAuth();
738
- const previousEnabled = orgStatus.status !== "pending" ? orgStatus.status === "enabled" : getGlobalConfig().penguinModeOrgEnabled;
739
- orgStatus = status.enabled ? { status: "enabled" } : {
740
- status: "disabled",
741
- reason: status.disabled_reason ?? "preference"
742
- };
743
- if (previousEnabled !== status.enabled) {
744
- if (!status.enabled) {
745
- updateSettingsForSource("userSettings", { fastMode: undefined });
746
- }
747
- saveGlobalConfig((current) => ({
748
- ...current,
749
- penguinModeOrgEnabled: status.enabled
750
- }));
751
- orgFastModeChange.emit(status.enabled);
752
- }
753
- logForDebugging(`Org fast mode: ${status.enabled ? "enabled" : `disabled (${status.disabled_reason ?? "preference"})`}`);
754
- } catch (err) {
755
- const isAnt = process.env.USER_TYPE === "ant";
756
- const cachedEnabled = getGlobalConfig().penguinModeOrgEnabled === true;
757
- orgStatus = isAnt || cachedEnabled ? { status: "enabled" } : { status: "disabled", reason: "network_error" };
758
- logForDebugging(`Failed to fetch org fast mode status, defaulting to ${orgStatus.status === "enabled" ? "enabled (cached)" : "disabled (network_error)"}: ${err}`, { level: "error" });
759
- logEvent("tengu_org_penguin_mode_fetch_failed", {});
760
- } finally {
761
- inflightPrefetch = null;
762
- }
763
- }
764
- inflightPrefetch = doFetch();
765
- return inflightPrefetch;
766
- }
767
- var FAST_MODE_MODEL_DISPLAY = "Opus 4.6", runtimeState, hasLoggedCooldownExpiry = false, cooldownTriggered, cooldownExpired, onCooldownTriggered, onCooldownExpired, overageRejection, onFastModeOverageRejection, orgStatus, orgFastModeChange, onOrgFastModeChanged, PREFETCH_MIN_INTERVAL_MS = 30000, lastPrefetchAt = 0, inflightPrefetch = null;
768
- var init_fastMode = __esm(() => {
769
- init_axios();
770
- init_apiConfig();
771
- init_growthbook();
772
- init_state();
773
- init_analytics();
774
- init_auth();
775
- init_bundledMode();
776
- init_config();
777
- init_debug();
778
- init_envUtils();
779
- init_model();
780
- init_providers();
781
- init_privacyLevel();
782
- init_settings();
783
- init_signal();
784
- runtimeState = { status: "active" };
785
- cooldownTriggered = createSignal();
786
- cooldownExpired = createSignal();
787
- onCooldownTriggered = cooldownTriggered.subscribe;
788
- onCooldownExpired = cooldownExpired.subscribe;
789
- overageRejection = createSignal();
790
- onFastModeOverageRejection = overageRejection.subscribe;
791
- orgStatus = { status: "pending" };
792
- orgFastModeChange = createSignal();
793
- onOrgFastModeChanged = orgFastModeChange.subscribe;
794
- });
795
-
796
- // src/utils/modelCost.ts
797
- function getOpus46CostTier(fastMode) {
798
- if (isFastModeEnabled() && fastMode) {
799
- return COST_TIER_30_150;
800
- }
801
- return COST_TIER_5_25;
802
- }
803
- function tokensToUSDCost(modelCosts, usage) {
804
- return usage.input_tokens / 1e6 * modelCosts.inputTokens + usage.output_tokens / 1e6 * modelCosts.outputTokens + (usage.cache_read_input_tokens ?? 0) / 1e6 * modelCosts.promptCacheReadTokens + (usage.cache_creation_input_tokens ?? 0) / 1e6 * modelCosts.promptCacheWriteTokens + (usage.server_tool_use?.web_search_requests ?? 0) * modelCosts.webSearchRequests;
805
- }
806
- function getModelCosts(model, usage) {
807
- const shortName = getCanonicalName(model);
808
- if (shortName === firstPartyNameToCanonical(CLAUDE_OPUS_4_6_CONFIG.firstParty)) {
809
- const isFastMode = usage.speed === "fast";
810
- return getOpus46CostTier(isFastMode);
811
- }
812
- const costs = MODEL_COSTS[shortName];
813
- if (!costs) {
814
- trackUnknownModelCost(model, shortName);
815
- return MODEL_COSTS[getCanonicalName(getDefaultMainLoopModelSetting())] ?? DEFAULT_UNKNOWN_MODEL_COST;
816
- }
817
- return costs;
818
- }
819
- function trackUnknownModelCost(model, shortName) {
820
- logEvent("tengu_unknown_model_cost", {
821
- model,
822
- shortName
823
- });
824
- setHasUnknownModelCost();
825
- }
826
- function calculateUSDCost(resolvedModel, usage) {
827
- const modelCosts = getModelCosts(resolvedModel, usage);
828
- return tokensToUSDCost(modelCosts, usage);
829
- }
830
- function calculateCostFromTokens(model, tokens) {
831
- const usage = {
832
- input_tokens: tokens.inputTokens,
833
- output_tokens: tokens.outputTokens,
834
- cache_read_input_tokens: tokens.cacheReadInputTokens,
835
- cache_creation_input_tokens: tokens.cacheCreationInputTokens
836
- };
837
- return calculateUSDCost(model, usage);
838
- }
839
- function formatPrice(price) {
840
- if (Number.isInteger(price)) {
841
- return `$${price}`;
842
- }
843
- return `$${price.toFixed(2)}`;
844
- }
845
- function formatModelPricing(costs) {
846
- return `${formatPrice(costs.inputTokens)}/${formatPrice(costs.outputTokens)} per Mtok`;
847
- }
848
- var COST_TIER_3_15, COST_TIER_15_75, COST_TIER_5_25, COST_TIER_30_150, COST_HAIKU_35, COST_HAIKU_45, DEFAULT_UNKNOWN_MODEL_COST, MODEL_COSTS;
849
- var init_modelCost = __esm(() => {
850
- init_analytics();
851
- init_state();
852
- init_fastMode();
853
- init_configs();
854
- init_model();
855
- COST_TIER_3_15 = {
856
- inputTokens: 3,
857
- outputTokens: 15,
858
- promptCacheWriteTokens: 3.75,
859
- promptCacheReadTokens: 0.3,
860
- webSearchRequests: 0.01
861
- };
862
- COST_TIER_15_75 = {
863
- inputTokens: 15,
864
- outputTokens: 75,
865
- promptCacheWriteTokens: 18.75,
866
- promptCacheReadTokens: 1.5,
867
- webSearchRequests: 0.01
868
- };
869
- COST_TIER_5_25 = {
870
- inputTokens: 5,
871
- outputTokens: 25,
872
- promptCacheWriteTokens: 6.25,
873
- promptCacheReadTokens: 0.5,
874
- webSearchRequests: 0.01
875
- };
876
- COST_TIER_30_150 = {
877
- inputTokens: 30,
878
- outputTokens: 150,
879
- promptCacheWriteTokens: 37.5,
880
- promptCacheReadTokens: 3,
881
- webSearchRequests: 0.01
882
- };
883
- COST_HAIKU_35 = {
884
- inputTokens: 0.8,
885
- outputTokens: 4,
886
- promptCacheWriteTokens: 1,
887
- promptCacheReadTokens: 0.08,
888
- webSearchRequests: 0.01
889
- };
890
- COST_HAIKU_45 = {
891
- inputTokens: 1,
892
- outputTokens: 5,
893
- promptCacheWriteTokens: 1.25,
894
- promptCacheReadTokens: 0.1,
895
- webSearchRequests: 0.01
896
- };
897
- DEFAULT_UNKNOWN_MODEL_COST = COST_TIER_5_25;
898
- MODEL_COSTS = {
899
- [firstPartyNameToCanonical(CLAUDE_3_5_HAIKU_CONFIG.firstParty)]: COST_HAIKU_35,
900
- [firstPartyNameToCanonical(CLAUDE_HAIKU_4_5_CONFIG.firstParty)]: COST_HAIKU_45,
901
- [firstPartyNameToCanonical(CLAUDE_3_5_V2_SONNET_CONFIG.firstParty)]: COST_TIER_3_15,
902
- [firstPartyNameToCanonical(CLAUDE_3_7_SONNET_CONFIG.firstParty)]: COST_TIER_3_15,
903
- [firstPartyNameToCanonical(CLAUDE_SONNET_4_CONFIG.firstParty)]: COST_TIER_3_15,
904
- [firstPartyNameToCanonical(CLAUDE_SONNET_4_5_CONFIG.firstParty)]: COST_TIER_3_15,
905
- [firstPartyNameToCanonical(CLAUDE_SONNET_4_6_CONFIG.firstParty)]: COST_TIER_3_15,
906
- [firstPartyNameToCanonical(CLAUDE_OPUS_4_CONFIG.firstParty)]: COST_TIER_15_75,
907
- [firstPartyNameToCanonical(CLAUDE_OPUS_4_1_CONFIG.firstParty)]: COST_TIER_15_75,
908
- [firstPartyNameToCanonical(CLAUDE_OPUS_4_5_CONFIG.firstParty)]: COST_TIER_5_25,
909
- [firstPartyNameToCanonical(CLAUDE_OPUS_4_6_CONFIG.firstParty)]: COST_TIER_5_25
910
- };
911
- });
912
-
913
- // src/utils/model/aliases.ts
914
- function isModelAlias(modelInput) {
915
- return MODEL_ALIASES.includes(modelInput);
916
- }
917
- function isModelFamilyAlias(model) {
918
- return MODEL_FAMILY_ALIASES.includes(model);
919
- }
920
- var MODEL_ALIASES, MODEL_FAMILY_ALIASES;
921
- var init_aliases = __esm(() => {
922
- MODEL_ALIASES = [
923
- "sonnet",
924
- "opus",
925
- "haiku",
926
- "best",
927
- "sonnet[1m]",
928
- "opus[1m]",
929
- "opusplan"
930
- ];
931
- MODEL_FAMILY_ALIASES = ["sonnet", "opus", "haiku"];
932
- });
933
-
934
- // src/utils/model/modelAllowlist.ts
935
- function modelBelongsToFamily(model, family) {
936
- if (model.includes(family)) {
937
- return true;
938
- }
939
- if (isModelAlias(model)) {
940
- const resolved = parseUserSpecifiedModel(model).toLowerCase();
941
- return resolved.includes(family);
942
- }
943
- return false;
944
- }
945
- function prefixMatchesModel(modelName, prefix) {
946
- if (!modelName.startsWith(prefix)) {
947
- return false;
948
- }
949
- return modelName.length === prefix.length || modelName[prefix.length] === "-";
950
- }
951
- function modelMatchesVersionPrefix(model, entry) {
952
- const resolvedModel = isModelAlias(model) ? parseUserSpecifiedModel(model).toLowerCase() : model;
953
- if (prefixMatchesModel(resolvedModel, entry)) {
954
- return true;
955
- }
956
- if (!entry.startsWith("claude-") && prefixMatchesModel(resolvedModel, `claude-${entry}`)) {
957
- return true;
958
- }
959
- return false;
960
- }
961
- function familyHasSpecificEntries(family, allowlist) {
962
- for (const entry of allowlist) {
963
- if (isModelFamilyAlias(entry)) {
964
- continue;
965
- }
966
- const idx = entry.indexOf(family);
967
- if (idx === -1) {
968
- continue;
969
- }
970
- const afterFamily = idx + family.length;
971
- if (afterFamily === entry.length || entry[afterFamily] === "-") {
972
- return true;
973
- }
974
- }
975
- return false;
976
- }
977
- function isModelAllowed(model) {
978
- const settings = getSettings_DEPRECATED() || {};
979
- const { availableModels } = settings;
980
- if (!availableModels) {
981
- return true;
982
- }
983
- if (availableModels.length === 0) {
984
- return false;
985
- }
986
- const resolvedModel = resolveOverriddenModel(model);
987
- const normalizedModel = resolvedModel.trim().toLowerCase();
988
- const normalizedAllowlist = availableModels.map((m) => m.trim().toLowerCase());
989
- if (normalizedAllowlist.includes(normalizedModel)) {
990
- if (!isModelFamilyAlias(normalizedModel) || !familyHasSpecificEntries(normalizedModel, normalizedAllowlist)) {
991
- return true;
992
- }
993
- }
994
- for (const entry of normalizedAllowlist) {
995
- if (isModelFamilyAlias(entry) && !familyHasSpecificEntries(entry, normalizedAllowlist) && modelBelongsToFamily(normalizedModel, entry)) {
996
- return true;
997
- }
998
- }
999
- if (isModelAlias(normalizedModel)) {
1000
- const resolved = parseUserSpecifiedModel(normalizedModel).toLowerCase();
1001
- if (normalizedAllowlist.includes(resolved)) {
1002
- return true;
1003
- }
1004
- }
1005
- for (const entry of normalizedAllowlist) {
1006
- if (!isModelFamilyAlias(entry) && isModelAlias(entry)) {
1007
- const resolved = parseUserSpecifiedModel(entry).toLowerCase();
1008
- if (resolved === normalizedModel) {
1009
- return true;
1010
- }
1011
- }
1012
- }
1013
- for (const entry of normalizedAllowlist) {
1014
- if (!isModelFamilyAlias(entry) && !isModelAlias(entry)) {
1015
- if (modelMatchesVersionPrefix(normalizedModel, entry)) {
1016
- return true;
1017
- }
1018
- }
1019
- }
1020
- return false;
1021
- }
1022
- var init_modelAllowlist = __esm(() => {
1023
- init_settings();
1024
- init_aliases();
1025
- init_model();
1026
- init_modelStrings();
1027
- });
1028
-
1029
- // src/utils/model/model.ts
1030
- function getSmallFastModel() {
1031
- const provider = getAPIProvider();
1032
- if (provider === "openai" && process.env.OPENAI_SMALL_FAST_MODEL) {
1033
- return process.env.OPENAI_SMALL_FAST_MODEL;
1034
- }
1035
- return process.env.ANTHROPIC_SMALL_FAST_MODEL || getDefaultHaikuModel();
1036
- }
1037
- function isNonCustomOpusModel(model) {
1038
- return model === getModelStrings2().opus40 || model === getModelStrings2().opus41 || model === getModelStrings2().opus45 || model === getModelStrings2().opus46;
1039
- }
1040
- function getUserSpecifiedModelSetting() {
1041
- let specifiedModel;
1042
- const modelOverride = getMainLoopModelOverride();
1043
- if (modelOverride !== undefined) {
1044
- specifiedModel = modelOverride;
1045
- } else {
1046
- const settings = getSettings_DEPRECATED() || {};
1047
- specifiedModel = process.env.ANTHROPIC_MODEL || settings.model || undefined;
1048
- }
1049
- if (specifiedModel && !isModelAllowed(specifiedModel)) {
1050
- return;
1051
- }
1052
- return specifiedModel;
1053
- }
1054
- function getMainLoopModel() {
1055
- const model = getUserSpecifiedModelSetting();
1056
- if (model !== undefined && model !== null) {
1057
- return parseUserSpecifiedModel(model);
1058
- }
1059
- return getDefaultMainLoopModel();
1060
- }
1061
- function getBestModel() {
1062
- return getDefaultOpusModel();
1063
- }
1064
- function getDefaultOpusModel() {
1065
- const provider = getAPIProvider();
1066
- if (provider === "openai" && process.env.OPENAI_DEFAULT_OPUS_MODEL) {
1067
- return process.env.OPENAI_DEFAULT_OPUS_MODEL;
1068
- }
1069
- if (process.env.ANTHROPIC_DEFAULT_OPUS_MODEL) {
1070
- return process.env.ANTHROPIC_DEFAULT_OPUS_MODEL;
1071
- }
1072
- return getModelStrings2().opus46;
1073
- }
1074
- function getDefaultSonnetModel() {
1075
- const provider = getAPIProvider();
1076
- if (provider === "openai" && process.env.OPENAI_DEFAULT_SONNET_MODEL) {
1077
- return process.env.OPENAI_DEFAULT_SONNET_MODEL;
1078
- }
1079
- if (process.env.ANTHROPIC_DEFAULT_SONNET_MODEL) {
1080
- return process.env.ANTHROPIC_DEFAULT_SONNET_MODEL;
1081
- }
1082
- return getModelStrings2().sonnet46;
1083
- }
1084
- function getDefaultHaikuModel() {
1085
- const provider = getAPIProvider();
1086
- if (provider === "openai" && process.env.OPENAI_DEFAULT_HAIKU_MODEL) {
1087
- return process.env.OPENAI_DEFAULT_HAIKU_MODEL;
1088
- }
1089
- if (process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL) {
1090
- return process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL;
1091
- }
1092
- return getModelStrings2().haiku45;
1093
- }
1094
- function getRuntimeMainLoopModel(params) {
1095
- const { permissionMode, mainLoopModel, exceeds200kTokens = false } = params;
1096
- if (getUserSpecifiedModelSetting() === "opusplan" && permissionMode === "plan" && !exceeds200kTokens) {
1097
- return getDefaultOpusModel();
1098
- }
1099
- if (getUserSpecifiedModelSetting() === "haiku" && permissionMode === "plan") {
1100
- return getDefaultSonnetModel();
1101
- }
1102
- return mainLoopModel;
1103
- }
1104
- function getDefaultMainLoopModelSetting() {
1105
- if (process.env.USER_TYPE === "ant") {
1106
- return getAntModelOverrideConfig()?.defaultModel ?? getDefaultOpusModel() + "[1m]";
1107
- }
1108
- if (isMaxSubscriber()) {
1109
- return getDefaultOpusModel() + (isOpus1mMergeEnabled() ? "[1m]" : "");
1110
- }
1111
- if (isTeamPremiumSubscriber()) {
1112
- return getDefaultOpusModel() + (isOpus1mMergeEnabled() ? "[1m]" : "");
1113
- }
1114
- return getDefaultSonnetModel();
1115
- }
1116
- function getDefaultMainLoopModel() {
1117
- return parseUserSpecifiedModel(getDefaultMainLoopModelSetting());
1118
- }
1119
- function firstPartyNameToCanonical(name) {
1120
- name = name.toLowerCase();
1121
- if (name.includes("claude-opus-4-6")) {
1122
- return "claude-opus-4-6";
1123
- }
1124
- if (name.includes("claude-opus-4-5")) {
1125
- return "claude-opus-4-5";
1126
- }
1127
- if (name.includes("claude-opus-4-1")) {
1128
- return "claude-opus-4-1";
1129
- }
1130
- if (name.includes("claude-opus-4")) {
1131
- return "claude-opus-4";
1132
- }
1133
- if (name.includes("claude-sonnet-4-6")) {
1134
- return "claude-sonnet-4-6";
1135
- }
1136
- if (name.includes("claude-sonnet-4-5")) {
1137
- return "claude-sonnet-4-5";
1138
- }
1139
- if (name.includes("claude-sonnet-4")) {
1140
- return "claude-sonnet-4";
1141
- }
1142
- if (name.includes("claude-haiku-4-5")) {
1143
- return "claude-haiku-4-5";
1144
- }
1145
- if (name.includes("claude-3-7-sonnet")) {
1146
- return "claude-3-7-sonnet";
1147
- }
1148
- if (name.includes("claude-3-5-sonnet")) {
1149
- return "claude-3-5-sonnet";
1150
- }
1151
- if (name.includes("claude-3-5-haiku")) {
1152
- return "claude-3-5-haiku";
1153
- }
1154
- if (name.includes("claude-3-opus")) {
1155
- return "claude-3-opus";
1156
- }
1157
- if (name.includes("claude-3-sonnet")) {
1158
- return "claude-3-sonnet";
1159
- }
1160
- if (name.includes("claude-3-haiku")) {
1161
- return "claude-3-haiku";
1162
- }
1163
- const match = name.match(/(claude-(\d+-\d+-)?\w+)/);
1164
- if (match && match[1]) {
1165
- return match[1];
1166
- }
1167
- return name;
1168
- }
1169
- function getCanonicalName(fullModelName) {
1170
- return firstPartyNameToCanonical(resolveOverriddenModel(fullModelName));
1171
- }
1172
- function getClaudeAiUserDefaultModelDescription(fastMode = false) {
1173
- if (isMaxSubscriber() || isTeamPremiumSubscriber()) {
1174
- if (isOpus1mMergeEnabled()) {
1175
- return `Opus 4.6 with 1M context \xB7 Most capable for complex work${fastMode ? getOpus46PricingSuffix(true) : ""}`;
1176
- }
1177
- return `Opus 4.6 \xB7 Most capable for complex work${fastMode ? getOpus46PricingSuffix(true) : ""}`;
1178
- }
1179
- return "Sonnet 4.6 \xB7 Best for everyday tasks";
1180
- }
1181
- function renderDefaultModelSetting(setting) {
1182
- if (setting === "opusplan") {
1183
- return "Opus 4.6 in plan mode, else Sonnet 4.6";
1184
- }
1185
- return renderModelName(parseUserSpecifiedModel(setting));
1186
- }
1187
- function getOpus46PricingSuffix(fastMode) {
1188
- if (getAPIProvider() !== "firstParty")
1189
- return "";
1190
- const pricing = formatModelPricing(getOpus46CostTier(fastMode));
1191
- const fastModeIndicator = fastMode ? ` (${LIGHTNING_BOLT})` : "";
1192
- return ` \xB7${fastModeIndicator} ${pricing}`;
1193
- }
1194
- function isOpus1mMergeEnabled() {
1195
- if (is1mContextDisabled() || isProSubscriber() || getAPIProvider() !== "firstParty") {
1196
- return false;
1197
- }
1198
- if (isClaudeAISubscriber() && getSubscriptionType() === null) {
1199
- return false;
1200
- }
1201
- return true;
1202
- }
1203
- function renderModelSetting(setting) {
1204
- if (setting === "opusplan") {
1205
- return "Opus Plan";
1206
- }
1207
- if (isModelAlias(setting)) {
1208
- return capitalize(setting);
1209
- }
1210
- return renderModelName(setting);
1211
- }
1212
- function getPublicModelDisplayName(model) {
1213
- switch (model) {
1214
- case getModelStrings2().opus46:
1215
- return "Opus 4.6";
1216
- case getModelStrings2().opus46 + "[1m]":
1217
- return "Opus 4.6 (1M context)";
1218
- case getModelStrings2().opus45:
1219
- return "Opus 4.5";
1220
- case getModelStrings2().opus41:
1221
- return "Opus 4.1";
1222
- case getModelStrings2().opus40:
1223
- return "Opus 4";
1224
- case getModelStrings2().sonnet46 + "[1m]":
1225
- return "Sonnet 4.6 (1M context)";
1226
- case getModelStrings2().sonnet46:
1227
- return "Sonnet 4.6";
1228
- case getModelStrings2().sonnet45 + "[1m]":
1229
- return "Sonnet 4.5 (1M context)";
1230
- case getModelStrings2().sonnet45:
1231
- return "Sonnet 4.5";
1232
- case getModelStrings2().sonnet40:
1233
- return "Sonnet 4";
1234
- case getModelStrings2().sonnet40 + "[1m]":
1235
- return "Sonnet 4 (1M context)";
1236
- case getModelStrings2().sonnet37:
1237
- return "Sonnet 3.7";
1238
- case getModelStrings2().sonnet35:
1239
- return "Sonnet 3.5";
1240
- case getModelStrings2().haiku45:
1241
- return "Haiku 4.5";
1242
- case getModelStrings2().haiku35:
1243
- return "Haiku 3.5";
1244
- default:
1245
- return null;
1246
- }
1247
- }
1248
- function maskModelCodename(baseName) {
1249
- const [codename = "", ...rest] = baseName.split("-");
1250
- const masked = codename.slice(0, 3) + "*".repeat(Math.max(0, codename.length - 3));
1251
- return [masked, ...rest].join("-");
1252
- }
1253
- function renderModelName(model) {
1254
- const publicName = getPublicModelDisplayName(model);
1255
- if (publicName) {
1256
- return publicName;
1257
- }
1258
- if (process.env.USER_TYPE === "ant") {
1259
- const resolved = parseUserSpecifiedModel(model);
1260
- const antModel = resolveAntModel(model);
1261
- if (antModel) {
1262
- const baseName = antModel.model.replace(/\[1m\]$/i, "");
1263
- const masked = maskModelCodename(baseName);
1264
- const suffix = has1mContext(resolved) ? "[1m]" : "";
1265
- return masked + suffix;
1266
- }
1267
- if (resolved !== model) {
1268
- return `${model} (${resolved})`;
1269
- }
1270
- return resolved;
1271
- }
1272
- return model;
1273
- }
1274
- function getPublicModelName(model) {
1275
- const publicName = getPublicModelDisplayName(model);
1276
- if (publicName) {
1277
- return `${publicName}`;
1278
- }
1279
- return `${model}`;
1280
- }
1281
- function parseUserSpecifiedModel(modelInput) {
1282
- const modelInputTrimmed = modelInput.trim();
1283
- const normalizedModel = modelInputTrimmed.toLowerCase();
1284
- const has1mTag = has1mContext(normalizedModel);
1285
- const modelString = has1mTag ? normalizedModel.replace(/\[1m]$/i, "").trim() : normalizedModel;
1286
- if (isModelAlias(modelString)) {
1287
- switch (modelString) {
1288
- case "opusplan":
1289
- return getDefaultSonnetModel() + (has1mTag ? "[1m]" : "");
1290
- case "sonnet":
1291
- return getDefaultSonnetModel() + (has1mTag ? "[1m]" : "");
1292
- case "haiku":
1293
- return getDefaultHaikuModel() + (has1mTag ? "[1m]" : "");
1294
- case "opus":
1295
- return getDefaultOpusModel() + (has1mTag ? "[1m]" : "");
1296
- case "best":
1297
- return getBestModel();
1298
- default:
1299
- }
1300
- }
1301
- if (getAPIProvider() === "firstParty" && isLegacyOpusFirstParty(modelString) && isLegacyModelRemapEnabled()) {
1302
- return getDefaultOpusModel() + (has1mTag ? "[1m]" : "");
1303
- }
1304
- if (process.env.USER_TYPE === "ant") {
1305
- const has1mAntTag = has1mContext(normalizedModel);
1306
- const baseAntModel = normalizedModel.replace(/\[1m]$/i, "").trim();
1307
- const antModel = resolveAntModel(baseAntModel);
1308
- if (antModel) {
1309
- const suffix = has1mAntTag ? "[1m]" : "";
1310
- return antModel.model + suffix;
1311
- }
1312
- }
1313
- if (has1mTag) {
1314
- return modelInputTrimmed.replace(/\[1m\]$/i, "").trim() + "[1m]";
1315
- }
1316
- return modelInputTrimmed;
1317
- }
1318
- function resolveSkillModelOverride(skillModel, currentModel) {
1319
- if (has1mContext(skillModel) || !has1mContext(currentModel)) {
1320
- return skillModel;
1321
- }
1322
- if (modelSupports1M(parseUserSpecifiedModel(skillModel))) {
1323
- return skillModel + "[1m]";
1324
- }
1325
- return skillModel;
1326
- }
1327
- function isLegacyOpusFirstParty(model) {
1328
- return LEGACY_OPUS_FIRSTPARTY.includes(model);
1329
- }
1330
- function isLegacyModelRemapEnabled() {
1331
- return !isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP);
1332
- }
1333
- function modelDisplayString(model) {
1334
- if (model === null) {
1335
- if (process.env.USER_TYPE === "ant") {
1336
- return `Default for Ants (${renderDefaultModelSetting(getDefaultMainLoopModelSetting())})`;
1337
- } else if (isClaudeAISubscriber()) {
1338
- return `Default (${getClaudeAiUserDefaultModelDescription()})`;
1339
- }
1340
- return `Default (${getDefaultMainLoopModel()})`;
1341
- }
1342
- const resolvedModel = parseUserSpecifiedModel(model);
1343
- return model === resolvedModel ? resolvedModel : `${model} (${resolvedModel})`;
1344
- }
1345
- function getMarketingNameForModel(modelId) {
1346
- const has1m = modelId.toLowerCase().includes("[1m]");
1347
- const canonical = getCanonicalName(modelId);
1348
- if (canonical.includes("claude-opus-4-6")) {
1349
- return has1m ? "Opus 4.6 (with 1M context)" : "Opus 4.6";
1350
- }
1351
- if (canonical.includes("claude-opus-4-5")) {
1352
- return "Opus 4.5";
1353
- }
1354
- if (canonical.includes("claude-opus-4-1")) {
1355
- return "Opus 4.1";
1356
- }
1357
- if (canonical.includes("claude-opus-4")) {
1358
- return "Opus 4";
1359
- }
1360
- if (canonical.includes("claude-sonnet-4-6")) {
1361
- return has1m ? "Sonnet 4.6 (with 1M context)" : "Sonnet 4.6";
1362
- }
1363
- if (canonical.includes("claude-sonnet-4-5")) {
1364
- return has1m ? "Sonnet 4.5 (with 1M context)" : "Sonnet 4.5";
1365
- }
1366
- if (canonical.includes("claude-sonnet-4")) {
1367
- return has1m ? "Sonnet 4 (with 1M context)" : "Sonnet 4";
1368
- }
1369
- if (canonical.includes("claude-3-7-sonnet")) {
1370
- return "3.7 Sonnet";
1371
- }
1372
- if (canonical.includes("claude-3-5-sonnet")) {
1373
- return "3.5 Sonnet";
1374
- }
1375
- if (canonical.includes("claude-haiku-4-5")) {
1376
- return "Haiku 4.5";
1377
- }
1378
- if (canonical.includes("claude-3-5-haiku")) {
1379
- return "3.5 Haiku";
1380
- }
1381
- return;
1382
- }
1383
- function normalizeModelStringForAPI(model) {
1384
- return model.replace(/\[(1|2)m\]/gi, "");
1385
- }
1386
- var getSubscriptionType = () => null, isClaudeAISubscriber = () => false, isMaxSubscriber = () => false, isProSubscriber = () => false, isTeamPremiumSubscriber = () => false, LEGACY_OPUS_FIRSTPARTY;
1387
- var init_model = __esm(() => {
1388
- init_state();
1389
- init_antModels();
1390
- init_context();
1391
- init_envUtils();
1392
- init_modelStrings();
1393
- init_modelCost();
1394
- init_settings();
1395
- init_providers();
1396
- init_figures();
1397
- init_modelAllowlist();
1398
- init_aliases();
1399
- init_stringUtils();
1400
- LEGACY_OPUS_FIRSTPARTY = [
1401
- "claude-opus-4-20250514",
1402
- "claude-opus-4-1-20250805",
1403
- "claude-opus-4-0",
1404
- "claude-opus-4-1"
1405
- ];
1406
- });
1407
-
1408
- // src/utils/context.ts
1409
- function is1mContextDisabled() {
1410
- return isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_1M_CONTEXT);
1411
- }
1412
- function has1mContext(model) {
1413
- if (is1mContextDisabled()) {
1414
- return false;
1415
- }
1416
- return /\[1m\]/i.test(model);
1417
- }
1418
- function modelSupports1M(model) {
1419
- if (is1mContextDisabled()) {
1420
- return false;
1421
- }
1422
- const canonical = getCanonicalName(model);
1423
- return canonical.includes("claude-sonnet-4") || canonical.includes("opus-4-6");
1424
- }
1425
- function getContextWindowForModel(model, betas) {
1426
- if (process.env.USER_TYPE === "ant" && process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS) {
1427
- const override = parseInt(process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS, 10);
1428
- if (!isNaN(override) && override > 0) {
1429
- return override;
1430
- }
1431
- }
1432
- if (has1mContext(model)) {
1433
- return 1e6;
1434
- }
1435
- const cap = getModelCapability(model);
1436
- if (cap?.max_input_tokens && cap.max_input_tokens >= 1e5) {
1437
- if (cap.max_input_tokens > MODEL_CONTEXT_WINDOW_DEFAULT && is1mContextDisabled()) {
1438
- return MODEL_CONTEXT_WINDOW_DEFAULT;
1439
- }
1440
- return cap.max_input_tokens;
1441
- }
1442
- if (betas?.includes(CONTEXT_1M_BETA_HEADER) && modelSupports1M(model)) {
1443
- return 1e6;
1444
- }
1445
- if (getSonnet1mExpTreatmentEnabled(model)) {
1446
- return 1e6;
1447
- }
1448
- if (process.env.USER_TYPE === "ant") {
1449
- const antModel = resolveAntModel(model);
1450
- if (antModel?.contextWindow) {
1451
- return antModel.contextWindow;
1452
- }
1453
- }
1454
- return MODEL_CONTEXT_WINDOW_DEFAULT;
1455
- }
1456
- function getSonnet1mExpTreatmentEnabled(model) {
1457
- if (is1mContextDisabled()) {
1458
- return false;
1459
- }
1460
- if (has1mContext(model)) {
1461
- return false;
1462
- }
1463
- if (!getCanonicalName(model).includes("sonnet-4-6")) {
1464
- return false;
1465
- }
1466
- return getGlobalConfig().clientDataCache?.["coral_reef_sonnet"] === "true";
1467
- }
1468
- function calculateContextPercentages(currentUsage, contextWindowSize) {
1469
- if (!currentUsage) {
1470
- return { used: null, remaining: null };
1471
- }
1472
- const totalInputTokens = currentUsage.input_tokens + currentUsage.cache_creation_input_tokens + currentUsage.cache_read_input_tokens;
1473
- const usedPercentage = Math.round(totalInputTokens / contextWindowSize * 100);
1474
- const clampedUsed = Math.min(100, Math.max(0, usedPercentage));
1475
- return {
1476
- used: clampedUsed,
1477
- remaining: 100 - clampedUsed
1478
- };
1479
- }
1480
- function getModelMaxOutputTokens(model) {
1481
- let defaultTokens;
1482
- let upperLimit;
1483
- if (process.env.USER_TYPE === "ant") {
1484
- const antModel = resolveAntModel(model.toLowerCase());
1485
- if (antModel) {
1486
- defaultTokens = antModel.defaultMaxTokens ?? MAX_OUTPUT_TOKENS_DEFAULT;
1487
- upperLimit = antModel.upperMaxTokensLimit ?? MAX_OUTPUT_TOKENS_UPPER_LIMIT;
1488
- return { default: defaultTokens, upperLimit };
1489
- }
1490
- }
1491
- const m = getCanonicalName(model);
1492
- if (m.includes("opus-4-6")) {
1493
- defaultTokens = 64000;
1494
- upperLimit = 128000;
1495
- } else if (m.includes("sonnet-4-6")) {
1496
- defaultTokens = 32000;
1497
- upperLimit = 128000;
1498
- } else if (m.includes("opus-4-5") || m.includes("sonnet-4") || m.includes("haiku-4")) {
1499
- defaultTokens = 32000;
1500
- upperLimit = 64000;
1501
- } else if (m.includes("opus-4-1") || m.includes("opus-4")) {
1502
- defaultTokens = 32000;
1503
- upperLimit = 32000;
1504
- } else if (m.includes("claude-3-opus")) {
1505
- defaultTokens = 4096;
1506
- upperLimit = 4096;
1507
- } else if (m.includes("claude-3-sonnet")) {
1508
- defaultTokens = 8192;
1509
- upperLimit = 8192;
1510
- } else if (m.includes("claude-3-haiku")) {
1511
- defaultTokens = 4096;
1512
- upperLimit = 4096;
1513
- } else if (m.includes("3-5-sonnet") || m.includes("3-5-haiku")) {
1514
- defaultTokens = 8192;
1515
- upperLimit = 8192;
1516
- } else if (m.includes("3-7-sonnet")) {
1517
- defaultTokens = 32000;
1518
- upperLimit = 64000;
1519
- } else {
1520
- defaultTokens = MAX_OUTPUT_TOKENS_DEFAULT;
1521
- upperLimit = MAX_OUTPUT_TOKENS_UPPER_LIMIT;
1522
- }
1523
- const cap = getModelCapability(model);
1524
- if (cap?.max_tokens && cap.max_tokens >= 4096) {
1525
- upperLimit = cap.max_tokens;
1526
- defaultTokens = Math.min(defaultTokens, upperLimit);
1527
- }
1528
- return { default: defaultTokens, upperLimit };
1529
- }
1530
- function getMaxThinkingTokensForModel(model) {
1531
- return getModelMaxOutputTokens(model).upperLimit - 1;
1532
- }
1533
- var MODEL_CONTEXT_WINDOW_DEFAULT = 200000, COMPACT_MAX_OUTPUT_TOKENS = 20000, MAX_OUTPUT_TOKENS_DEFAULT = 32000, MAX_OUTPUT_TOKENS_UPPER_LIMIT = 64000, CAPPED_DEFAULT_MAX_TOKENS = 8000, ESCALATED_MAX_TOKENS = 64000;
1534
- var init_context = __esm(() => {
1535
- init_betas();
1536
- init_config();
1537
- init_envUtils();
1538
- init_model();
1539
- init_antModels();
1540
- init_modelCapabilities();
1541
- });
1542
-
1543
- export { CLAUDE_CODE_20250219_BETA_HEADER, INTERLEAVED_THINKING_BETA_HEADER, CONTEXT_1M_BETA_HEADER, CONTEXT_MANAGEMENT_BETA_HEADER, STRUCTURED_OUTPUTS_BETA_HEADER, TOOL_SEARCH_BETA_HEADER_1P, EFFORT_BETA_HEADER, TASK_BUDGETS_BETA_HEADER, PROMPT_CACHING_SCOPE_BETA_HEADER, FAST_MODE_BETA_HEADER, REDACT_THINKING_BETA_HEADER, TOKEN_EFFICIENT_TOOLS_BETA_HEADER, AFK_MODE_BETA_HEADER, CLI_INTERNAL_BETA_HEADER, ADVISOR_BETA_HEADER, init_betas, getAPIProvider, getAPIProviderForStatsig, isFirstPartyAnthropicBaseUrl, init_providers, getAntModelOverrideConfig, getAntModels, resolveAntModel, init_antModels, getAnthropicClient, CLIENT_REQUEST_ID_HEADER, init_client, refreshModelCapabilities, init_modelCapabilities, COMPACT_MAX_OUTPUT_TOKENS, CAPPED_DEFAULT_MAX_TOKENS, ESCALATED_MAX_TOKENS, is1mContextDisabled, has1mContext, getContextWindowForModel, getSonnet1mExpTreatmentEnabled, calculateContextPercentages, getModelMaxOutputTokens, getMaxThinkingTokensForModel, init_context, CLAUDE_OPUS_4_6_CONFIG, ALL_MODEL_CONFIGS, init_configs, getModelStrings2 as getModelStrings, ensureModelStringsInitialized, init_modelStrings, isFastModeEnabled, isFastModeAvailable, getFastModeUnavailableReason, FAST_MODE_MODEL_DISPLAY, getFastModeModel, getInitialFastModeSetting, isFastModeSupportedByModel, onCooldownTriggered, onCooldownExpired, getFastModeRuntimeState, triggerFastModeCooldown, clearFastModeCooldown, handleFastModeRejectedByAPI, onFastModeOverageRejection, handleFastModeOverageRejection, isFastModeCooldown, getFastModeState, onOrgFastModeChanged, resolveFastModeStatusFromCache, prefetchFastModeStatus, init_fastMode, COST_TIER_3_15, COST_HAIKU_35, COST_HAIKU_45, getOpus46CostTier, calculateUSDCost, calculateCostFromTokens, formatModelPricing, init_modelCost, MODEL_ALIASES, init_aliases, isModelAllowed, init_modelAllowlist, getSmallFastModel, isNonCustomOpusModel, getUserSpecifiedModelSetting, getMainLoopModel, getDefaultOpusModel, getDefaultSonnetModel, getDefaultHaikuModel, getRuntimeMainLoopModel, getDefaultMainLoopModelSetting, getDefaultMainLoopModel, getCanonicalName, renderDefaultModelSetting, getOpus46PricingSuffix, isOpus1mMergeEnabled, renderModelSetting, getPublicModelDisplayName, renderModelName, getPublicModelName, parseUserSpecifiedModel, resolveSkillModelOverride, isLegacyModelRemapEnabled, modelDisplayString, getMarketingNameForModel, normalizeModelStringForAPI, init_model };