@caspian2026/agent-sdk 0.0.8 → 0.0.11

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 (312) hide show
  1. package/dist/{chunk-dtgh4te6.js → chunk-0ac6r0fw.js} +46 -45
  2. package/dist/{chunk-cfgha78n.js → chunk-0dm971mw.js} +2 -2
  3. package/dist/{chunk-0mej3p7q.js → chunk-0f5anjkb.js} +14 -14
  4. package/dist/{chunk-6g5qbbxk.js → chunk-0k9sft0s.js} +47 -46
  5. package/dist/chunk-0kgwksm1.js +57 -0
  6. package/dist/chunk-0vp3wfab.js +12 -0
  7. package/dist/{chunk-d9yghsfg.js → chunk-1etzkkxs.js} +1 -1
  8. package/dist/{chunk-a4npwxvb.js → chunk-1gz2wrhq.js} +46 -45
  9. package/dist/{chunk-25bwa70y.js → chunk-1pr4hr5x.js} +49 -48
  10. package/dist/{chunk-2f21meep.js → chunk-1v01c96r.js} +1 -1
  11. package/dist/{chunk-jvmybb06.js → chunk-1vhjn1j9.js} +46 -45
  12. package/dist/{chunk-69r3hm9b.js → chunk-1wr6ag3j.js} +13 -19
  13. package/dist/{chunk-83e71kz6.js → chunk-2072dpbx.js} +2 -2
  14. package/dist/{chunk-8hpq2659.js → chunk-24t2wjab.js} +1 -1
  15. package/dist/{chunk-q7e0106d.js → chunk-2589k4k0.js} +51 -56
  16. package/dist/{chunk-d7886r6a.js → chunk-26wtxbdc.js} +7774 -7774
  17. package/dist/{chunk-ahrhwpm9.js → chunk-28k13wc7.js} +2 -2
  18. package/dist/{chunk-vvjgdzhn.js → chunk-2cr43hzw.js} +55 -51
  19. package/dist/{chunk-mw1kpeg9.js → chunk-2sqhjnpn.js} +1909 -1377
  20. package/dist/chunk-2tfe2zs1.js +87 -0
  21. package/dist/{chunk-c11swzas.js → chunk-2vteceqh.js} +5 -5
  22. package/dist/{chunk-zmra45az.js → chunk-2z9rak9s.js} +47 -46
  23. package/dist/chunk-31bwdrm5.js +93 -0
  24. package/dist/{chunk-2xbyb015.js → chunk-38rkx4cj.js} +47 -46
  25. package/dist/{chunk-am3qcgzp.js → chunk-394djs3v.js} +56 -55
  26. package/dist/{chunk-15m49c67.js → chunk-3e28fvn0.js} +2 -2
  27. package/dist/{chunk-4hv90qcz.js → chunk-3mgywd32.js} +1 -1
  28. package/dist/{chunk-234668cb.js → chunk-3we6j8b4.js} +5 -5
  29. package/dist/{chunk-7rnqsng2.js → chunk-400r5gmq.js} +19 -19
  30. package/dist/{chunk-yc23zxmj.js → chunk-4057dtxd.js} +1 -1
  31. package/dist/{chunk-70eey1nh.js → chunk-40s88wdg.js} +2 -2
  32. package/dist/{chunk-8nfn89nz.js → chunk-41en0cc6.js} +9 -9
  33. package/dist/{chunk-t5vbqd9d.js → chunk-488spx13.js} +55 -54
  34. package/dist/{chunk-9v13f3gm.js → chunk-49bs7x5p.js} +558 -196
  35. package/dist/{chunk-0awwmrwr.js → chunk-4ayjwyqj.js} +2 -2
  36. package/dist/chunk-4d0g9n3q.js +92 -0
  37. package/dist/{chunk-denyma1s.js → chunk-4fh25m1z.js} +14 -12
  38. package/dist/chunk-4hgxxzdw.js +94 -0
  39. package/dist/{chunk-8g747a8x.js → chunk-4pbx3g7s.js} +1 -1
  40. package/dist/{chunk-fkhs3myp.js → chunk-4pj88fnc.js} +5 -3
  41. package/dist/{chunk-st73prx0.js → chunk-4re879ja.js} +47 -46
  42. package/dist/{chunk-pb92bj1h.js → chunk-50art2hr.js} +6 -6
  43. package/dist/{chunk-1nk93fqz.js → chunk-5cxjxxx8.js} +2 -7
  44. package/dist/{chunk-kek5v6ef.js → chunk-5pqq0nym.js} +3 -3
  45. package/dist/{chunk-nk82j7r2.js → chunk-6696fngv.js} +7 -7
  46. package/dist/{chunk-ya40p6vj.js → chunk-66dk94r4.js} +46 -45
  47. package/dist/{chunk-xrpstt41.js → chunk-67808qek.js} +4 -4
  48. package/dist/{chunk-zhk465tg.js → chunk-69841w77.js} +46 -45
  49. package/dist/{chunk-jgzxmtpf.js → chunk-6ebvysef.js} +52 -52
  50. package/dist/{chunk-bmbq6nt1.js → chunk-6wzg2hpc.js} +2 -2
  51. package/dist/{chunk-12k745vf.js → chunk-6zsxtysq.js} +3 -3
  52. package/dist/{chunk-qcnhb4cd.js → chunk-75qqeec8.js} +3 -3
  53. package/dist/{chunk-nvwwtq1w.js → chunk-765zdaq8.js} +49 -48
  54. package/dist/{chunk-zq6ezxh2.js → chunk-7ce8wn1f.js} +49 -45
  55. package/dist/{chunk-e7h4qxgw.js → chunk-7etkb4pr.js} +4 -4
  56. package/dist/{chunk-wha6v7za.js → chunk-7krg0dkt.js} +2 -2
  57. package/dist/{chunk-nqrc7pc4.js → chunk-7p2vw8qe.js} +29 -27
  58. package/dist/{chunk-q1ah9nbq.js → chunk-7t5ymv2m.js} +1 -1
  59. package/dist/{chunk-xz655xxa.js → chunk-7tphrzjj.js} +2 -2
  60. package/dist/{chunk-hzknr99c.js → chunk-83b2frat.js} +4 -4
  61. package/dist/{chunk-bxcfz5gy.js → chunk-87xg6yb4.js} +1 -1
  62. package/dist/{chunk-nrtksr2p.js → chunk-8b2y3x7a.js} +1 -1
  63. package/dist/{chunk-1cq2vrzq.js → chunk-8c907cv9.js} +4 -4
  64. package/dist/{chunk-88cekjja.js → chunk-8dzg4nr5.js} +47 -46
  65. package/dist/{chunk-2fxpd35d.js → chunk-8hn2xqjz.js} +2 -2
  66. package/dist/{chunk-3g1vqhyx.js → chunk-8kmna3cc.js} +17 -21
  67. package/dist/{chunk-1zhy5cbc.js → chunk-8r5eevap.js} +13 -13
  68. package/dist/{chunk-7n51wk9k.js → chunk-8vkv63c5.js} +2 -2
  69. package/dist/{chunk-268jd0rc.js → chunk-8w21adpe.js} +6 -4
  70. package/dist/{chunk-21gmrwhs.js → chunk-8w8d1k7b.js} +17 -21
  71. package/dist/{chunk-yzcjz0gg.js → chunk-90bqyqfd.js} +46 -45
  72. package/dist/{chunk-2xvc97x4.js → chunk-942yq6xx.js} +3 -3
  73. package/dist/{chunk-88xc4d7f.js → chunk-99ck62v1.js} +49 -48
  74. package/dist/chunk-9ewnsd7f.js +31 -0
  75. package/dist/{chunk-xwg327ys.js → chunk-9g29z3dv.js} +6 -6
  76. package/dist/{chunk-5a5w0ygx.js → chunk-9nj016rn.js} +2 -2
  77. package/dist/chunk-9nk34wee.js +441 -0
  78. package/dist/{chunk-2v4x8kaq.js → chunk-9z45660r.js} +51 -50
  79. package/dist/{chunk-s1tg295x.js → chunk-a3gq2vv4.js} +10 -8
  80. package/dist/{chunk-6p4cyhb3.js → chunk-a6d2q415.js} +2 -2
  81. package/dist/{chunk-0jtbeesf.js → chunk-akqsq8bn.js} +16 -20
  82. package/dist/{chunk-tff58196.js → chunk-aqq5qh2y.js} +48 -47
  83. package/dist/{chunk-dvcwahst.js → chunk-awdftfcf.js} +51 -50
  84. package/dist/{chunk-3zxswxtg.js → chunk-b3nkagky.js} +2 -2
  85. package/dist/{chunk-jgjqa49s.js → chunk-b56smerd.js} +3 -3
  86. package/dist/{chunk-enkdxqas.js → chunk-b5asw4tj.js} +6 -6
  87. package/dist/{chunk-1x0y4426.js → chunk-b8f5dz5b.js} +4 -4
  88. package/dist/{chunk-30smv00b.js → chunk-bayvqjm6.js} +47 -46
  89. package/dist/chunk-bgyb0z0p.js +96 -0
  90. package/dist/{chunk-3skj4gfg.js → chunk-bhabqhx1.js} +47 -46
  91. package/dist/{chunk-4140c8xy.js → chunk-bj85dnsy.js} +20 -24
  92. package/dist/{chunk-vdcm8hz6.js → chunk-bp4s0gry.js} +47 -46
  93. package/dist/{chunk-d00mfc1e.js → chunk-brng9f4q.js} +46 -45
  94. package/dist/{chunk-a3ws4gae.js → chunk-bvdzmdw4.js} +47 -46
  95. package/dist/{chunk-m87bhhqv.js → chunk-bzatg35k.js} +1 -1
  96. package/dist/{chunk-hxzt3r84.js → chunk-ca72efeb.js} +51 -50
  97. package/dist/{chunk-vajwapkf.js → chunk-cdact4jj.js} +17 -23
  98. package/dist/{chunk-s3hsqf80.js → chunk-cexw1jmv.js} +30 -81
  99. package/dist/chunk-cfyvkbe5.js +197 -0
  100. package/dist/{chunk-jj5wj46b.js → chunk-cjca0q27.js} +7 -7
  101. package/dist/{chunk-3hwa20vg.js → chunk-cs9aqzag.js} +49 -46
  102. package/dist/{chunk-1ax1znzj.js → chunk-cttezxcb.js} +24 -14
  103. package/dist/chunk-d2g976qe.js +1457 -0
  104. package/dist/{chunk-d6rypdxt.js → chunk-d7ws01qk.js} +1 -1
  105. package/dist/{chunk-xxw9a0bq.js → chunk-dhwr4fz4.js} +2 -2
  106. package/dist/{chunk-x2pvw7xw.js → chunk-dmyedkpw.js} +8 -8
  107. package/dist/{chunk-af868wet.js → chunk-dsqfe05n.js} +46 -45
  108. package/dist/{chunk-4r50c14n.js → chunk-e82vbky2.js} +46 -45
  109. package/dist/{chunk-vawgyev5.js → chunk-eba0b85f.js} +3 -3
  110. package/dist/{chunk-87e209aj.js → chunk-eqnfk1g0.js} +46 -45
  111. package/dist/chunk-erj5nc8b.js +92 -0
  112. package/dist/{chunk-ky39hkg1.js → chunk-eseq7djh.js} +9 -7
  113. package/dist/{chunk-vvsbvz2b.js → chunk-esrkw9v4.js} +2 -2
  114. package/dist/{chunk-jgpmpgx6.js → chunk-etdt1xz3.js} +1 -1
  115. package/dist/{chunk-w05jpkkr.js → chunk-ewbvcf88.js} +5 -9
  116. package/dist/chunk-ewhxddsa.js +445 -0
  117. package/dist/{chunk-jjh7m5sg.js → chunk-ey1pg5v8.js} +66 -77
  118. package/dist/{chunk-h02gcdx5.js → chunk-f1v8h236.js} +8 -8
  119. package/dist/chunk-f70fwxds.js +211 -0
  120. package/dist/{chunk-1dwvgrfc.js → chunk-f73trmvk.js} +46 -45
  121. package/dist/{chunk-xnv6kb39.js → chunk-fcww10dt.js} +22 -23
  122. package/dist/{chunk-15edybe0.js → chunk-fhprmgf4.js} +1 -1
  123. package/dist/{chunk-5awgsvrw.js → chunk-fnf4av18.js} +14 -6
  124. package/dist/{chunk-j4m8fd76.js → chunk-fy543pwf.js} +7 -11
  125. package/dist/chunk-fybanr7d.js +988 -0
  126. package/dist/chunk-g5epkvz2.js +331 -0
  127. package/dist/chunk-g5pe8dew.js +25 -0
  128. package/dist/chunk-g8183rkv.js +517 -0
  129. package/dist/{chunk-4g0nj78p.js → chunk-gbztsm42.js} +46 -45
  130. package/dist/{chunk-ga86yjm1.js → chunk-gdwdqewd.js} +3 -3
  131. package/dist/{chunk-kva79cra.js → chunk-ge57c9hg.js} +7 -5
  132. package/dist/{chunk-f2hbn5rk.js → chunk-ggq2y3tn.js} +100420 -57118
  133. package/dist/{chunk-w0gmf6bv.js → chunk-gpzkzg7v.js} +47 -46
  134. package/dist/{chunk-v0bykh19.js → chunk-gw1a82j8.js} +108 -102
  135. package/dist/chunk-gw1g065z.js +20 -0
  136. package/dist/{chunk-21jsjcfa.js → chunk-h4dnamt5.js} +46 -45
  137. package/dist/{chunk-hh3k5s1s.js → chunk-h5mkzk0z.js} +3 -3
  138. package/dist/chunk-h7dm24cc.js +108 -0
  139. package/dist/{chunk-wr3pd88n.js → chunk-hadww3nd.js} +40 -9
  140. package/dist/{chunk-8ywngxqt.js → chunk-hapvn84d.js} +10 -10
  141. package/dist/{chunk-gbte7d7h.js → chunk-hekf5s9q.js} +4 -2
  142. package/dist/{chunk-veap97he.js → chunk-hkgb5y9f.js} +46 -45
  143. package/dist/{chunk-23fkapww.js → chunk-hzceftr4.js} +2 -2
  144. package/dist/chunk-j2x6fp25.js +29 -0
  145. package/dist/{chunk-vsqwd13w.js → chunk-j30g8fd1.js} +17 -19
  146. package/dist/{chunk-yyf72f78.js → chunk-j35mw64g.js} +4 -2
  147. package/dist/{chunk-qq5d2s0d.js → chunk-j3awswy3.js} +46 -45
  148. package/dist/{chunk-dmqeqxfz.js → chunk-j513wqe9.js} +46 -45
  149. package/dist/{chunk-hya4c599.js → chunk-jkens34n.js} +46 -45
  150. package/dist/{chunk-s4zb3f1b.js → chunk-jperb6n2.js} +46 -45
  151. package/dist/{chunk-psnsve7m.js → chunk-jqmr6ag1.js} +49 -48
  152. package/dist/{chunk-q7jnesv8.js → chunk-jsj3fx0g.js} +5 -5
  153. package/dist/{chunk-w1sv7j01.js → chunk-jx6k8msx.js} +46 -45
  154. package/dist/{chunk-xw8pjerk.js → chunk-jyz65rfv.js} +48 -47
  155. package/dist/{chunk-1avzakfd.js → chunk-k5mckm5f.js} +3 -3
  156. package/dist/{chunk-zctfbr1v.js → chunk-k7cw1a8a.js} +1 -1
  157. package/dist/{chunk-m46xyqr6.js → chunk-k9z36r5q.js} +48 -47
  158. package/dist/{chunk-th4y838y.js → chunk-kamesdff.js} +51 -50
  159. package/dist/{chunk-y7we499r.js → chunk-kj4m0j4n.js} +8 -8
  160. package/dist/{chunk-tdbz9gbm.js → chunk-kjqyhxz7.js} +6 -6
  161. package/dist/{chunk-k0v0cz71.js → chunk-m25yfqc3.js} +46 -45
  162. package/dist/{chunk-4nspekjp.js → chunk-mcws22k3.js} +1 -28
  163. package/dist/chunk-mgpj5f7h.js +150 -0
  164. package/dist/{chunk-1ybvj5df.js → chunk-mmn62bh2.js} +47 -46
  165. package/dist/{chunk-jpc9zwsk.js → chunk-mq94v5vn.js} +3 -3
  166. package/dist/{chunk-a1bf2kh4.js → chunk-msvv7dpt.js} +46 -45
  167. package/dist/chunk-mtv83pq4.js +123 -0
  168. package/dist/chunk-n36xjgtj.js +95 -0
  169. package/dist/{chunk-twqzmqsn.js → chunk-n9d0gg9z.js} +31 -27
  170. package/dist/{chunk-cvm2tmwg.js → chunk-na63s9wn.js} +20 -24
  171. package/dist/{chunk-jtztm8f5.js → chunk-nebntwvd.js} +44 -43
  172. package/dist/{chunk-0ym2z0c7.js → chunk-nj02kck4.js} +1 -1
  173. package/dist/{chunk-5rv9c8yd.js → chunk-nrjtxhyr.js} +1 -1
  174. package/dist/{chunk-nqn45znr.js → chunk-ns7x6xam.js} +9 -9
  175. package/dist/{chunk-jaaxk89e.js → chunk-nsc89h0n.js} +2 -22
  176. package/dist/{chunk-gnj7tyj6.js → chunk-nv7vcqme.js} +49 -48
  177. package/dist/{chunk-z19sd3bt.js → chunk-p4196wzm.js} +5 -5
  178. package/dist/{chunk-as5rvw4n.js → chunk-pbeee2kp.js} +17 -21
  179. package/dist/{chunk-va8drjmv.js → chunk-pcbm66ch.js} +48 -47
  180. package/dist/{chunk-phd1qfpc.js → chunk-pd2vy8hx.js} +5 -5
  181. package/dist/chunk-pe3n0w2t.js +91 -0
  182. package/dist/{chunk-bd5sqj86.js → chunk-peh3mj19.js} +11 -11
  183. package/dist/{chunk-mk1y74w7.js → chunk-pepgckn4.js} +17 -21
  184. package/dist/{chunk-wqvr37xp.js → chunk-pm67yj46.js} +15 -31
  185. package/dist/{chunk-qyqpb15f.js → chunk-pp8nrx40.js} +205 -261
  186. package/dist/{chunk-nx7c354z.js → chunk-pq5290db.js} +46 -45
  187. package/dist/{chunk-w4yn8cq7.js → chunk-psm26hv7.js} +8 -8
  188. package/dist/{chunk-hwn8vetn.js → chunk-pwpk3gm6.js} +10 -10
  189. package/dist/chunk-pzp8fj0a.js +123 -0
  190. package/dist/{chunk-x94btg29.js → chunk-q1j8ebyf.js} +17 -21
  191. package/dist/{chunk-87scz097.js → chunk-q2fn2p7y.js} +46 -45
  192. package/dist/chunk-q347821k.js +99 -0
  193. package/dist/{chunk-23jzrwsw.js → chunk-q6tdxy8v.js} +5 -5
  194. package/dist/{chunk-byb2mn1c.js → chunk-qb88vpgy.js} +118 -450
  195. package/dist/{chunk-eenq3avg.js → chunk-qcrpqjya.js} +1 -1
  196. package/dist/chunk-qehbwde1.js +90 -0
  197. package/dist/{chunk-ck0ap688.js → chunk-qkczt8cr.js} +4 -4
  198. package/dist/{chunk-c3d2cnz5.js → chunk-qmmxwh8x.js} +7 -7
  199. package/dist/{chunk-1a6ez1mg.js → chunk-qxmm3jbn.js} +51 -49
  200. package/dist/{chunk-njxgct8f.js → chunk-qywk2c7m.js} +46 -45
  201. package/dist/{chunk-rkg741k3.js → chunk-qz0xdht6.js} +14 -14
  202. package/dist/chunk-r0dpeqg0.js +468 -0
  203. package/dist/{chunk-6ksdp40n.js → chunk-r0m970pk.js} +1 -1
  204. package/dist/{chunk-fape0yfp.js → chunk-r5bf0h0t.js} +46 -45
  205. package/dist/{chunk-jcwkgtbp.js → chunk-r7xpsch7.js} +52 -90
  206. package/dist/{chunk-z9n0183s.js → chunk-rfq9kmsy.js} +9 -9
  207. package/dist/{chunk-xp61y5ba.js → chunk-rkv8bdtr.js} +2 -2
  208. package/dist/{chunk-5cem2v7n.js → chunk-rkvwts6v.js} +5 -5
  209. package/dist/{chunk-1vnd9s2j.js → chunk-rm4c8zd9.js} +57 -66
  210. package/dist/{chunk-e7efcp3k.js → chunk-rm9gb396.js} +257 -2857
  211. package/dist/{chunk-0m9w9esf.js → chunk-s213xmp8.js} +46 -45
  212. package/dist/{chunk-c42pqnxx.js → chunk-s3s0611n.js} +1 -1
  213. package/dist/{chunk-qdnxk7d7.js → chunk-scrk9jbt.js} +29 -30
  214. package/dist/{chunk-wayfjcwt.js → chunk-sdfvr9ps.js} +4 -4
  215. package/dist/{chunk-7mqab3z7.js → chunk-skp5w8bq.js} +1 -1
  216. package/dist/{chunk-76j2e9vy.js → chunk-snxp8mxj.js} +2 -2
  217. package/dist/{chunk-ad3v6mzw.js → chunk-tgmettzd.js} +12 -12
  218. package/dist/{chunk-cdj51xbj.js → chunk-tj6hejny.js} +46 -45
  219. package/dist/chunk-tn0xnp8a.js +124 -0
  220. package/dist/chunk-tpn6rh31.js +62 -0
  221. package/dist/{chunk-qsc98gbe.js → chunk-tq4vws6e.js} +2 -2
  222. package/dist/{chunk-ydcsbj4t.js → chunk-tzzzbb9d.js} +11 -9
  223. package/dist/chunk-v3s93bzd.js +34 -0
  224. package/dist/{chunk-4cp6193g.js → chunk-v4t6dyyh.js} +2 -2
  225. package/dist/{chunk-xfkfh5sd.js → chunk-v6fcbmqz.js} +1808 -1643
  226. package/dist/{chunk-k7g9gcr9.js → chunk-vc59jf3q.js} +64 -58
  227. package/dist/{chunk-gdhz1652.js → chunk-vdk9b74d.js} +27 -30
  228. package/dist/{chunk-tvzr9c8a.js → chunk-vf9c1649.js} +46 -45
  229. package/dist/{chunk-naybw0p0.js → chunk-vgk0nymz.js} +8 -8
  230. package/dist/{chunk-jh965sa0.js → chunk-vgzpbh28.js} +47 -46
  231. package/dist/{chunk-q87kegxh.js → chunk-vhxrn87v.js} +49 -48
  232. package/dist/chunk-vnzgpyrz.js +1534 -0
  233. package/dist/{chunk-r6kaak61.js → chunk-vqh6cjfx.js} +16 -20
  234. package/dist/{chunk-wbbykfdd.js → chunk-vz3pa5n6.js} +1 -1
  235. package/dist/{chunk-pwqm47kn.js → chunk-w1h5z2sy.js} +46 -45
  236. package/dist/{chunk-rm2vtv77.js → chunk-w2vvxj1f.js} +22 -25
  237. package/dist/{chunk-s7q42kp2.js → chunk-w5zezk61.js} +9 -9
  238. package/dist/{chunk-vrjbc8ap.js → chunk-wa8yn2p0.js} +1 -1
  239. package/dist/{chunk-a3wczqrp.js → chunk-wahqac7c.js} +37 -41
  240. package/dist/{chunk-qvd3hbqs.js → chunk-wc0np2zw.js} +5 -5
  241. package/dist/{chunk-2j3v2dgk.js → chunk-wcpmtszh.js} +47 -46
  242. package/dist/{chunk-jxfp3g9b.js → chunk-wdzjtdye.js} +4 -4
  243. package/dist/{chunk-0g5cy3wj.js → chunk-wgk9sxk7.js} +4 -4
  244. package/dist/{chunk-rc9x0raa.js → chunk-wmbpjx7v.js} +56 -55
  245. package/dist/chunk-wrsy4y58.js +93 -0
  246. package/dist/{chunk-rtmh0v4c.js → chunk-wskkym13.js} +6 -6
  247. package/dist/{chunk-bm5rc541.js → chunk-wt6v1zbe.js} +5 -5
  248. package/dist/{chunk-37p5p94r.js → chunk-wyj3wpjv.js} +55 -54
  249. package/dist/chunk-x7fdwq3d.js +33 -0
  250. package/dist/{chunk-6t5zvnrg.js → chunk-xdg2rpj3.js} +48 -46
  251. package/dist/{chunk-chsyvavm.js → chunk-xeb6075z.js} +1 -1
  252. package/dist/{chunk-23q4jpn2.js → chunk-xemw9d52.js} +3 -3
  253. package/dist/{chunk-n7pnyq43.js → chunk-xhfmdq1y.js} +16 -0
  254. package/dist/{chunk-jmkn11my.js → chunk-xmdny0m1.js} +20 -20
  255. package/dist/chunk-xswyz2es.js +118 -0
  256. package/dist/{chunk-67a4147x.js → chunk-xv5a2xbe.js} +1 -1
  257. package/dist/{chunk-1dgdjrm1.js → chunk-xx709m24.js} +4 -4
  258. package/dist/{chunk-qn8z4r79.js → chunk-y024419t.js} +50 -48
  259. package/dist/{chunk-dbwmzvfj.js → chunk-y1ps26mz.js} +46 -45
  260. package/dist/{chunk-4m9df5ef.js → chunk-y2r5e6kv.js} +17 -21
  261. package/dist/{chunk-k1crm94z.js → chunk-y41svpxw.js} +46 -45
  262. package/dist/{chunk-qjyg1dv7.js → chunk-ygwcq4vd.js} +6 -10
  263. package/dist/{chunk-fk8crdnk.js → chunk-ykv414dd.js} +48 -46
  264. package/dist/{chunk-g5pgham9.js → chunk-ynkzfhs1.js} +20 -14
  265. package/dist/{chunk-gvrjgq1n.js → chunk-yrqx3p9k.js} +16 -20
  266. package/dist/{chunk-c9dmpdss.js → chunk-ys17e80d.js} +46 -45
  267. package/dist/{chunk-97wgdsab.js → chunk-z16txqz0.js} +3 -3
  268. package/dist/{chunk-yvtzznds.js → chunk-z6wm96eh.js} +2 -2
  269. package/dist/{chunk-8ybw2s0h.js → chunk-zbb7qd0v.js} +4 -4
  270. package/dist/{chunk-030rqd3a.js → chunk-zjxv5g2n.js} +54 -53
  271. package/dist/{chunk-425w66ka.js → chunk-zmwgp2sh.js} +4 -4
  272. package/dist/cli.js +8 -8
  273. package/dist/gateway/index.js +430 -0
  274. package/dist/gateway/worker.js +482687 -0
  275. package/package.json +1 -1
  276. package/dist/chunk-11cz07kz.js +0 -93
  277. package/dist/chunk-1pbtp2z2.js +0 -92
  278. package/dist/chunk-25y2dtzf.js +0 -91
  279. package/dist/chunk-3hyj0zpy.js +0 -95
  280. package/dist/chunk-4kqjjakw.js +0 -73
  281. package/dist/chunk-4zwqbg7s.js +0 -87
  282. package/dist/chunk-5be33wja.js +0 -120
  283. package/dist/chunk-70mgxhkz.js +0 -369
  284. package/dist/chunk-7gmk09cq.js +0 -116
  285. package/dist/chunk-8dprcdra.js +0 -92
  286. package/dist/chunk-8xwx1xtg.js +0 -120
  287. package/dist/chunk-a579wjd2.js +0 -436
  288. package/dist/chunk-axqk3mxk.js +0 -116
  289. package/dist/chunk-c0ckmxr1.js +0 -86
  290. package/dist/chunk-c6t24y8q.js +0 -94
  291. package/dist/chunk-cfv996bs.js +0 -22
  292. package/dist/chunk-e5t5eefc.js +0 -62
  293. package/dist/chunk-eyph0250.js +0 -88
  294. package/dist/chunk-f825x57v.js +0 -91
  295. package/dist/chunk-h9xx5bj6.js +0 -91
  296. package/dist/chunk-j1dg659r.js +0 -89
  297. package/dist/chunk-jk8seqkk.js +0 -90
  298. package/dist/chunk-jzg4nddc.js +0 -92
  299. package/dist/chunk-k5vy0s3c.js +0 -93
  300. package/dist/chunk-ke820fjw.js +0 -91
  301. package/dist/chunk-kyzd4p8z.js +0 -111
  302. package/dist/chunk-njrt3tac.js +0 -640
  303. package/dist/chunk-pavb6a7w.js +0 -516
  304. package/dist/chunk-q268gpa0.js +0 -145
  305. package/dist/chunk-qvh1w3t7.js +0 -157
  306. package/dist/chunk-qy1es4jj.js +0 -95
  307. package/dist/chunk-qz2x630m.js +0 -49145
  308. package/dist/chunk-tw48evtr.js +0 -40
  309. package/dist/chunk-w0gfctyc.js +0 -117
  310. package/dist/chunk-y0fhjxef.js +0 -276
  311. package/dist/chunk-y275vgmw.js +0 -654
  312. package/dist/chunk-zq7pmdas.js +0 -1003
@@ -6,13 +6,13 @@ import {
6
6
  init_types,
7
7
  safeParseJSON,
8
8
  stripBOM
9
- } from "./chunk-z19sd3bt.js";
9
+ } from "./chunk-p4196wzm.js";
10
10
  import {
11
11
  expandPath,
12
12
  init_path,
13
13
  normalizePathForConfigKey,
14
14
  sanitizePath
15
- } from "./chunk-1ax1znzj.js";
15
+ } from "./chunk-cttezxcb.js";
16
16
  import {
17
17
  count,
18
18
  init_array,
@@ -23,42 +23,35 @@ import {
23
23
  import {
24
24
  getPlatform,
25
25
  init_platform
26
- } from "./chunk-xp61y5ba.js";
26
+ } from "./chunk-rkv8bdtr.js";
27
27
  import {
28
28
  init_lazySchema,
29
29
  lazySchema
30
30
  } from "./chunk-64c1avct.js";
31
- import {
32
- getProxyFetchOptions,
33
- init_proxy
34
- } from "./chunk-wha6v7za.js";
35
31
  import {
36
32
  init_v4,
37
33
  v4_default
38
- } from "./chunk-8g747a8x.js";
34
+ } from "./chunk-4pbx3g7s.js";
39
35
  import {
40
36
  exports_external,
41
37
  toJSONSchema
42
- } from "./chunk-d7886r6a.js";
38
+ } from "./chunk-26wtxbdc.js";
43
39
  import {
44
40
  init_normalization,
45
41
  normalizeNameForMCP
46
42
  } from "./chunk-3c25bcsw.js";
47
43
  import {
48
- OAUTH_BETA_HEADER,
49
44
  env,
45
+ getApiConfigSuffix,
50
46
  getGlobalClaudeFile,
51
47
  getHostPlatformForAnalytics,
52
- getOauthConfig,
53
- init_bundledMode,
54
- init_env,
55
- init_oauth,
56
- isInBundledMode
57
- } from "./chunk-s3hsqf80.js";
48
+ init_apiConfig,
49
+ init_env
50
+ } from "./chunk-cexw1jmv.js";
58
51
  import {
59
52
  init_startupProfiler,
60
53
  profileCheckpoint
61
- } from "./chunk-yyf72f78.js";
54
+ } from "./chunk-j35mw64g.js";
62
55
  import {
63
56
  init_source,
64
57
  source_default
@@ -73,32 +66,27 @@ import {
73
66
  init_diagLogs,
74
67
  init_git,
75
68
  logForDiagnosticsNoPII
76
- } from "./chunk-tdbz9gbm.js";
69
+ } from "./chunk-kjqyhxz7.js";
77
70
  import {
78
- execFileNoThrow,
79
71
  execFileNoThrowWithCwd,
80
72
  execSyncWithDefaults_DEPRECATED,
81
- init_execFileNoThrow,
82
- init_execFileNoThrowPortable
83
- } from "./chunk-70eey1nh.js";
73
+ init_execFileNoThrow
74
+ } from "./chunk-40s88wdg.js";
84
75
  import {
85
76
  getEssentialTrafficOnlyReason,
86
77
  init_log,
87
78
  init_privacyLevel,
88
- isEssentialTrafficOnly,
89
79
  logError
90
- } from "./chunk-1nk93fqz.js";
80
+ } from "./chunk-5cxjxxx8.js";
91
81
  import {
92
82
  getCwd,
93
83
  init_cwd
94
84
  } from "./chunk-s8kj6ajy.js";
95
85
  import {
96
86
  execa,
97
- execaSync,
98
87
  init_execa
99
88
  } from "./chunk-5z28bqne.js";
100
89
  import {
101
- Anthropic,
102
90
  ConfigParseError,
103
91
  _assignValue_default,
104
92
  _baseAssignValue_default,
@@ -130,9 +118,7 @@ import {
130
118
  init_errors,
131
119
  init_fsOperations,
132
120
  init_keysIn,
133
- init_sdk,
134
121
  init_slowOperations,
135
- isDebugToStdErr,
136
122
  isENOENT,
137
123
  isFsInaccessible,
138
124
  jsonParse,
@@ -142,9 +128,8 @@ import {
142
128
  logForDebugging,
143
129
  registerCleanup,
144
130
  safeResolvePath,
145
- toError,
146
- writeFileSync_DEPRECATED
147
- } from "./chunk-phd1qfpc.js";
131
+ toError
132
+ } from "./chunk-pd2vy8hx.js";
148
133
  import {
149
134
  getClaudeConfigHomeDir,
150
135
  init_envUtils,
@@ -152,7 +137,7 @@ import {
152
137
  isEnvDefinedFalsy,
153
138
  isEnvTruthy,
154
139
  isRunningOnHomespace
155
- } from "./chunk-jaaxk89e.js";
140
+ } from "./chunk-nsc89h0n.js";
156
141
  import {
157
142
  _Stack_default,
158
143
  _arrayMap_default,
@@ -170,13 +155,9 @@ import {
170
155
  getFlagSettingsInline,
171
156
  getFlagSettingsPath,
172
157
  getIsNonInteractiveSession,
173
- getKairosActive,
174
- getMainLoopModelOverride,
175
- getModelStrings,
176
158
  getOriginalCwd,
177
159
  getPluginSettingsBase,
178
160
  getProjectRoot,
179
- getSdkBetas,
180
161
  getSessionId,
181
162
  getSessionSettingsCache,
182
163
  getSessionTrustAccepted,
@@ -209,8 +190,6 @@ import {
209
190
  setApiKeyFromFd,
210
191
  setCachedParsedFile,
211
192
  setCachedSettingsForSource,
212
- setHasUnknownModelCost,
213
- setModelStrings,
214
193
  setSessionSettingsCache
215
194
  } from "./chunk-k8vp0atq.js";
216
195
  import {
@@ -231,10 +210,6 @@ import {
231
210
  init_isObject,
232
211
  isObject_default
233
212
  } from "./chunk-d4mdda98.js";
234
- import {
235
- axios_default,
236
- init_axios
237
- } from "./chunk-55raexh7.js";
238
213
  import {
239
214
  __esm,
240
215
  __export,
@@ -333,6 +308,205 @@ var init_lodash = __esm(() => {
333
308
  init_memoize();
334
309
  });
335
310
 
311
+ // src/utils/authFileDescriptor.ts
312
+ import { mkdirSync, writeFileSync } from "fs";
313
+ function maybePersistTokenForSubprocesses(path, token, tokenName) {
314
+ if (!isEnvTruthy(process.env.CLAUDE_CODE_REMOTE)) {
315
+ return;
316
+ }
317
+ try {
318
+ mkdirSync(CCR_TOKEN_DIR, { recursive: true, mode: 448 });
319
+ writeFileSync(path, token, { encoding: "utf8", mode: 384 });
320
+ logForDebugging(`Persisted ${tokenName} to ${path} for subprocess access`);
321
+ } catch (error) {
322
+ logForDebugging(`Failed to persist ${tokenName} to disk (non-fatal): ${errorMessage(error)}`, { level: "error" });
323
+ }
324
+ }
325
+ function readTokenFromWellKnownFile(path, tokenName) {
326
+ try {
327
+ const fsOps = getFsImplementation();
328
+ const token = fsOps.readFileSync(path, { encoding: "utf8" }).trim();
329
+ if (!token) {
330
+ return null;
331
+ }
332
+ logForDebugging(`Read ${tokenName} from well-known file ${path}`);
333
+ return token;
334
+ } catch (error) {
335
+ if (!isENOENT(error)) {
336
+ logForDebugging(`Failed to read ${tokenName} from ${path}: ${errorMessage(error)}`, { level: "debug" });
337
+ }
338
+ return null;
339
+ }
340
+ }
341
+ function getCredentialFromFd({
342
+ envVar,
343
+ wellKnownPath,
344
+ label,
345
+ getCached,
346
+ setCached
347
+ }) {
348
+ const cached = getCached();
349
+ if (cached !== undefined) {
350
+ return cached;
351
+ }
352
+ const fdEnv = process.env[envVar];
353
+ if (!fdEnv) {
354
+ const fromFile = readTokenFromWellKnownFile(wellKnownPath, label);
355
+ setCached(fromFile);
356
+ return fromFile;
357
+ }
358
+ const fd = parseInt(fdEnv, 10);
359
+ if (Number.isNaN(fd)) {
360
+ logForDebugging(`${envVar} must be a valid file descriptor number, got: ${fdEnv}`, { level: "error" });
361
+ setCached(null);
362
+ return null;
363
+ }
364
+ try {
365
+ const fsOps = getFsImplementation();
366
+ const fdPath = process.platform === "darwin" || process.platform === "freebsd" ? `/dev/fd/${fd}` : `/proc/self/fd/${fd}`;
367
+ const token = fsOps.readFileSync(fdPath, { encoding: "utf8" }).trim();
368
+ if (!token) {
369
+ logForDebugging(`File descriptor contained empty ${label}`, {
370
+ level: "error"
371
+ });
372
+ setCached(null);
373
+ return null;
374
+ }
375
+ logForDebugging(`Successfully read ${label} from file descriptor ${fd}`);
376
+ setCached(token);
377
+ maybePersistTokenForSubprocesses(wellKnownPath, token, label);
378
+ return token;
379
+ } catch (error) {
380
+ logForDebugging(`Failed to read ${label} from file descriptor ${fd}: ${errorMessage(error)}`, { level: "error" });
381
+ const fromFile = readTokenFromWellKnownFile(wellKnownPath, label);
382
+ setCached(fromFile);
383
+ return fromFile;
384
+ }
385
+ }
386
+ function getApiKeyFromFileDescriptor() {
387
+ return getCredentialFromFd({
388
+ envVar: "CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR",
389
+ wellKnownPath: CCR_API_KEY_PATH,
390
+ label: "API key",
391
+ getCached: getApiKeyFromFd,
392
+ setCached: setApiKeyFromFd
393
+ });
394
+ }
395
+ var CCR_TOKEN_DIR = "/home/claude/.claude/remote", CCR_OAUTH_TOKEN_PATH, CCR_API_KEY_PATH, CCR_SESSION_INGRESS_TOKEN_PATH;
396
+ var init_authFileDescriptor = __esm(() => {
397
+ init_state();
398
+ init_debug();
399
+ init_envUtils();
400
+ init_errors();
401
+ init_fsOperations();
402
+ CCR_OAUTH_TOKEN_PATH = `${CCR_TOKEN_DIR}/.oauth_token`;
403
+ CCR_API_KEY_PATH = `${CCR_TOKEN_DIR}/.api_key`;
404
+ CCR_SESSION_INGRESS_TOKEN_PATH = `${CCR_TOKEN_DIR}/.session_ingress_token`;
405
+ });
406
+
407
+ // src/utils/secureStorage/macOsKeychainHelpers.ts
408
+ import { createHash } from "crypto";
409
+ import { userInfo } from "os";
410
+ function getMacOsKeychainStorageServiceName(serviceSuffix = "") {
411
+ const configDir = getClaudeConfigHomeDir();
412
+ const isDefaultDir = !process.env.CLAUDE_CONFIG_DIR;
413
+ const dirHash = isDefaultDir ? "" : `-${createHash("sha256").update(configDir).digest("hex").substring(0, 8)}`;
414
+ return `Claude Code${getApiConfigSuffix()}${serviceSuffix}${dirHash}`;
415
+ }
416
+ function getUsername() {
417
+ try {
418
+ return process.env.USER || userInfo().username;
419
+ } catch {
420
+ return "claude-code-user";
421
+ }
422
+ }
423
+ function clearKeychainCache() {
424
+ keychainCacheState.cache = { data: null, cachedAt: 0 };
425
+ keychainCacheState.generation++;
426
+ keychainCacheState.readInFlight = null;
427
+ }
428
+ function primeKeychainCacheFromPrefetch(stdout) {
429
+ if (keychainCacheState.cache.cachedAt !== 0)
430
+ return;
431
+ let data = null;
432
+ if (stdout) {
433
+ try {
434
+ data = JSON.parse(stdout);
435
+ } catch {
436
+ return;
437
+ }
438
+ }
439
+ keychainCacheState.cache = { data, cachedAt: Date.now() };
440
+ }
441
+ var CREDENTIALS_SERVICE_SUFFIX = "-credentials", KEYCHAIN_CACHE_TTL_MS = 30000, keychainCacheState;
442
+ var init_macOsKeychainHelpers = __esm(() => {
443
+ init_apiConfig();
444
+ init_envUtils();
445
+ keychainCacheState = {
446
+ cache: { data: null, cachedAt: 0 },
447
+ generation: 0,
448
+ readInFlight: null
449
+ };
450
+ });
451
+
452
+ // src/utils/authPortable.ts
453
+ async function maybeRemoveApiKeyFromMacOSKeychainThrows() {
454
+ if (process.platform === "darwin") {
455
+ const storageServiceName = getMacOsKeychainStorageServiceName();
456
+ const result = await execa(`security delete-generic-password -a $USER -s "${storageServiceName}"`, { shell: true, reject: false });
457
+ if (result.exitCode !== 0) {
458
+ throw new Error("Failed to delete keychain entry");
459
+ }
460
+ }
461
+ }
462
+ function normalizeApiKeyForConfig(apiKey) {
463
+ return apiKey.slice(-20);
464
+ }
465
+ var init_authPortable = __esm(() => {
466
+ init_execa();
467
+ init_macOsKeychainHelpers();
468
+ });
469
+
470
+ // src/utils/secureStorage/keychainPrefetch.ts
471
+ import { execFile } from "child_process";
472
+ function spawnSecurity(serviceName) {
473
+ return new Promise((resolve) => {
474
+ execFile("security", ["find-generic-password", "-a", getUsername(), "-w", "-s", serviceName], { encoding: "utf-8", timeout: KEYCHAIN_PREFETCH_TIMEOUT_MS }, (err, stdout) => {
475
+ resolve({
476
+ stdout: err ? null : stdout?.trim() || null,
477
+ timedOut: Boolean(err && "killed" in err && err.killed)
478
+ });
479
+ });
480
+ });
481
+ }
482
+ function startKeychainPrefetch() {
483
+ if (process.platform !== "darwin" || prefetchPromise || isBareMode())
484
+ return;
485
+ const oauthSpawn = spawnSecurity(getMacOsKeychainStorageServiceName(CREDENTIALS_SERVICE_SUFFIX));
486
+ const legacySpawn = spawnSecurity(getMacOsKeychainStorageServiceName());
487
+ prefetchPromise = Promise.all([oauthSpawn, legacySpawn]).then(([oauth, legacy]) => {
488
+ if (!oauth.timedOut)
489
+ primeKeychainCacheFromPrefetch(oauth.stdout);
490
+ if (!legacy.timedOut)
491
+ legacyApiKeyPrefetch = { stdout: legacy.stdout };
492
+ });
493
+ }
494
+ async function ensureKeychainPrefetchCompleted() {
495
+ if (prefetchPromise)
496
+ await prefetchPromise;
497
+ }
498
+ function getLegacyApiKeyPrefetchResult() {
499
+ return legacyApiKeyPrefetch;
500
+ }
501
+ function clearLegacyApiKeyPrefetch() {
502
+ legacyApiKeyPrefetch = null;
503
+ }
504
+ var KEYCHAIN_PREFETCH_TIMEOUT_MS = 1e4, legacyApiKeyPrefetch = null, prefetchPromise = null;
505
+ var init_keychainPrefetch = __esm(() => {
506
+ init_envUtils();
507
+ init_macOsKeychainHelpers();
508
+ });
509
+
336
510
  // node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignMergeValue.js
337
511
  function assignMergeValue(object, key, value) {
338
512
  if (value !== undefined && !eq_default(object[key], value) || value === undefined && !(key in object)) {
@@ -2653,7 +2827,7 @@ var init_types2 = __esm(() => {
2653
2827
  includeCoAuthoredBy: exports_external.boolean().optional().describe("Deprecated: Use attribution instead. " + "Whether to include the AI assistant's co-authored by attribution in commits and PRs (defaults to true)"),
2654
2828
  includeGitInstructions: exports_external.boolean().optional().describe("Include built-in commit and PR workflow instructions in the AI assistant's system prompt (default: true)"),
2655
2829
  permissions: PermissionsSchema().optional().describe("Tool usage permissions configuration"),
2656
- modelType: exports_external.enum(["anthropic", "openai", "gemini", "grok"]).optional().describe('API provider type. "anthropic" uses the Anthropic API (default), "openai" uses the OpenAI Chat Completions API, "gemini" uses the Gemini API, and "grok" uses the xAI Grok API (OpenAI-compatible). ' + 'When set to "openai", configure OPENAI_API_KEY, OPENAI_BASE_URL, and OPENAI_MODEL. When set to "gemini", configure GEMINI_API_KEY and optional GEMINI_BASE_URL. When set to "grok", configure GROK_API_KEY (or XAI_API_KEY), optional GROK_BASE_URL, GROK_MODEL, and GROK_MODEL_MAP.'),
2830
+ modelType: exports_external.enum(["anthropic", "openai"]).optional().describe('API provider type. "anthropic" uses the Anthropic API (default), "openai" uses the OpenAI Chat Completions API. ' + 'When set to "openai", configure OPENAI_API_KEY, OPENAI_BASE_URL, and OPENAI_MODEL.'),
2657
2831
  model: exports_external.string().optional().describe("Override the default model used by the AI assistant"),
2658
2832
  availableModels: exports_external.array(exports_external.string()).optional().describe("Allowlist of models that users can select. " + 'Accepts family aliases ("opus" allows any opus version), ' + 'version prefixes ("opus-4-5" allows only that version), ' + "and full model IDs. " + "If undefined, all models are available. If empty array, only the default model is available. " + "Typically set in managed settings by enterprise administrators."),
2659
2833
  modelOverrides: exports_external.record(exports_external.string(), exports_external.string()).optional().describe('Override mapping from Anthropic model ID (e.g. "claude-opus-4-6") to provider-specific ' + "model ID (e.g. a Bedrock inference profile ARN). Typically set in managed settings by " + "enterprise administrators."),
@@ -3055,12 +3229,12 @@ var init_validation = __esm(() => {
3055
3229
  });
3056
3230
 
3057
3231
  // src/utils/settings/mdm/constants.ts
3058
- import { homedir as homedir3, userInfo } from "os";
3232
+ import { homedir as homedir3, userInfo as userInfo2 } from "os";
3059
3233
  import { join as join4 } from "path";
3060
3234
  function getMacOSPlistPaths() {
3061
3235
  let username = "";
3062
3236
  try {
3063
- username = userInfo().username;
3237
+ username = userInfo2().username;
3064
3238
  } catch {}
3065
3239
  const paths = [];
3066
3240
  if (username) {
@@ -3087,11 +3261,11 @@ var init_constants4 = __esm(() => {
3087
3261
  });
3088
3262
 
3089
3263
  // src/utils/settings/mdm/rawRead.ts
3090
- import { execFile } from "child_process";
3264
+ import { execFile as execFile2 } from "child_process";
3091
3265
  import { existsSync } from "fs";
3092
3266
  function execFilePromise(cmd, args) {
3093
3267
  return new Promise((resolve2) => {
3094
- execFile(cmd, args, { encoding: "utf-8", timeout: MDM_SUBPROCESS_TIMEOUT_MS }, (err, stdout) => {
3268
+ execFile2(cmd, args, { encoding: "utf-8", timeout: MDM_SUBPROCESS_TIMEOUT_MS }, (err, stdout) => {
3095
3269
  resolve2({ stdout: stdout ?? "", code: err ? 1 : 0 });
3096
3270
  });
3097
3271
  });
@@ -3800,288 +3974,33 @@ var init_settings2 = __esm(() => {
3800
3974
  getSettings_DEPRECATED = getInitialSettings;
3801
3975
  });
3802
3976
 
3803
- // src/utils/model/providers.ts
3804
- function getAPIProvider() {
3805
- const modelType = getInitialSettings().modelType;
3806
- if (modelType === "openai")
3807
- return "openai";
3808
- if (modelType === "gemini")
3809
- return "gemini";
3810
- if (modelType === "grok")
3811
- return "grok";
3812
- if (isEnvTruthy(process.env.CLAUDE_CODE_USE_BEDROCK))
3813
- return "bedrock";
3814
- if (isEnvTruthy(process.env.CLAUDE_CODE_USE_VERTEX))
3815
- return "vertex";
3816
- if (isEnvTruthy(process.env.CLAUDE_CODE_USE_FOUNDRY))
3817
- return "foundry";
3818
- if (isEnvTruthy(process.env.CLAUDE_CODE_USE_OPENAI))
3819
- return "openai";
3820
- if (isEnvTruthy(process.env.CLAUDE_CODE_USE_GEMINI))
3821
- return "gemini";
3822
- if (isEnvTruthy(process.env.CLAUDE_CODE_USE_GROK))
3823
- return "grok";
3824
- return "firstParty";
3825
- }
3826
- function getAPIProviderForStatsig() {
3827
- return getAPIProvider();
3828
- }
3829
- function isFirstPartyAnthropicBaseUrl() {
3830
- const baseUrl = process.env.ANTHROPIC_BASE_URL;
3831
- if (!baseUrl) {
3832
- return true;
3833
- }
3834
- try {
3835
- const host = new URL(baseUrl).host;
3836
- const allowedHosts = ["api.anthropic.com"];
3837
- if (process.env.USER_TYPE === "ant") {
3838
- allowedHosts.push("api-staging.anthropic.com");
3977
+ // src/utils/auth.ts
3978
+ function getAuthTokenSource() {
3979
+ if (isBareMode()) {
3980
+ if (getConfiguredApiKeyHelper()) {
3981
+ return { source: "apiKeyHelper", hasToken: true };
3839
3982
  }
3840
- return allowedHosts.includes(host);
3841
- } catch {
3842
- return false;
3983
+ return { source: "none", hasToken: false };
3843
3984
  }
3844
- }
3845
- var init_providers = __esm(() => {
3846
- init_settings2();
3847
- init_envUtils();
3848
- });
3849
-
3850
- // src/utils/authFileDescriptor.ts
3851
- import { mkdirSync, writeFileSync } from "fs";
3852
- function maybePersistTokenForSubprocesses(path, token, tokenName) {
3853
- if (!isEnvTruthy(process.env.CLAUDE_CODE_REMOTE)) {
3854
- return;
3985
+ if (process.env.ANTHROPIC_AUTH_TOKEN) {
3986
+ return { source: "ANTHROPIC_AUTH_TOKEN", hasToken: true };
3855
3987
  }
3856
- try {
3857
- mkdirSync(CCR_TOKEN_DIR, { recursive: true, mode: 448 });
3858
- writeFileSync(path, token, { encoding: "utf8", mode: 384 });
3859
- logForDebugging(`Persisted ${tokenName} to ${path} for subprocess access`);
3860
- } catch (error) {
3861
- logForDebugging(`Failed to persist ${tokenName} to disk (non-fatal): ${errorMessage(error)}`, { level: "error" });
3988
+ const apiKeyHelper = getConfiguredApiKeyHelper();
3989
+ if (apiKeyHelper) {
3990
+ return { source: "apiKeyHelper", hasToken: true };
3862
3991
  }
3863
- }
3864
- function readTokenFromWellKnownFile(path, tokenName) {
3865
- try {
3866
- const fsOps = getFsImplementation();
3867
- const token = fsOps.readFileSync(path, { encoding: "utf8" }).trim();
3868
- if (!token) {
3869
- return null;
3870
- }
3871
- logForDebugging(`Read ${tokenName} from well-known file ${path}`);
3872
- return token;
3873
- } catch (error) {
3874
- if (!isENOENT(error)) {
3875
- logForDebugging(`Failed to read ${tokenName} from ${path}: ${errorMessage(error)}`, { level: "debug" });
3876
- }
3877
- return null;
3992
+ const { source: apiKeySource } = getAnthropicApiKeyWithSource({
3993
+ skipRetrievingKeyFromApiKeyHelper: true
3994
+ });
3995
+ if (apiKeySource !== "none") {
3996
+ return { source: apiKeySource, hasToken: true };
3878
3997
  }
3879
- }
3880
- function getCredentialFromFd({
3881
- envVar,
3882
- wellKnownPath,
3883
- label,
3884
- getCached,
3885
- setCached
3886
- }) {
3887
- const cached = getCached();
3888
- if (cached !== undefined) {
3889
- return cached;
3890
- }
3891
- const fdEnv = process.env[envVar];
3892
- if (!fdEnv) {
3893
- const fromFile = readTokenFromWellKnownFile(wellKnownPath, label);
3894
- setCached(fromFile);
3895
- return fromFile;
3896
- }
3897
- const fd = parseInt(fdEnv, 10);
3898
- if (Number.isNaN(fd)) {
3899
- logForDebugging(`${envVar} must be a valid file descriptor number, got: ${fdEnv}`, { level: "error" });
3900
- setCached(null);
3901
- return null;
3902
- }
3903
- try {
3904
- const fsOps = getFsImplementation();
3905
- const fdPath = process.platform === "darwin" || process.platform === "freebsd" ? `/dev/fd/${fd}` : `/proc/self/fd/${fd}`;
3906
- const token = fsOps.readFileSync(fdPath, { encoding: "utf8" }).trim();
3907
- if (!token) {
3908
- logForDebugging(`File descriptor contained empty ${label}`, {
3909
- level: "error"
3910
- });
3911
- setCached(null);
3912
- return null;
3913
- }
3914
- logForDebugging(`Successfully read ${label} from file descriptor ${fd}`);
3915
- setCached(token);
3916
- maybePersistTokenForSubprocesses(wellKnownPath, token, label);
3917
- return token;
3918
- } catch (error) {
3919
- logForDebugging(`Failed to read ${label} from file descriptor ${fd}: ${errorMessage(error)}`, { level: "error" });
3920
- const fromFile = readTokenFromWellKnownFile(wellKnownPath, label);
3921
- setCached(fromFile);
3922
- return fromFile;
3923
- }
3924
- }
3925
- function getApiKeyFromFileDescriptor() {
3926
- return getCredentialFromFd({
3927
- envVar: "CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR",
3928
- wellKnownPath: CCR_API_KEY_PATH,
3929
- label: "API key",
3930
- getCached: getApiKeyFromFd,
3931
- setCached: setApiKeyFromFd
3932
- });
3933
- }
3934
- var CCR_TOKEN_DIR = "/home/claude/.claude/remote", CCR_OAUTH_TOKEN_PATH, CCR_API_KEY_PATH, CCR_SESSION_INGRESS_TOKEN_PATH;
3935
- var init_authFileDescriptor = __esm(() => {
3936
- init_state();
3937
- init_debug();
3938
- init_envUtils();
3939
- init_errors();
3940
- init_fsOperations();
3941
- CCR_OAUTH_TOKEN_PATH = `${CCR_TOKEN_DIR}/.oauth_token`;
3942
- CCR_API_KEY_PATH = `${CCR_TOKEN_DIR}/.api_key`;
3943
- CCR_SESSION_INGRESS_TOKEN_PATH = `${CCR_TOKEN_DIR}/.session_ingress_token`;
3944
- });
3945
-
3946
- // src/utils/secureStorage/macOsKeychainHelpers.ts
3947
- import { createHash } from "crypto";
3948
- import { userInfo as userInfo2 } from "os";
3949
- function getMacOsKeychainStorageServiceName(serviceSuffix = "") {
3950
- const configDir = getClaudeConfigHomeDir();
3951
- const isDefaultDir = !process.env.CLAUDE_CONFIG_DIR;
3952
- const dirHash = isDefaultDir ? "" : `-${createHash("sha256").update(configDir).digest("hex").substring(0, 8)}`;
3953
- return `Claude Code${getOauthConfig().OAUTH_FILE_SUFFIX}${serviceSuffix}${dirHash}`;
3954
- }
3955
- function getUsername() {
3956
- try {
3957
- return process.env.USER || userInfo2().username;
3958
- } catch {
3959
- return "claude-code-user";
3960
- }
3961
- }
3962
- function clearKeychainCache() {
3963
- keychainCacheState.cache = { data: null, cachedAt: 0 };
3964
- keychainCacheState.generation++;
3965
- keychainCacheState.readInFlight = null;
3966
- }
3967
- function primeKeychainCacheFromPrefetch(stdout) {
3968
- if (keychainCacheState.cache.cachedAt !== 0)
3969
- return;
3970
- let data = null;
3971
- if (stdout) {
3972
- try {
3973
- data = JSON.parse(stdout);
3974
- } catch {
3975
- return;
3976
- }
3977
- }
3978
- keychainCacheState.cache = { data, cachedAt: Date.now() };
3979
- }
3980
- var CREDENTIALS_SERVICE_SUFFIX = "-credentials", KEYCHAIN_CACHE_TTL_MS = 30000, keychainCacheState;
3981
- var init_macOsKeychainHelpers = __esm(() => {
3982
- init_oauth();
3983
- init_envUtils();
3984
- keychainCacheState = {
3985
- cache: { data: null, cachedAt: 0 },
3986
- generation: 0,
3987
- readInFlight: null
3988
- };
3989
- });
3990
-
3991
- // src/utils/authPortable.ts
3992
- async function maybeRemoveApiKeyFromMacOSKeychainThrows() {
3993
- if (process.platform === "darwin") {
3994
- const storageServiceName = getMacOsKeychainStorageServiceName();
3995
- const result = await execa(`security delete-generic-password -a $USER -s "${storageServiceName}"`, { shell: true, reject: false });
3996
- if (result.exitCode !== 0) {
3997
- throw new Error("Failed to delete keychain entry");
3998
- }
3999
- }
4000
- }
4001
- function normalizeApiKeyForConfig(apiKey) {
4002
- return apiKey.slice(-20);
4003
- }
4004
- var init_authPortable = __esm(() => {
4005
- init_execa();
4006
- init_macOsKeychainHelpers();
4007
- });
4008
-
4009
- // src/utils/secureStorage/keychainPrefetch.ts
4010
- import { execFile as execFile2 } from "child_process";
4011
- function spawnSecurity(serviceName) {
4012
- return new Promise((resolve3) => {
4013
- execFile2("security", ["find-generic-password", "-a", getUsername(), "-w", "-s", serviceName], { encoding: "utf-8", timeout: KEYCHAIN_PREFETCH_TIMEOUT_MS }, (err, stdout) => {
4014
- resolve3({
4015
- stdout: err ? null : stdout?.trim() || null,
4016
- timedOut: Boolean(err && "killed" in err && err.killed)
4017
- });
4018
- });
4019
- });
4020
- }
4021
- function startKeychainPrefetch() {
4022
- if (process.platform !== "darwin" || prefetchPromise || isBareMode())
4023
- return;
4024
- const oauthSpawn = spawnSecurity(getMacOsKeychainStorageServiceName(CREDENTIALS_SERVICE_SUFFIX));
4025
- const legacySpawn = spawnSecurity(getMacOsKeychainStorageServiceName());
4026
- prefetchPromise = Promise.all([oauthSpawn, legacySpawn]).then(([oauth, legacy]) => {
4027
- if (!oauth.timedOut)
4028
- primeKeychainCacheFromPrefetch(oauth.stdout);
4029
- if (!legacy.timedOut)
4030
- legacyApiKeyPrefetch = { stdout: legacy.stdout };
4031
- });
4032
- }
4033
- async function ensureKeychainPrefetchCompleted() {
4034
- if (prefetchPromise)
4035
- await prefetchPromise;
4036
- }
4037
- function getLegacyApiKeyPrefetchResult() {
4038
- return legacyApiKeyPrefetch;
4039
- }
4040
- function clearLegacyApiKeyPrefetch() {
4041
- legacyApiKeyPrefetch = null;
4042
- }
4043
- var KEYCHAIN_PREFETCH_TIMEOUT_MS = 1e4, legacyApiKeyPrefetch = null, prefetchPromise = null;
4044
- var init_keychainPrefetch = __esm(() => {
4045
- init_envUtils();
4046
- init_macOsKeychainHelpers();
4047
- });
4048
-
4049
- // src/utils/auth.ts
4050
- function isAnthropicAuthEnabled() {
4051
- return false;
4052
- }
4053
- function getAuthTokenSource() {
4054
- if (isBareMode()) {
4055
- if (getConfiguredApiKeyHelper()) {
4056
- return { source: "apiKeyHelper", hasToken: true };
4057
- }
4058
- return { source: "none", hasToken: false };
4059
- }
4060
- if (process.env.ANTHROPIC_AUTH_TOKEN) {
4061
- return { source: "ANTHROPIC_AUTH_TOKEN", hasToken: true };
4062
- }
4063
- const apiKeyHelper = getConfiguredApiKeyHelper();
4064
- if (apiKeyHelper) {
4065
- return { source: "apiKeyHelper", hasToken: true };
4066
- }
4067
- const { source: apiKeySource } = getAnthropicApiKeyWithSource({
4068
- skipRetrievingKeyFromApiKeyHelper: true
4069
- });
4070
- if (apiKeySource !== "none") {
4071
- return { source: apiKeySource, hasToken: true };
4072
- }
4073
- return { source: "none", hasToken: false };
3998
+ return { source: "none", hasToken: false };
4074
3999
  }
4075
4000
  function getAnthropicApiKey() {
4076
4001
  const { key } = getAnthropicApiKeyWithSource();
4077
4002
  return key;
4078
4003
  }
4079
- function hasAnthropicApiKeyAuth() {
4080
- const { key, source } = getAnthropicApiKeyWithSource({
4081
- skipRetrievingKeyFromApiKeyHelper: true
4082
- });
4083
- return key !== null && source !== "none";
4084
- }
4085
4004
  function getAnthropicApiKeyWithSource(opts = {}) {
4086
4005
  if (isBareMode()) {
4087
4006
  if (process.env.ANTHROPIC_API_KEY) {
@@ -4110,8 +4029,8 @@ function getAnthropicApiKeyWithSource(opts = {}) {
4110
4029
  source: "ANTHROPIC_API_KEY"
4111
4030
  };
4112
4031
  }
4113
- if (!apiKeyEnv && !process.env.CLAUDE_CODE_OAUTH_TOKEN && !process.env.CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR) {
4114
- throw new Error("ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN env var is required");
4032
+ if (!apiKeyEnv) {
4033
+ throw new Error("ANTHROPIC_API_KEY env var is required");
4115
4034
  }
4116
4035
  if (apiKeyEnv) {
4117
4036
  return {
@@ -4175,13 +4094,6 @@ function isApiKeyHelperFromProjectOrLocalSettings() {
4175
4094
  const localSettings = getSettingsForSource("localSettings");
4176
4095
  return projectSettings?.apiKeyHelper === apiKeyHelper || localSettings?.apiKeyHelper === apiKeyHelper;
4177
4096
  }
4178
- function isAwsAuthRefreshFromProjectSettings() {
4179
- return false;
4180
- }
4181
- function isAwsCredentialExportFromProjectSettings() {
4182
- return false;
4183
- }
4184
- function clearAwsCredentialsCache() {}
4185
4097
  function calculateApiKeyHelperTTL() {
4186
4098
  const envTtl = process.env.CLAUDE_CODE_API_KEY_HELPER_TTL_MS;
4187
4099
  if (envTtl) {
@@ -4294,74 +4206,6 @@ function prefetchApiKeyFromApiKeyHelperIfSafe(isNonInteractiveSession) {
4294
4206
  }
4295
4207
  getApiKeyFromApiKeyHelper(isNonInteractiveSession);
4296
4208
  }
4297
- function refreshAwsAuth(_awsAuthRefresh) {
4298
- return Promise.resolve(false);
4299
- }
4300
- function isGcpAuthRefreshFromProjectSettings() {
4301
- return false;
4302
- }
4303
- async function checkGcpCredentialsValid() {
4304
- return false;
4305
- }
4306
- function refreshGcpAuth(_gcpAuthRefresh) {
4307
- return Promise.resolve(false);
4308
- }
4309
- function clearGcpCredentialsCache() {}
4310
- function prefetchGcpCredentialsIfSafe() {}
4311
- function prefetchAwsCredentialsAndBedRockInfoIfSafe() {}
4312
- function isValidApiKey(apiKey) {
4313
- return /^[a-zA-Z0-9-_]+$/.test(apiKey);
4314
- }
4315
- async function saveApiKey(apiKey) {
4316
- if (!isValidApiKey(apiKey)) {
4317
- throw new Error("Invalid API key format. API key must contain only alphanumeric characters, dashes, and underscores.");
4318
- }
4319
- await maybeRemoveApiKeyFromMacOSKeychain();
4320
- let savedToKeychain = false;
4321
- if (process.platform === "darwin") {
4322
- try {
4323
- const storageServiceName = getMacOsKeychainStorageServiceName();
4324
- const username = getUsername();
4325
- const hexValue = Buffer.from(apiKey, "utf-8").toString("hex");
4326
- const command = `add-generic-password -U -a "${username}" -s "${storageServiceName}" -X "${hexValue}"
4327
- `;
4328
- await execa("security", ["-i"], {
4329
- input: command,
4330
- reject: false
4331
- });
4332
- logEvent("tengu_api_key_saved_to_keychain", {});
4333
- savedToKeychain = true;
4334
- } catch (e) {
4335
- logError(e);
4336
- logEvent("tengu_api_key_keychain_error", {
4337
- error: errorMessage(e)
4338
- });
4339
- logEvent("tengu_api_key_saved_to_config", {});
4340
- }
4341
- } else {
4342
- logEvent("tengu_api_key_saved_to_config", {});
4343
- }
4344
- const normalizedKey = normalizeApiKeyForConfig(apiKey);
4345
- saveGlobalConfig((current) => {
4346
- const approved = current.customApiKeyResponses?.approved ?? [];
4347
- return {
4348
- ...current,
4349
- primaryApiKey: savedToKeychain ? current.primaryApiKey : apiKey,
4350
- customApiKeyResponses: {
4351
- ...current.customApiKeyResponses,
4352
- approved: approved.includes(normalizedKey) ? approved : [...approved, normalizedKey],
4353
- rejected: current.customApiKeyResponses?.rejected ?? []
4354
- }
4355
- };
4356
- });
4357
- getApiKeyFromConfigOrMacOSKeychain.cache.clear?.();
4358
- clearLegacyApiKeyPrefetch();
4359
- }
4360
- function isCustomApiKeyApproved(apiKey) {
4361
- const config = getGlobalConfig();
4362
- const normalizedKey = normalizeApiKeyForConfig(apiKey);
4363
- return config.customApiKeyResponses?.approved?.includes(normalizedKey) ?? false;
4364
- }
4365
4209
  async function removeApiKey() {
4366
4210
  await maybeRemoveApiKeyFromMacOSKeychain();
4367
4211
  saveGlobalConfig((current) => ({
@@ -4378,146 +4222,32 @@ async function maybeRemoveApiKeyFromMacOSKeychain() {
4378
4222
  logError(e);
4379
4223
  }
4380
4224
  }
4381
- function saveOAuthTokensIfNeeded(_tokens) {
4382
- return { success: true };
4383
- }
4384
- function clearOAuthTokenCache() {}
4385
- function handleOAuth401Error(_failedAccessToken) {
4386
- return Promise.resolve(false);
4387
- }
4388
- async function getClaudeAIOAuthTokensAsync() {
4389
- return null;
4390
- }
4391
- function checkAndRefreshOAuthTokenIfNeeded(_retryCount = 0, _force = false) {
4392
- return Promise.resolve(false);
4393
- }
4394
- function isClaudeAISubscriber() {
4395
- return false;
4396
- }
4397
- function hasProfileScope() {
4398
- return false;
4399
- }
4400
4225
  function is1PApiCustomer() {
4401
4226
  return true;
4402
4227
  }
4403
- function getOauthAccountInfo() {
4404
- return;
4405
- }
4406
- function isOverageProvisioningAllowed() {
4228
+ function isUsing3PServices() {
4407
4229
  return false;
4408
4230
  }
4409
- function hasOpusAccess() {
4410
- return true;
4411
- }
4412
- function getSubscriptionType() {
4413
- return null;
4414
- }
4415
- function isMaxSubscriber() {
4416
- return getSubscriptionType() === "max";
4417
- }
4418
- function isTeamSubscriber() {
4419
- return getSubscriptionType() === "team";
4420
- }
4421
- function isTeamPremiumSubscriber() {
4422
- return getSubscriptionType() === "team" && getRateLimitTier() === "default_claude_max_5x";
4423
- }
4424
- function isEnterpriseSubscriber() {
4425
- return getSubscriptionType() === "enterprise";
4426
- }
4427
- function isProSubscriber() {
4428
- return getSubscriptionType() === "pro";
4429
- }
4430
- function getRateLimitTier() {
4431
- if (!isAnthropicAuthEnabled()) {
4432
- return null;
4433
- }
4434
- const oauthTokens = getClaudeAIOAuthTokens();
4435
- if (!oauthTokens) {
4436
- return null;
4231
+ function getAccountInformation() {
4232
+ const apiProvider = getAPIProvider();
4233
+ if (apiProvider !== "firstParty") {
4234
+ return;
4437
4235
  }
4438
- return oauthTokens.rateLimitTier ?? null;
4439
- }
4440
- function getSubscriptionName() {
4441
- const subscriptionType = getSubscriptionType();
4442
- switch (subscriptionType) {
4443
- case "enterprise":
4444
- return "Claude Enterprise";
4445
- case "team":
4446
- return "Claude Team";
4447
- case "max":
4448
- return "Claude Max";
4449
- case "pro":
4450
- return "Claude Pro";
4451
- default:
4452
- return "Claude API";
4236
+ const { source: authTokenSource } = getAuthTokenSource();
4237
+ const accountInfo = {};
4238
+ accountInfo.tokenSource = authTokenSource;
4239
+ const { key: apiKey, source: apiKeySource } = getAnthropicApiKeyWithSource();
4240
+ if (apiKey) {
4241
+ accountInfo.apiKeySource = apiKeySource;
4453
4242
  }
4243
+ return accountInfo;
4454
4244
  }
4455
- function isUsing3PServices() {
4456
- return false;
4457
- }
4458
- function getConfiguredOtelHeadersHelper() {
4459
- const mergedSettings = getSettings_DEPRECATED() || {};
4460
- return mergedSettings.otelHeadersHelper;
4461
- }
4462
- function isOtelHeadersHelperFromProjectOrLocalSettings() {
4463
- const otelHeadersHelper = getConfiguredOtelHeadersHelper();
4464
- if (!otelHeadersHelper) {
4465
- return false;
4466
- }
4467
- const projectSettings = getSettingsForSource("projectSettings");
4468
- const localSettings = getSettingsForSource("localSettings");
4469
- return projectSettings?.otelHeadersHelper === otelHeadersHelper || localSettings?.otelHeadersHelper === otelHeadersHelper;
4470
- }
4471
- function getOtelHeadersFromHelper() {
4472
- return {};
4473
- }
4474
- function isConsumerSubscriber() {
4475
- return false;
4476
- }
4477
- function getAccountInformation() {
4478
- const apiProvider = getAPIProvider();
4479
- if (apiProvider !== "firstParty") {
4480
- return;
4481
- }
4482
- const { source: authTokenSource } = getAuthTokenSource();
4483
- const accountInfo = {};
4484
- if (authTokenSource === "CLAUDE_CODE_OAUTH_TOKEN" || authTokenSource === "CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR") {
4485
- accountInfo.tokenSource = authTokenSource;
4486
- } else if (isClaudeAISubscriber()) {
4487
- accountInfo.subscription = getSubscriptionName();
4488
- } else {
4489
- accountInfo.tokenSource = authTokenSource;
4490
- }
4491
- const { key: apiKey, source: apiKeySource } = getAnthropicApiKeyWithSource();
4492
- if (apiKey) {
4493
- accountInfo.apiKeySource = apiKeySource;
4494
- }
4495
- if (authTokenSource === "claude.ai" || apiKeySource === "/login managed key") {
4496
- const orgName = getOauthAccountInfo()?.organizationName;
4497
- if (orgName) {
4498
- accountInfo.organization = orgName;
4499
- }
4500
- }
4501
- const email = getOauthAccountInfo()?.emailAddress;
4502
- if ((authTokenSource === "claude.ai" || apiKeySource === "/login managed key") && email) {
4503
- accountInfo.email = email;
4504
- }
4505
- return accountInfo;
4506
- }
4507
- async function validateForceLoginOrg() {
4508
- return { valid: true };
4509
- }
4510
- var DEFAULT_API_KEY_HELPER_TTL, refreshAndGetAwsCredentials = async () => {
4511
- return null;
4512
- }, _apiKeyHelperCache = null, _apiKeyHelperInflight = null, _apiKeyHelperEpoch = 0, DEFAULT_AWS_STS_TTL, AWS_AUTH_REFRESH_TIMEOUT_MS, DEFAULT_GCP_CREDENTIAL_TTL, GCP_AUTH_REFRESH_TIMEOUT_MS, refreshGcpCredentialsIfNeeded = async () => {
4513
- return false;
4514
- }, getApiKeyFromConfigOrMacOSKeychain, getClaudeAIOAuthTokens, pending401Handlers, DEFAULT_OTEL_HEADERS_DEBOUNCE_MS;
4245
+ var DEFAULT_API_KEY_HELPER_TTL, _apiKeyHelperCache = null, _apiKeyHelperInflight = null, _apiKeyHelperEpoch = 0, getApiKeyFromConfigOrMacOSKeychain;
4515
4246
  var init_auth = __esm(() => {
4516
4247
  init_source();
4517
4248
  init_execa();
4518
4249
  init_memoize();
4519
4250
  init_analytics();
4520
- init_providers();
4521
4251
  init_state();
4522
4252
  init_authFileDescriptor();
4523
4253
  init_authPortable();
@@ -4531,10 +4261,6 @@ var init_auth = __esm(() => {
4531
4261
  init_macOsKeychainHelpers();
4532
4262
  init_settings2();
4533
4263
  DEFAULT_API_KEY_HELPER_TTL = 5 * 60 * 1000;
4534
- DEFAULT_AWS_STS_TTL = 60 * 60 * 1000;
4535
- AWS_AUTH_REFRESH_TIMEOUT_MS = 3 * 60 * 1000;
4536
- DEFAULT_GCP_CREDENTIAL_TTL = 60 * 60 * 1000;
4537
- GCP_AUTH_REFRESH_TIMEOUT_MS = 3 * 60 * 1000;
4538
4264
  getApiKeyFromConfigOrMacOSKeychain = memoize_default(() => {
4539
4265
  if (isBareMode())
4540
4266
  return null;
@@ -4562,11 +4288,6 @@ var init_auth = __esm(() => {
4562
4288
  }
4563
4289
  return { key: config.primaryApiKey, source: "/login managed key" };
4564
4290
  });
4565
- getClaudeAIOAuthTokens = memoize_default(() => {
4566
- return null;
4567
- });
4568
- pending401Handlers = new Map;
4569
- DEFAULT_OTEL_HEADERS_DEBOUNCE_MS = 29 * 60 * 1000;
4570
4291
  });
4571
4292
 
4572
4293
  // src/utils/userAgent.ts
@@ -4614,21 +4335,6 @@ function getWebFetchUserAgent() {
4614
4335
  return `Claude-User (${getClaudeCodeUserAgent()}; +https://support.anthropic.com/)`;
4615
4336
  }
4616
4337
  function getAuthHeaders() {
4617
- if (isClaudeAISubscriber()) {
4618
- const oauthTokens = getClaudeAIOAuthTokens();
4619
- if (!oauthTokens?.accessToken) {
4620
- return {
4621
- headers: {},
4622
- error: "No OAuth token available"
4623
- };
4624
- }
4625
- return {
4626
- headers: {
4627
- Authorization: `Bearer ${oauthTokens.accessToken}`,
4628
- "anthropic-beta": OAUTH_BETA_HEADER
4629
- }
4630
- };
4631
- }
4632
4338
  const apiKey = getAnthropicApiKey();
4633
4339
  if (!apiKey) {
4634
4340
  return {
@@ -4642,26 +4348,7 @@ function getAuthHeaders() {
4642
4348
  }
4643
4349
  };
4644
4350
  }
4645
- async function withOAuth401Retry(request, opts) {
4646
- try {
4647
- return await request();
4648
- } catch (err) {
4649
- if (!axios_default.isAxiosError(err))
4650
- throw err;
4651
- const status = err.response?.status;
4652
- const isAuthError = status === 401 || opts?.also403Revoked && status === 403 && typeof err.response?.data === "string" && err.response.data.includes("OAuth token has been revoked");
4653
- if (!isAuthError)
4654
- throw err;
4655
- const failedAccessToken = getClaudeAIOAuthTokens()?.accessToken;
4656
- if (!failedAccessToken)
4657
- throw err;
4658
- await handleOAuth401Error(failedAccessToken);
4659
- return await request();
4660
- }
4661
- }
4662
4351
  var init_http = __esm(() => {
4663
- init_axios();
4664
- init_oauth();
4665
4352
  init_auth();
4666
4353
  init_userAgent();
4667
4354
  init_workloadContext();
@@ -4714,12 +4401,13 @@ async function getEmailAsync() {
4714
4401
  }
4715
4402
  return getGitEmail();
4716
4403
  }
4717
- var cachedEmail = null, emailFetchPromise = null, getCoreUserData, getGitEmail;
4404
+ var getOauthAccountInfo = () => {
4405
+ return;
4406
+ }, cachedEmail = null, emailFetchPromise = null, getCoreUserData, getGitEmail;
4718
4407
  var init_user = __esm(() => {
4719
4408
  init_execa();
4720
4409
  init_memoize();
4721
4410
  init_state();
4722
- init_auth();
4723
4411
  init_config();
4724
4412
  init_cwd();
4725
4413
  init_env();
@@ -4730,16 +4418,6 @@ var init_user = __esm(() => {
4730
4418
  let subscriptionType;
4731
4419
  let rateLimitTier;
4732
4420
  let firstTokenTime;
4733
- if (includeAnalyticsMetadata) {
4734
- subscriptionType = getSubscriptionType() ?? undefined;
4735
- rateLimitTier = getRateLimitTier() ?? undefined;
4736
- if (subscriptionType && config.claudeCodeFirstTokenDate) {
4737
- const configFirstTokenTime = new Date(config.claudeCodeFirstTokenDate).getTime();
4738
- if (!isNaN(configFirstTokenTime)) {
4739
- firstTokenTime = configFirstTokenTime;
4740
- }
4741
- }
4742
- }
4743
4421
  const oauthAccount = getOauthAccountInfo();
4744
4422
  const organizationUuid = oauthAccount?.organizationUuid;
4745
4423
  const accountUuid = oauthAccount?.accountUuid;
@@ -6146,2282 +5824,4 @@ var init_config = __esm(() => {
6146
5824
  _wouldLoseAuthStateForTesting = wouldLoseAuthState;
6147
5825
  });
6148
5826
 
6149
- // src/utils/sequential.ts
6150
- function sequential(fn) {
6151
- const queue = [];
6152
- let processing = false;
6153
- async function processQueue() {
6154
- if (processing)
6155
- return;
6156
- if (queue.length === 0)
6157
- return;
6158
- processing = true;
6159
- while (queue.length > 0) {
6160
- const { args, resolve: resolve4, reject, context } = queue.shift();
6161
- try {
6162
- const result = await fn.apply(context, args);
6163
- resolve4(result);
6164
- } catch (error) {
6165
- reject(error);
6166
- }
6167
- }
6168
- processing = false;
6169
- if (queue.length > 0) {
6170
- processQueue();
6171
- }
6172
- }
6173
- return function(...args) {
6174
- return new Promise((resolve4, reject) => {
6175
- queue.push({ args, resolve: resolve4, reject, context: this });
6176
- processQueue();
6177
- });
6178
- };
6179
- }
6180
- var init_sequential = () => {};
6181
-
6182
- // src/utils/model/bedrock.ts
6183
- function isFoundationModel(modelId) {
6184
- return modelId.startsWith("anthropic.");
6185
- }
6186
- function extractModelIdFromArn(modelId) {
6187
- if (!modelId.startsWith("arn:")) {
6188
- return modelId;
6189
- }
6190
- const lastSlashIndex = modelId.lastIndexOf("/");
6191
- if (lastSlashIndex === -1) {
6192
- return modelId;
6193
- }
6194
- return modelId.substring(lastSlashIndex + 1);
6195
- }
6196
- function getBedrockRegionPrefix(modelId) {
6197
- const effectiveModelId = extractModelIdFromArn(modelId);
6198
- for (const prefix of BEDROCK_REGION_PREFIXES) {
6199
- if (effectiveModelId.startsWith(`${prefix}.anthropic.`)) {
6200
- return prefix;
6201
- }
6202
- }
6203
- return;
6204
- }
6205
- function applyBedrockRegionPrefix(modelId, prefix) {
6206
- const existingPrefix = getBedrockRegionPrefix(modelId);
6207
- if (existingPrefix) {
6208
- return modelId.replace(`${existingPrefix}.`, `${prefix}.`);
6209
- }
6210
- if (isFoundationModel(modelId)) {
6211
- return `${prefix}.${modelId}`;
6212
- }
6213
- return modelId;
6214
- }
6215
- function findFirstMatch(_profiles, _substring) {
6216
- return null;
6217
- }
6218
- var BEDROCK_REGION_PREFIXES, getBedrockInferenceProfiles = async function() {
6219
- return [];
6220
- }, getInferenceProfileBackingModel = async function(_profileId) {
6221
- return null;
6222
- };
6223
- var init_bedrock = __esm(() => {
6224
- BEDROCK_REGION_PREFIXES = ["us", "eu", "apac", "global"];
6225
- });
6226
-
6227
- // src/utils/model/configs.ts
6228
- 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;
6229
- var init_configs = __esm(() => {
6230
- CLAUDE_3_7_SONNET_CONFIG = {
6231
- firstParty: "claude-3-7-sonnet-20250219",
6232
- bedrock: "us.anthropic.claude-3-7-sonnet-20250219-v1:0",
6233
- vertex: "claude-3-7-sonnet@20250219",
6234
- foundry: "claude-3-7-sonnet",
6235
- openai: "claude-3-7-sonnet-20250219",
6236
- gemini: "claude-3-7-sonnet-20250219"
6237
- };
6238
- CLAUDE_3_5_V2_SONNET_CONFIG = {
6239
- firstParty: "claude-3-5-sonnet-20241022",
6240
- bedrock: "anthropic.claude-3-5-sonnet-20241022-v2:0",
6241
- vertex: "claude-3-5-sonnet-v2@20241022",
6242
- foundry: "claude-3-5-sonnet",
6243
- openai: "claude-3-5-sonnet-20241022",
6244
- gemini: "claude-3-5-sonnet-20241022"
6245
- };
6246
- CLAUDE_3_5_HAIKU_CONFIG = {
6247
- firstParty: "claude-3-5-haiku-20241022",
6248
- bedrock: "us.anthropic.claude-3-5-haiku-20241022-v1:0",
6249
- vertex: "claude-3-5-haiku@20241022",
6250
- foundry: "claude-3-5-haiku",
6251
- openai: "claude-3-5-haiku-20241022",
6252
- gemini: "claude-3-5-haiku-20241022"
6253
- };
6254
- CLAUDE_HAIKU_4_5_CONFIG = {
6255
- firstParty: "claude-haiku-4-5-20251001",
6256
- bedrock: "us.anthropic.claude-haiku-4-5-20251001-v1:0",
6257
- vertex: "claude-haiku-4-5@20251001",
6258
- foundry: "claude-haiku-4-5",
6259
- openai: "claude-haiku-4-5-20251001",
6260
- gemini: "claude-haiku-4-5-20251001"
6261
- };
6262
- CLAUDE_SONNET_4_CONFIG = {
6263
- firstParty: "claude-sonnet-4-20250514",
6264
- bedrock: "us.anthropic.claude-sonnet-4-20250514-v1:0",
6265
- vertex: "claude-sonnet-4@20250514",
6266
- foundry: "claude-sonnet-4",
6267
- openai: "claude-sonnet-4-20250514",
6268
- gemini: "claude-sonnet-4-20250514"
6269
- };
6270
- CLAUDE_SONNET_4_5_CONFIG = {
6271
- firstParty: "claude-sonnet-4-5-20250929",
6272
- bedrock: "us.anthropic.claude-sonnet-4-5-20250929-v1:0",
6273
- vertex: "claude-sonnet-4-5@20250929",
6274
- foundry: "claude-sonnet-4-5",
6275
- openai: "claude-sonnet-4-5-20250929",
6276
- gemini: "claude-sonnet-4-5-20250929"
6277
- };
6278
- CLAUDE_OPUS_4_CONFIG = {
6279
- firstParty: "claude-opus-4-20250514",
6280
- bedrock: "us.anthropic.claude-opus-4-20250514-v1:0",
6281
- vertex: "claude-opus-4@20250514",
6282
- foundry: "claude-opus-4",
6283
- openai: "claude-opus-4-20250514",
6284
- gemini: "claude-opus-4-20250514"
6285
- };
6286
- CLAUDE_OPUS_4_1_CONFIG = {
6287
- firstParty: "claude-opus-4-1-20250805",
6288
- bedrock: "us.anthropic.claude-opus-4-1-20250805-v1:0",
6289
- vertex: "claude-opus-4-1@20250805",
6290
- foundry: "claude-opus-4-1",
6291
- openai: "claude-opus-4-1-20250805",
6292
- gemini: "claude-opus-4-1-20250805"
6293
- };
6294
- CLAUDE_OPUS_4_5_CONFIG = {
6295
- firstParty: "claude-opus-4-5-20251101",
6296
- bedrock: "us.anthropic.claude-opus-4-5-20251101-v1:0",
6297
- vertex: "claude-opus-4-5@20251101",
6298
- foundry: "claude-opus-4-5",
6299
- openai: "claude-opus-4-5-20251101",
6300
- gemini: "claude-opus-4-5-20251101"
6301
- };
6302
- CLAUDE_OPUS_4_6_CONFIG = {
6303
- firstParty: "claude-opus-4-6",
6304
- bedrock: "us.anthropic.claude-opus-4-6-v1",
6305
- vertex: "claude-opus-4-6",
6306
- foundry: "claude-opus-4-6",
6307
- openai: "claude-opus-4-6",
6308
- gemini: "claude-opus-4-6"
6309
- };
6310
- CLAUDE_SONNET_4_6_CONFIG = {
6311
- firstParty: "claude-sonnet-4-6",
6312
- bedrock: "us.anthropic.claude-sonnet-4-6",
6313
- vertex: "claude-sonnet-4-6",
6314
- foundry: "claude-sonnet-4-6",
6315
- openai: "claude-sonnet-4-6",
6316
- gemini: "claude-sonnet-4-6"
6317
- };
6318
- ALL_MODEL_CONFIGS = {
6319
- haiku35: CLAUDE_3_5_HAIKU_CONFIG,
6320
- haiku45: CLAUDE_HAIKU_4_5_CONFIG,
6321
- sonnet35: CLAUDE_3_5_V2_SONNET_CONFIG,
6322
- sonnet37: CLAUDE_3_7_SONNET_CONFIG,
6323
- sonnet40: CLAUDE_SONNET_4_CONFIG,
6324
- sonnet45: CLAUDE_SONNET_4_5_CONFIG,
6325
- sonnet46: CLAUDE_SONNET_4_6_CONFIG,
6326
- opus40: CLAUDE_OPUS_4_CONFIG,
6327
- opus41: CLAUDE_OPUS_4_1_CONFIG,
6328
- opus45: CLAUDE_OPUS_4_5_CONFIG,
6329
- opus46: CLAUDE_OPUS_4_6_CONFIG
6330
- };
6331
- CANONICAL_MODEL_IDS = Object.values(ALL_MODEL_CONFIGS).map((c) => c.firstParty);
6332
- CANONICAL_ID_TO_KEY = Object.fromEntries(Object.entries(ALL_MODEL_CONFIGS).map(([key, cfg]) => [cfg.firstParty, key]));
6333
- });
6334
-
6335
- // src/utils/model/modelStrings.ts
6336
- function getBuiltinModelStrings(provider) {
6337
- const out = {};
6338
- for (const key of MODEL_KEYS) {
6339
- out[key] = ALL_MODEL_CONFIGS[key][provider];
6340
- }
6341
- return out;
6342
- }
6343
- async function getBedrockModelStrings() {
6344
- const fallback = getBuiltinModelStrings("bedrock");
6345
- let profiles;
6346
- try {
6347
- profiles = await getBedrockInferenceProfiles();
6348
- } catch (error) {
6349
- logError(error);
6350
- return fallback;
6351
- }
6352
- if (!profiles?.length) {
6353
- return fallback;
6354
- }
6355
- const out = {};
6356
- for (const key of MODEL_KEYS) {
6357
- const needle = ALL_MODEL_CONFIGS[key].firstParty;
6358
- out[key] = findFirstMatch(profiles, needle) || fallback[key];
6359
- }
6360
- return out;
6361
- }
6362
- function applyModelOverrides(ms) {
6363
- const overrides = getInitialSettings().modelOverrides;
6364
- if (!overrides) {
6365
- return ms;
6366
- }
6367
- const out = { ...ms };
6368
- for (const [canonicalId, override] of Object.entries(overrides)) {
6369
- const key = CANONICAL_ID_TO_KEY[canonicalId];
6370
- if (key && override) {
6371
- out[key] = override;
6372
- }
6373
- }
6374
- return out;
6375
- }
6376
- function resolveOverriddenModel(modelId) {
6377
- let overrides;
6378
- try {
6379
- overrides = getInitialSettings().modelOverrides;
6380
- } catch {
6381
- return modelId;
6382
- }
6383
- if (!overrides) {
6384
- return modelId;
6385
- }
6386
- for (const [canonicalId, override] of Object.entries(overrides)) {
6387
- if (override === modelId) {
6388
- return canonicalId;
6389
- }
6390
- }
6391
- return modelId;
6392
- }
6393
- function initModelStrings() {
6394
- const ms = getModelStrings();
6395
- if (ms !== null) {
6396
- return;
6397
- }
6398
- if (getAPIProvider() !== "bedrock") {
6399
- setModelStrings(getBuiltinModelStrings(getAPIProvider()));
6400
- return;
6401
- }
6402
- updateBedrockModelStrings();
6403
- }
6404
- function getModelStrings2() {
6405
- const ms = getModelStrings();
6406
- if (ms === null) {
6407
- initModelStrings();
6408
- return applyModelOverrides(getBuiltinModelStrings(getAPIProvider()));
6409
- }
6410
- return applyModelOverrides(ms);
6411
- }
6412
- async function ensureModelStringsInitialized() {
6413
- const ms = getModelStrings();
6414
- if (ms !== null) {
6415
- return;
6416
- }
6417
- if (getAPIProvider() !== "bedrock") {
6418
- setModelStrings(getBuiltinModelStrings(getAPIProvider()));
6419
- return;
6420
- }
6421
- await updateBedrockModelStrings();
6422
- }
6423
- var MODEL_KEYS, updateBedrockModelStrings;
6424
- var init_modelStrings = __esm(() => {
6425
- init_state();
6426
- init_log();
6427
- init_sequential();
6428
- init_settings2();
6429
- init_bedrock();
6430
- init_configs();
6431
- init_providers();
6432
- MODEL_KEYS = Object.keys(ALL_MODEL_CONFIGS);
6433
- updateBedrockModelStrings = sequential(async () => {
6434
- if (getModelStrings() !== null) {
6435
- return;
6436
- }
6437
- try {
6438
- const ms = await getBedrockModelStrings();
6439
- setModelStrings(ms);
6440
- } catch (error) {
6441
- logError(error);
6442
- }
6443
- });
6444
- });
6445
-
6446
- // src/utils/billing.ts
6447
- function hasConsoleBillingAccess() {
6448
- if (isEnvTruthy(process.env.DISABLE_COST_WARNINGS)) {
6449
- return false;
6450
- }
6451
- const isSubscriber = isClaudeAISubscriber();
6452
- if (isSubscriber)
6453
- return false;
6454
- const authSource = getAuthTokenSource();
6455
- const hasApiKey = getAnthropicApiKey() !== null;
6456
- if (!authSource.hasToken && !hasApiKey) {
6457
- return false;
6458
- }
6459
- const config = getGlobalConfig();
6460
- const orgRole = config.oauthAccount?.organizationRole;
6461
- const workspaceRole = config.oauthAccount?.workspaceRole;
6462
- if (!orgRole || !workspaceRole) {
6463
- return false;
6464
- }
6465
- return ["admin", "billing"].includes(orgRole) || ["workspace_admin", "workspace_billing"].includes(workspaceRole);
6466
- }
6467
- function setMockBillingAccessOverride(value) {
6468
- mockBillingAccessOverride = value;
6469
- }
6470
- function hasClaudeAiBillingAccess() {
6471
- if (mockBillingAccessOverride !== null) {
6472
- return mockBillingAccessOverride;
6473
- }
6474
- if (!isClaudeAISubscriber()) {
6475
- return false;
6476
- }
6477
- const subscriptionType = getSubscriptionType();
6478
- if (subscriptionType === "max" || subscriptionType === "pro") {
6479
- return true;
6480
- }
6481
- const config = getGlobalConfig();
6482
- const orgRole = config.oauthAccount?.organizationRole;
6483
- return !!orgRole && ["admin", "billing", "owner", "primary_owner"].includes(orgRole);
6484
- }
6485
- var mockBillingAccessOverride = null;
6486
- var init_billing = __esm(() => {
6487
- init_auth();
6488
- init_config();
6489
- init_envUtils();
6490
- });
6491
-
6492
- // src/services/mockRateLimits.ts
6493
- function getMockHeaderless429Message() {
6494
- if (process.env.USER_TYPE !== "ant") {
6495
- return null;
6496
- }
6497
- if (process.env.CLAUDE_MOCK_HEADERLESS_429) {
6498
- return process.env.CLAUDE_MOCK_HEADERLESS_429;
6499
- }
6500
- if (!mockEnabled) {
6501
- return null;
6502
- }
6503
- return mockHeaderless429Message;
6504
- }
6505
- function getMockHeaders() {
6506
- if (!mockEnabled || process.env.USER_TYPE !== "ant" || Object.keys(mockHeaders).length === 0) {
6507
- return null;
6508
- }
6509
- return mockHeaders;
6510
- }
6511
- function clearMockHeaders() {
6512
- mockHeaders = {};
6513
- exceededLimits = [];
6514
- mockSubscriptionType = null;
6515
- mockFastModeRateLimitDurationMs = null;
6516
- mockFastModeRateLimitExpiresAt = null;
6517
- mockHeaderless429Message = null;
6518
- setMockBillingAccessOverride(null);
6519
- mockEnabled = false;
6520
- }
6521
- function applyMockHeaders(headers) {
6522
- const mock = getMockHeaders();
6523
- if (!mock) {
6524
- return headers;
6525
- }
6526
- const newHeaders = new globalThis.Headers(headers);
6527
- Object.entries(mock).forEach(([key, value]) => {
6528
- if (value !== undefined) {
6529
- newHeaders.set(key, value);
6530
- }
6531
- });
6532
- return newHeaders;
6533
- }
6534
- function shouldProcessMockLimits() {
6535
- if (process.env.USER_TYPE !== "ant") {
6536
- return false;
6537
- }
6538
- return mockEnabled || Boolean(process.env.CLAUDE_MOCK_HEADERLESS_429);
6539
- }
6540
- function isMockFastModeRateLimitScenario() {
6541
- return mockFastModeRateLimitDurationMs !== null;
6542
- }
6543
- function checkMockFastModeRateLimit(isFastModeActive) {
6544
- if (mockFastModeRateLimitDurationMs === null) {
6545
- return null;
6546
- }
6547
- if (!isFastModeActive) {
6548
- return null;
6549
- }
6550
- if (mockFastModeRateLimitExpiresAt !== null && Date.now() >= mockFastModeRateLimitExpiresAt) {
6551
- clearMockHeaders();
6552
- return null;
6553
- }
6554
- if (mockFastModeRateLimitExpiresAt === null) {
6555
- mockFastModeRateLimitExpiresAt = Date.now() + mockFastModeRateLimitDurationMs;
6556
- }
6557
- const remainingMs = mockFastModeRateLimitExpiresAt - Date.now();
6558
- const headersToSend = { ...mockHeaders };
6559
- headersToSend["retry-after"] = String(Math.max(1, Math.ceil(remainingMs / 1000)));
6560
- return headersToSend;
6561
- }
6562
- var mockHeaders, mockEnabled = false, mockHeaderless429Message = null, mockSubscriptionType = null, mockFastModeRateLimitDurationMs = null, mockFastModeRateLimitExpiresAt = null, exceededLimits;
6563
- var init_mockRateLimits = __esm(() => {
6564
- init_billing();
6565
- mockHeaders = {};
6566
- exceededLimits = [];
6567
- });
6568
-
6569
- // src/utils/model/antModels.ts
6570
- function getAntModelOverrideConfig() {
6571
- if (process.env.USER_TYPE !== "ant") {
6572
- return null;
6573
- }
6574
- return getFeatureValue_CACHED_MAY_BE_STALE("tengu_ant_model_override", null);
6575
- }
6576
- function getAntModels() {
6577
- if (process.env.USER_TYPE !== "ant") {
6578
- return [];
6579
- }
6580
- return getAntModelOverrideConfig()?.antModels ?? [];
6581
- }
6582
- function resolveAntModel(model) {
6583
- if (process.env.USER_TYPE !== "ant") {
6584
- return;
6585
- }
6586
- if (model === undefined) {
6587
- return;
6588
- }
6589
- const lower = model.toLowerCase();
6590
- return getAntModels().find((m) => m.alias === model || lower.includes(m.model.toLowerCase()));
6591
- }
6592
- var init_antModels = __esm(() => {
6593
- init_growthbook();
6594
- });
6595
-
6596
- // src/constants/betas.ts
6597
- 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", WEB_SEARCH_BETA_HEADER = "web-search-2025-03-05", TOOL_SEARCH_BETA_HEADER_1P = "advanced-tool-use-2025-11-20", TOOL_SEARCH_BETA_HEADER_3P = "tool-search-tool-2025-10-19", 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", BEDROCK_EXTRA_PARAMS_HEADERS, VERTEX_COUNT_TOKENS_ALLOWED_BETAS;
6598
- var init_betas = __esm(() => {
6599
- CLI_INTERNAL_BETA_HEADER = process.env.USER_TYPE === "ant" ? "cli-internal-2026-02-09" : "";
6600
- BEDROCK_EXTRA_PARAMS_HEADERS = new Set([
6601
- INTERLEAVED_THINKING_BETA_HEADER,
6602
- CONTEXT_1M_BETA_HEADER,
6603
- TOOL_SEARCH_BETA_HEADER_3P
6604
- ]);
6605
- VERTEX_COUNT_TOKENS_ALLOWED_BETAS = new Set([
6606
- CLAUDE_CODE_20250219_BETA_HEADER,
6607
- INTERLEAVED_THINKING_BETA_HEADER,
6608
- CONTEXT_MANAGEMENT_BETA_HEADER
6609
- ]);
6610
- });
6611
-
6612
- // src/services/api/client.ts
6613
- import { randomUUID } from "crypto";
6614
- function createStderrLogger() {
6615
- return {
6616
- error: (msg, ...args) => console.error("[Anthropic SDK ERROR]", msg, ...args),
6617
- warn: (msg, ...args) => console.error("[Anthropic SDK WARN]", msg, ...args),
6618
- info: (msg, ...args) => console.error("[Anthropic SDK INFO]", msg, ...args),
6619
- debug: (msg, ...args) => console.error("[Anthropic SDK DEBUG]", msg, ...args)
6620
- };
6621
- }
6622
- async function getAnthropicClient({
6623
- apiKey,
6624
- maxRetries,
6625
- model,
6626
- fetchOverride,
6627
- source
6628
- }) {
6629
- const containerId = process.env.CLAUDE_CODE_CONTAINER_ID;
6630
- const remoteSessionId = process.env.CLAUDE_CODE_REMOTE_SESSION_ID;
6631
- const clientApp = process.env.CLAUDE_AGENT_SDK_CLIENT_APP;
6632
- const customHeaders = getCustomHeaders();
6633
- const defaultHeaders = {
6634
- "x-app": "cli",
6635
- "User-Agent": getUserAgent(),
6636
- "X-Claude-Code-Session-Id": getSessionId(),
6637
- ...customHeaders,
6638
- ...containerId ? { "x-claude-remote-container-id": containerId } : {},
6639
- ...remoteSessionId ? { "x-claude-remote-session-id": remoteSessionId } : {},
6640
- ...clientApp ? { "x-client-app": clientApp } : {}
6641
- };
6642
- logForDebugging(`[API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: ${!!process.env.ANTHROPIC_CUSTOM_HEADERS}, has Authorization header: ${!!customHeaders["Authorization"]}`);
6643
- const additionalProtectionEnabled = isEnvTruthy(process.env.CLAUDE_CODE_ADDITIONAL_PROTECTION);
6644
- if (additionalProtectionEnabled) {
6645
- defaultHeaders["x-anthropic-additional-protection"] = "true";
6646
- }
6647
- logForDebugging("[API:auth] Configuring API key headers");
6648
- await configureApiKeyHeaders(defaultHeaders, getIsNonInteractiveSession());
6649
- const resolvedFetch = buildFetch(fetchOverride, source);
6650
- const ARGS = {
6651
- defaultHeaders,
6652
- maxRetries,
6653
- timeout: parseInt(process.env.API_TIMEOUT_MS || String(600 * 1000), 10),
6654
- dangerouslyAllowBrowser: true,
6655
- fetchOptions: getProxyFetchOptions({
6656
- forAnthropicAPI: true
6657
- }),
6658
- ...resolvedFetch && {
6659
- fetch: resolvedFetch
6660
- }
6661
- };
6662
- const clientConfig = {
6663
- apiKey: apiKey || getAnthropicApiKey(),
6664
- ...ARGS,
6665
- ...isDebugToStdErr() && { logger: createStderrLogger() }
6666
- };
6667
- return new Anthropic(clientConfig);
6668
- }
6669
- async function configureApiKeyHeaders(headers, isNonInteractiveSession) {
6670
- const token = process.env.ANTHROPIC_AUTH_TOKEN || await getApiKeyFromApiKeyHelper(isNonInteractiveSession);
6671
- if (token) {
6672
- headers["Authorization"] = `Bearer ${token}`;
6673
- }
6674
- }
6675
- function getCustomHeaders() {
6676
- const customHeaders = {};
6677
- const customHeadersEnv = process.env.ANTHROPIC_CUSTOM_HEADERS;
6678
- if (!customHeadersEnv)
6679
- return customHeaders;
6680
- const headerStrings = customHeadersEnv.split(/\n|\r\n/);
6681
- for (const headerString of headerStrings) {
6682
- if (!headerString.trim())
6683
- continue;
6684
- const colonIdx = headerString.indexOf(":");
6685
- if (colonIdx === -1)
6686
- continue;
6687
- const name = headerString.slice(0, colonIdx).trim();
6688
- const value = headerString.slice(colonIdx + 1).trim();
6689
- if (name) {
6690
- customHeaders[name] = value;
6691
- }
6692
- }
6693
- return customHeaders;
6694
- }
6695
- function buildFetch(fetchOverride, source) {
6696
- const inner = fetchOverride ?? globalThis.fetch;
6697
- const injectClientRequestId = getAPIProvider() === "firstParty" && isFirstPartyAnthropicBaseUrl();
6698
- return (input, init) => {
6699
- const headers = new Headers(init?.headers);
6700
- if (injectClientRequestId && !headers.has(CLIENT_REQUEST_ID_HEADER)) {
6701
- headers.set(CLIENT_REQUEST_ID_HEADER, randomUUID());
6702
- }
6703
- try {
6704
- const url = input instanceof Request ? input.url : String(input);
6705
- const id = headers.get(CLIENT_REQUEST_ID_HEADER);
6706
- logForDebugging(`[API REQUEST] ${new URL(url).pathname}${id ? ` ${CLIENT_REQUEST_ID_HEADER}=${id}` : ""} source=${source ?? "unknown"}`);
6707
- } catch {}
6708
- return inner(input, { ...init, headers });
6709
- };
6710
- }
6711
- var CLIENT_REQUEST_ID_HEADER = "x-client-request-id";
6712
- var init_client = __esm(() => {
6713
- init_sdk();
6714
- init_auth();
6715
- init_http();
6716
- init_providers();
6717
- init_proxy();
6718
- init_state();
6719
- init_debug();
6720
- init_envUtils();
6721
- });
6722
-
6723
- // src/utils/model/modelCapabilities.ts
6724
- import { readFileSync as readFileSync2 } from "fs";
6725
- import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
6726
- import { join as join9 } from "path";
6727
- function getCacheDir() {
6728
- return join9(getClaudeConfigHomeDir(), "cache");
6729
- }
6730
- function getCachePath() {
6731
- return join9(getCacheDir(), "model-capabilities.json");
6732
- }
6733
- function isModelCapabilitiesEligible() {
6734
- if (process.env.USER_TYPE !== "ant")
6735
- return false;
6736
- if (getAPIProvider() !== "firstParty")
6737
- return false;
6738
- if (!isFirstPartyAnthropicBaseUrl())
6739
- return false;
6740
- return true;
6741
- }
6742
- function sortForMatching(models) {
6743
- return [...models].sort((a, b) => b.id.length - a.id.length || a.id.localeCompare(b.id));
6744
- }
6745
- function getModelCapability(model) {
6746
- if (!isModelCapabilitiesEligible())
6747
- return;
6748
- const cached = loadCache(getCachePath());
6749
- if (!cached || cached.length === 0)
6750
- return;
6751
- const m = model.toLowerCase();
6752
- const exact = cached.find((c) => c.id.toLowerCase() === m);
6753
- if (exact)
6754
- return exact;
6755
- return cached.find((c) => m.includes(c.id.toLowerCase()));
6756
- }
6757
- async function refreshModelCapabilities() {
6758
- if (!isModelCapabilitiesEligible())
6759
- return;
6760
- if (isEssentialTrafficOnly())
6761
- return;
6762
- try {
6763
- const anthropic = await getAnthropicClient({ maxRetries: 1 });
6764
- const betas = isClaudeAISubscriber() ? [OAUTH_BETA_HEADER] : undefined;
6765
- const parsed = [];
6766
- for await (const entry of anthropic.models.list({ betas })) {
6767
- const result = ModelCapabilitySchema().safeParse(entry);
6768
- if (result.success)
6769
- parsed.push(result.data);
6770
- }
6771
- if (parsed.length === 0)
6772
- return;
6773
- const path = getCachePath();
6774
- const models = sortForMatching(parsed);
6775
- if (isEqual_default(loadCache(path), models)) {
6776
- logForDebugging("[modelCapabilities] cache unchanged, skipping write");
6777
- return;
6778
- }
6779
- await mkdir2(getCacheDir(), { recursive: true });
6780
- await writeFile2(path, jsonStringify({ models, timestamp: Date.now() }), {
6781
- encoding: "utf-8",
6782
- mode: 384
6783
- });
6784
- loadCache.cache.delete(path);
6785
- logForDebugging(`[modelCapabilities] cached ${models.length} models`);
6786
- } catch (error) {
6787
- logForDebugging(`[modelCapabilities] fetch failed: ${error instanceof Error ? error.message : "unknown"}`);
6788
- }
6789
- }
6790
- var ModelCapabilitySchema, CacheFileSchema, loadCache;
6791
- var init_modelCapabilities = __esm(() => {
6792
- init_isEqual();
6793
- init_memoize();
6794
- init_v4();
6795
- init_oauth();
6796
- init_client();
6797
- init_auth();
6798
- init_debug();
6799
- init_envUtils();
6800
- init_json();
6801
- init_lazySchema();
6802
- init_privacyLevel();
6803
- init_slowOperations();
6804
- init_providers();
6805
- ModelCapabilitySchema = lazySchema(() => exports_external.object({
6806
- id: exports_external.string(),
6807
- max_input_tokens: exports_external.number().optional(),
6808
- max_tokens: exports_external.number().optional()
6809
- }).strip());
6810
- CacheFileSchema = lazySchema(() => exports_external.object({
6811
- models: exports_external.array(ModelCapabilitySchema()),
6812
- timestamp: exports_external.number()
6813
- }));
6814
- loadCache = memoize_default((path) => {
6815
- try {
6816
- const raw = readFileSync2(path, "utf-8");
6817
- const parsed = CacheFileSchema().safeParse(safeParseJSON(raw, false));
6818
- return parsed.success ? parsed.data.models : null;
6819
- } catch {
6820
- return null;
6821
- }
6822
- }, (path) => path);
6823
- });
6824
-
6825
- // src/utils/context.ts
6826
- function is1mContextDisabled() {
6827
- return isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_1M_CONTEXT);
6828
- }
6829
- function has1mContext(model) {
6830
- if (is1mContextDisabled()) {
6831
- return false;
6832
- }
6833
- return /\[1m\]/i.test(model);
6834
- }
6835
- function modelSupports1M(model) {
6836
- if (is1mContextDisabled()) {
6837
- return false;
6838
- }
6839
- const canonical = getCanonicalName(model);
6840
- return canonical.includes("claude-sonnet-4") || canonical.includes("opus-4-6");
6841
- }
6842
- function getContextWindowForModel(model, betas) {
6843
- if (process.env.USER_TYPE === "ant" && process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS) {
6844
- const override = parseInt(process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS, 10);
6845
- if (!isNaN(override) && override > 0) {
6846
- return override;
6847
- }
6848
- }
6849
- if (has1mContext(model)) {
6850
- return 1e6;
6851
- }
6852
- const cap = getModelCapability(model);
6853
- if (cap?.max_input_tokens && cap.max_input_tokens >= 1e5) {
6854
- if (cap.max_input_tokens > MODEL_CONTEXT_WINDOW_DEFAULT && is1mContextDisabled()) {
6855
- return MODEL_CONTEXT_WINDOW_DEFAULT;
6856
- }
6857
- return cap.max_input_tokens;
6858
- }
6859
- if (betas?.includes(CONTEXT_1M_BETA_HEADER) && modelSupports1M(model)) {
6860
- return 1e6;
6861
- }
6862
- if (getSonnet1mExpTreatmentEnabled(model)) {
6863
- return 1e6;
6864
- }
6865
- if (process.env.USER_TYPE === "ant") {
6866
- const antModel = resolveAntModel(model);
6867
- if (antModel?.contextWindow) {
6868
- return antModel.contextWindow;
6869
- }
6870
- }
6871
- return MODEL_CONTEXT_WINDOW_DEFAULT;
6872
- }
6873
- function getSonnet1mExpTreatmentEnabled(model) {
6874
- if (is1mContextDisabled()) {
6875
- return false;
6876
- }
6877
- if (has1mContext(model)) {
6878
- return false;
6879
- }
6880
- if (!getCanonicalName(model).includes("sonnet-4-6")) {
6881
- return false;
6882
- }
6883
- return getGlobalConfig().clientDataCache?.["coral_reef_sonnet"] === "true";
6884
- }
6885
- function calculateContextPercentages(currentUsage, contextWindowSize) {
6886
- if (!currentUsage) {
6887
- return { used: null, remaining: null };
6888
- }
6889
- const totalInputTokens = currentUsage.input_tokens + currentUsage.cache_creation_input_tokens + currentUsage.cache_read_input_tokens;
6890
- const usedPercentage = Math.round(totalInputTokens / contextWindowSize * 100);
6891
- const clampedUsed = Math.min(100, Math.max(0, usedPercentage));
6892
- return {
6893
- used: clampedUsed,
6894
- remaining: 100 - clampedUsed
6895
- };
6896
- }
6897
- function getModelMaxOutputTokens(model) {
6898
- let defaultTokens;
6899
- let upperLimit;
6900
- if (process.env.USER_TYPE === "ant") {
6901
- const antModel = resolveAntModel(model.toLowerCase());
6902
- if (antModel) {
6903
- defaultTokens = antModel.defaultMaxTokens ?? MAX_OUTPUT_TOKENS_DEFAULT;
6904
- upperLimit = antModel.upperMaxTokensLimit ?? MAX_OUTPUT_TOKENS_UPPER_LIMIT;
6905
- return { default: defaultTokens, upperLimit };
6906
- }
6907
- }
6908
- const m = getCanonicalName(model);
6909
- if (m.includes("opus-4-6")) {
6910
- defaultTokens = 64000;
6911
- upperLimit = 128000;
6912
- } else if (m.includes("sonnet-4-6")) {
6913
- defaultTokens = 32000;
6914
- upperLimit = 128000;
6915
- } else if (m.includes("opus-4-5") || m.includes("sonnet-4") || m.includes("haiku-4")) {
6916
- defaultTokens = 32000;
6917
- upperLimit = 64000;
6918
- } else if (m.includes("opus-4-1") || m.includes("opus-4")) {
6919
- defaultTokens = 32000;
6920
- upperLimit = 32000;
6921
- } else if (m.includes("claude-3-opus")) {
6922
- defaultTokens = 4096;
6923
- upperLimit = 4096;
6924
- } else if (m.includes("claude-3-sonnet")) {
6925
- defaultTokens = 8192;
6926
- upperLimit = 8192;
6927
- } else if (m.includes("claude-3-haiku")) {
6928
- defaultTokens = 4096;
6929
- upperLimit = 4096;
6930
- } else if (m.includes("3-5-sonnet") || m.includes("3-5-haiku")) {
6931
- defaultTokens = 8192;
6932
- upperLimit = 8192;
6933
- } else if (m.includes("3-7-sonnet")) {
6934
- defaultTokens = 32000;
6935
- upperLimit = 64000;
6936
- } else {
6937
- defaultTokens = MAX_OUTPUT_TOKENS_DEFAULT;
6938
- upperLimit = MAX_OUTPUT_TOKENS_UPPER_LIMIT;
6939
- }
6940
- const cap = getModelCapability(model);
6941
- if (cap?.max_tokens && cap.max_tokens >= 4096) {
6942
- upperLimit = cap.max_tokens;
6943
- defaultTokens = Math.min(defaultTokens, upperLimit);
6944
- }
6945
- return { default: defaultTokens, upperLimit };
6946
- }
6947
- function getMaxThinkingTokensForModel(model) {
6948
- return getModelMaxOutputTokens(model).upperLimit - 1;
6949
- }
6950
- 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;
6951
- var init_context = __esm(() => {
6952
- init_betas();
6953
- init_config();
6954
- init_envUtils();
6955
- init_model();
6956
- init_antModels();
6957
- init_modelCapabilities();
6958
- });
6959
-
6960
- // src/utils/modelCost.ts
6961
- function getOpus46CostTier(fastMode) {
6962
- if (isFastModeEnabled() && fastMode) {
6963
- return COST_TIER_30_150;
6964
- }
6965
- return COST_TIER_5_25;
6966
- }
6967
- function tokensToUSDCost(modelCosts, usage) {
6968
- 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;
6969
- }
6970
- function getModelCosts(model, usage) {
6971
- const shortName = getCanonicalName(model);
6972
- if (shortName === firstPartyNameToCanonical(CLAUDE_OPUS_4_6_CONFIG.firstParty)) {
6973
- const isFastMode = usage.speed === "fast";
6974
- return getOpus46CostTier(isFastMode);
6975
- }
6976
- const costs = MODEL_COSTS[shortName];
6977
- if (!costs) {
6978
- trackUnknownModelCost(model, shortName);
6979
- return MODEL_COSTS[getCanonicalName(getDefaultMainLoopModelSetting())] ?? DEFAULT_UNKNOWN_MODEL_COST;
6980
- }
6981
- return costs;
6982
- }
6983
- function trackUnknownModelCost(model, shortName) {
6984
- logEvent("tengu_unknown_model_cost", {
6985
- model,
6986
- shortName
6987
- });
6988
- setHasUnknownModelCost();
6989
- }
6990
- function calculateUSDCost(resolvedModel, usage) {
6991
- const modelCosts = getModelCosts(resolvedModel, usage);
6992
- return tokensToUSDCost(modelCosts, usage);
6993
- }
6994
- function formatPrice(price) {
6995
- if (Number.isInteger(price)) {
6996
- return `$${price}`;
6997
- }
6998
- return `$${price.toFixed(2)}`;
6999
- }
7000
- function formatModelPricing(costs) {
7001
- return `${formatPrice(costs.inputTokens)}/${formatPrice(costs.outputTokens)} per Mtok`;
7002
- }
7003
- 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;
7004
- var init_modelCost = __esm(() => {
7005
- init_analytics();
7006
- init_state();
7007
- init_fastMode();
7008
- init_configs();
7009
- init_model();
7010
- COST_TIER_3_15 = {
7011
- inputTokens: 3,
7012
- outputTokens: 15,
7013
- promptCacheWriteTokens: 3.75,
7014
- promptCacheReadTokens: 0.3,
7015
- webSearchRequests: 0.01
7016
- };
7017
- COST_TIER_15_75 = {
7018
- inputTokens: 15,
7019
- outputTokens: 75,
7020
- promptCacheWriteTokens: 18.75,
7021
- promptCacheReadTokens: 1.5,
7022
- webSearchRequests: 0.01
7023
- };
7024
- COST_TIER_5_25 = {
7025
- inputTokens: 5,
7026
- outputTokens: 25,
7027
- promptCacheWriteTokens: 6.25,
7028
- promptCacheReadTokens: 0.5,
7029
- webSearchRequests: 0.01
7030
- };
7031
- COST_TIER_30_150 = {
7032
- inputTokens: 30,
7033
- outputTokens: 150,
7034
- promptCacheWriteTokens: 37.5,
7035
- promptCacheReadTokens: 3,
7036
- webSearchRequests: 0.01
7037
- };
7038
- COST_HAIKU_35 = {
7039
- inputTokens: 0.8,
7040
- outputTokens: 4,
7041
- promptCacheWriteTokens: 1,
7042
- promptCacheReadTokens: 0.08,
7043
- webSearchRequests: 0.01
7044
- };
7045
- COST_HAIKU_45 = {
7046
- inputTokens: 1,
7047
- outputTokens: 5,
7048
- promptCacheWriteTokens: 1.25,
7049
- promptCacheReadTokens: 0.1,
7050
- webSearchRequests: 0.01
7051
- };
7052
- DEFAULT_UNKNOWN_MODEL_COST = COST_TIER_5_25;
7053
- MODEL_COSTS = {
7054
- [firstPartyNameToCanonical(CLAUDE_3_5_HAIKU_CONFIG.firstParty)]: COST_HAIKU_35,
7055
- [firstPartyNameToCanonical(CLAUDE_HAIKU_4_5_CONFIG.firstParty)]: COST_HAIKU_45,
7056
- [firstPartyNameToCanonical(CLAUDE_3_5_V2_SONNET_CONFIG.firstParty)]: COST_TIER_3_15,
7057
- [firstPartyNameToCanonical(CLAUDE_3_7_SONNET_CONFIG.firstParty)]: COST_TIER_3_15,
7058
- [firstPartyNameToCanonical(CLAUDE_SONNET_4_CONFIG.firstParty)]: COST_TIER_3_15,
7059
- [firstPartyNameToCanonical(CLAUDE_SONNET_4_5_CONFIG.firstParty)]: COST_TIER_3_15,
7060
- [firstPartyNameToCanonical(CLAUDE_SONNET_4_6_CONFIG.firstParty)]: COST_TIER_3_15,
7061
- [firstPartyNameToCanonical(CLAUDE_OPUS_4_CONFIG.firstParty)]: COST_TIER_15_75,
7062
- [firstPartyNameToCanonical(CLAUDE_OPUS_4_1_CONFIG.firstParty)]: COST_TIER_15_75,
7063
- [firstPartyNameToCanonical(CLAUDE_OPUS_4_5_CONFIG.firstParty)]: COST_TIER_5_25,
7064
- [firstPartyNameToCanonical(CLAUDE_OPUS_4_6_CONFIG.firstParty)]: COST_TIER_5_25
7065
- };
7066
- });
7067
-
7068
- // src/utils/model/aliases.ts
7069
- function isModelAlias(modelInput) {
7070
- return MODEL_ALIASES.includes(modelInput);
7071
- }
7072
- function isModelFamilyAlias(model) {
7073
- return MODEL_FAMILY_ALIASES.includes(model);
7074
- }
7075
- var MODEL_ALIASES, MODEL_FAMILY_ALIASES;
7076
- var init_aliases = __esm(() => {
7077
- MODEL_ALIASES = [
7078
- "sonnet",
7079
- "opus",
7080
- "haiku",
7081
- "best",
7082
- "sonnet[1m]",
7083
- "opus[1m]",
7084
- "opusplan"
7085
- ];
7086
- MODEL_FAMILY_ALIASES = ["sonnet", "opus", "haiku"];
7087
- });
7088
-
7089
- // src/utils/model/modelAllowlist.ts
7090
- function modelBelongsToFamily(model, family) {
7091
- if (model.includes(family)) {
7092
- return true;
7093
- }
7094
- if (isModelAlias(model)) {
7095
- const resolved = parseUserSpecifiedModel(model).toLowerCase();
7096
- return resolved.includes(family);
7097
- }
7098
- return false;
7099
- }
7100
- function prefixMatchesModel(modelName, prefix) {
7101
- if (!modelName.startsWith(prefix)) {
7102
- return false;
7103
- }
7104
- return modelName.length === prefix.length || modelName[prefix.length] === "-";
7105
- }
7106
- function modelMatchesVersionPrefix(model, entry) {
7107
- const resolvedModel = isModelAlias(model) ? parseUserSpecifiedModel(model).toLowerCase() : model;
7108
- if (prefixMatchesModel(resolvedModel, entry)) {
7109
- return true;
7110
- }
7111
- if (!entry.startsWith("claude-") && prefixMatchesModel(resolvedModel, `claude-${entry}`)) {
7112
- return true;
7113
- }
7114
- return false;
7115
- }
7116
- function familyHasSpecificEntries(family, allowlist) {
7117
- for (const entry of allowlist) {
7118
- if (isModelFamilyAlias(entry)) {
7119
- continue;
7120
- }
7121
- const idx = entry.indexOf(family);
7122
- if (idx === -1) {
7123
- continue;
7124
- }
7125
- const afterFamily = idx + family.length;
7126
- if (afterFamily === entry.length || entry[afterFamily] === "-") {
7127
- return true;
7128
- }
7129
- }
7130
- return false;
7131
- }
7132
- function isModelAllowed(model) {
7133
- const settings = getSettings_DEPRECATED() || {};
7134
- const { availableModels } = settings;
7135
- if (!availableModels) {
7136
- return true;
7137
- }
7138
- if (availableModels.length === 0) {
7139
- return false;
7140
- }
7141
- const resolvedModel = resolveOverriddenModel(model);
7142
- const normalizedModel = resolvedModel.trim().toLowerCase();
7143
- const normalizedAllowlist = availableModels.map((m) => m.trim().toLowerCase());
7144
- if (normalizedAllowlist.includes(normalizedModel)) {
7145
- if (!isModelFamilyAlias(normalizedModel) || !familyHasSpecificEntries(normalizedModel, normalizedAllowlist)) {
7146
- return true;
7147
- }
7148
- }
7149
- for (const entry of normalizedAllowlist) {
7150
- if (isModelFamilyAlias(entry) && !familyHasSpecificEntries(entry, normalizedAllowlist) && modelBelongsToFamily(normalizedModel, entry)) {
7151
- return true;
7152
- }
7153
- }
7154
- if (isModelAlias(normalizedModel)) {
7155
- const resolved = parseUserSpecifiedModel(normalizedModel).toLowerCase();
7156
- if (normalizedAllowlist.includes(resolved)) {
7157
- return true;
7158
- }
7159
- }
7160
- for (const entry of normalizedAllowlist) {
7161
- if (!isModelFamilyAlias(entry) && isModelAlias(entry)) {
7162
- const resolved = parseUserSpecifiedModel(entry).toLowerCase();
7163
- if (resolved === normalizedModel) {
7164
- return true;
7165
- }
7166
- }
7167
- }
7168
- for (const entry of normalizedAllowlist) {
7169
- if (!isModelFamilyAlias(entry) && !isModelAlias(entry)) {
7170
- if (modelMatchesVersionPrefix(normalizedModel, entry)) {
7171
- return true;
7172
- }
7173
- }
7174
- }
7175
- return false;
7176
- }
7177
- var init_modelAllowlist = __esm(() => {
7178
- init_settings2();
7179
- init_aliases();
7180
- init_model();
7181
- init_modelStrings();
7182
- });
7183
-
7184
- // src/utils/model/model.ts
7185
- function getSmallFastModel() {
7186
- const provider = getAPIProvider();
7187
- if (provider === "openai" && process.env.OPENAI_SMALL_FAST_MODEL) {
7188
- return process.env.OPENAI_SMALL_FAST_MODEL;
7189
- }
7190
- if (provider === "gemini" && process.env.GEMINI_SMALL_FAST_MODEL) {
7191
- return process.env.GEMINI_SMALL_FAST_MODEL;
7192
- }
7193
- return process.env.ANTHROPIC_SMALL_FAST_MODEL || getDefaultHaikuModel();
7194
- }
7195
- function isNonCustomOpusModel(model) {
7196
- return model === getModelStrings2().opus40 || model === getModelStrings2().opus41 || model === getModelStrings2().opus45 || model === getModelStrings2().opus46;
7197
- }
7198
- function getUserSpecifiedModelSetting() {
7199
- let specifiedModel;
7200
- const modelOverride = getMainLoopModelOverride();
7201
- if (modelOverride !== undefined) {
7202
- specifiedModel = modelOverride;
7203
- } else {
7204
- const settings = getSettings_DEPRECATED() || {};
7205
- specifiedModel = process.env.ANTHROPIC_MODEL || settings.model || undefined;
7206
- }
7207
- if (specifiedModel && !isModelAllowed(specifiedModel)) {
7208
- return;
7209
- }
7210
- return specifiedModel;
7211
- }
7212
- function getMainLoopModel() {
7213
- const model = getUserSpecifiedModelSetting();
7214
- if (model !== undefined && model !== null) {
7215
- return parseUserSpecifiedModel(model);
7216
- }
7217
- return getDefaultMainLoopModel();
7218
- }
7219
- function getBestModel() {
7220
- return getDefaultOpusModel();
7221
- }
7222
- function getDefaultOpusModel() {
7223
- const provider = getAPIProvider();
7224
- if (provider === "openai" && process.env.OPENAI_DEFAULT_OPUS_MODEL) {
7225
- return process.env.OPENAI_DEFAULT_OPUS_MODEL;
7226
- }
7227
- if (provider === "gemini" && process.env.GEMINI_DEFAULT_OPUS_MODEL) {
7228
- return process.env.GEMINI_DEFAULT_OPUS_MODEL;
7229
- }
7230
- if (process.env.ANTHROPIC_DEFAULT_OPUS_MODEL) {
7231
- return process.env.ANTHROPIC_DEFAULT_OPUS_MODEL;
7232
- }
7233
- if (provider !== "firstParty") {
7234
- return getModelStrings2().opus46;
7235
- }
7236
- return getModelStrings2().opus46;
7237
- }
7238
- function getDefaultSonnetModel() {
7239
- const provider = getAPIProvider();
7240
- if (provider === "openai" && process.env.OPENAI_DEFAULT_SONNET_MODEL) {
7241
- return process.env.OPENAI_DEFAULT_SONNET_MODEL;
7242
- }
7243
- if (provider === "gemini" && process.env.GEMINI_DEFAULT_SONNET_MODEL) {
7244
- return process.env.GEMINI_DEFAULT_SONNET_MODEL;
7245
- }
7246
- if (process.env.ANTHROPIC_DEFAULT_SONNET_MODEL) {
7247
- return process.env.ANTHROPIC_DEFAULT_SONNET_MODEL;
7248
- }
7249
- if (provider !== "firstParty") {
7250
- return getModelStrings2().sonnet45;
7251
- }
7252
- return getModelStrings2().sonnet46;
7253
- }
7254
- function getDefaultHaikuModel() {
7255
- const provider = getAPIProvider();
7256
- if (provider === "openai" && process.env.OPENAI_DEFAULT_HAIKU_MODEL) {
7257
- return process.env.OPENAI_DEFAULT_HAIKU_MODEL;
7258
- }
7259
- if (provider === "gemini" && process.env.GEMINI_DEFAULT_HAIKU_MODEL) {
7260
- return process.env.GEMINI_DEFAULT_HAIKU_MODEL;
7261
- }
7262
- if (process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL) {
7263
- return process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL;
7264
- }
7265
- return getModelStrings2().haiku45;
7266
- }
7267
- function getRuntimeMainLoopModel(params) {
7268
- const { permissionMode, mainLoopModel, exceeds200kTokens = false } = params;
7269
- if (getUserSpecifiedModelSetting() === "opusplan" && permissionMode === "plan" && !exceeds200kTokens) {
7270
- return getDefaultOpusModel();
7271
- }
7272
- if (getUserSpecifiedModelSetting() === "haiku" && permissionMode === "plan") {
7273
- return getDefaultSonnetModel();
7274
- }
7275
- return mainLoopModel;
7276
- }
7277
- function getDefaultMainLoopModelSetting() {
7278
- if (process.env.USER_TYPE === "ant") {
7279
- return getAntModelOverrideConfig()?.defaultModel ?? getDefaultOpusModel() + "[1m]";
7280
- }
7281
- if (isMaxSubscriber()) {
7282
- return getDefaultOpusModel() + (isOpus1mMergeEnabled() ? "[1m]" : "");
7283
- }
7284
- if (isTeamPremiumSubscriber()) {
7285
- return getDefaultOpusModel() + (isOpus1mMergeEnabled() ? "[1m]" : "");
7286
- }
7287
- return getDefaultSonnetModel();
7288
- }
7289
- function getDefaultMainLoopModel() {
7290
- return parseUserSpecifiedModel(getDefaultMainLoopModelSetting());
7291
- }
7292
- function firstPartyNameToCanonical(name) {
7293
- name = name.toLowerCase();
7294
- if (name.includes("claude-opus-4-6")) {
7295
- return "claude-opus-4-6";
7296
- }
7297
- if (name.includes("claude-opus-4-5")) {
7298
- return "claude-opus-4-5";
7299
- }
7300
- if (name.includes("claude-opus-4-1")) {
7301
- return "claude-opus-4-1";
7302
- }
7303
- if (name.includes("claude-opus-4")) {
7304
- return "claude-opus-4";
7305
- }
7306
- if (name.includes("claude-sonnet-4-6")) {
7307
- return "claude-sonnet-4-6";
7308
- }
7309
- if (name.includes("claude-sonnet-4-5")) {
7310
- return "claude-sonnet-4-5";
7311
- }
7312
- if (name.includes("claude-sonnet-4")) {
7313
- return "claude-sonnet-4";
7314
- }
7315
- if (name.includes("claude-haiku-4-5")) {
7316
- return "claude-haiku-4-5";
7317
- }
7318
- if (name.includes("claude-3-7-sonnet")) {
7319
- return "claude-3-7-sonnet";
7320
- }
7321
- if (name.includes("claude-3-5-sonnet")) {
7322
- return "claude-3-5-sonnet";
7323
- }
7324
- if (name.includes("claude-3-5-haiku")) {
7325
- return "claude-3-5-haiku";
7326
- }
7327
- if (name.includes("claude-3-opus")) {
7328
- return "claude-3-opus";
7329
- }
7330
- if (name.includes("claude-3-sonnet")) {
7331
- return "claude-3-sonnet";
7332
- }
7333
- if (name.includes("claude-3-haiku")) {
7334
- return "claude-3-haiku";
7335
- }
7336
- const match = name.match(/(claude-(\d+-\d+-)?\w+)/);
7337
- if (match && match[1]) {
7338
- return match[1];
7339
- }
7340
- return name;
7341
- }
7342
- function getCanonicalName(fullModelName) {
7343
- return firstPartyNameToCanonical(resolveOverriddenModel(fullModelName));
7344
- }
7345
- function getClaudeAiUserDefaultModelDescription(fastMode = false) {
7346
- if (isMaxSubscriber() || isTeamPremiumSubscriber()) {
7347
- if (isOpus1mMergeEnabled()) {
7348
- return `Opus 4.6 with 1M context \xB7 Most capable for complex work${fastMode ? getOpus46PricingSuffix(true) : ""}`;
7349
- }
7350
- return `Opus 4.6 \xB7 Most capable for complex work${fastMode ? getOpus46PricingSuffix(true) : ""}`;
7351
- }
7352
- return "Sonnet 4.6 \xB7 Best for everyday tasks";
7353
- }
7354
- function renderDefaultModelSetting(setting) {
7355
- if (setting === "opusplan") {
7356
- return "Opus 4.6 in plan mode, else Sonnet 4.6";
7357
- }
7358
- return renderModelName(parseUserSpecifiedModel(setting));
7359
- }
7360
- function getOpus46PricingSuffix(fastMode) {
7361
- if (getAPIProvider() !== "firstParty")
7362
- return "";
7363
- const pricing = formatModelPricing(getOpus46CostTier(fastMode));
7364
- const fastModeIndicator = fastMode ? ` (${LIGHTNING_BOLT})` : "";
7365
- return ` \xB7${fastModeIndicator} ${pricing}`;
7366
- }
7367
- function isOpus1mMergeEnabled() {
7368
- if (is1mContextDisabled() || isProSubscriber() || getAPIProvider() !== "firstParty") {
7369
- return false;
7370
- }
7371
- if (isClaudeAISubscriber() && getSubscriptionType() === null) {
7372
- return false;
7373
- }
7374
- return true;
7375
- }
7376
- function renderModelSetting(setting) {
7377
- if (setting === "opusplan") {
7378
- return "Opus Plan";
7379
- }
7380
- if (isModelAlias(setting)) {
7381
- return capitalize(setting);
7382
- }
7383
- return renderModelName(setting);
7384
- }
7385
- function getPublicModelDisplayName(model) {
7386
- switch (model) {
7387
- case getModelStrings2().opus46:
7388
- return "Opus 4.6";
7389
- case getModelStrings2().opus46 + "[1m]":
7390
- return "Opus 4.6 (1M context)";
7391
- case getModelStrings2().opus45:
7392
- return "Opus 4.5";
7393
- case getModelStrings2().opus41:
7394
- return "Opus 4.1";
7395
- case getModelStrings2().opus40:
7396
- return "Opus 4";
7397
- case getModelStrings2().sonnet46 + "[1m]":
7398
- return "Sonnet 4.6 (1M context)";
7399
- case getModelStrings2().sonnet46:
7400
- return "Sonnet 4.6";
7401
- case getModelStrings2().sonnet45 + "[1m]":
7402
- return "Sonnet 4.5 (1M context)";
7403
- case getModelStrings2().sonnet45:
7404
- return "Sonnet 4.5";
7405
- case getModelStrings2().sonnet40:
7406
- return "Sonnet 4";
7407
- case getModelStrings2().sonnet40 + "[1m]":
7408
- return "Sonnet 4 (1M context)";
7409
- case getModelStrings2().sonnet37:
7410
- return "Sonnet 3.7";
7411
- case getModelStrings2().sonnet35:
7412
- return "Sonnet 3.5";
7413
- case getModelStrings2().haiku45:
7414
- return "Haiku 4.5";
7415
- case getModelStrings2().haiku35:
7416
- return "Haiku 3.5";
7417
- default:
7418
- return null;
7419
- }
7420
- }
7421
- function maskModelCodename(baseName) {
7422
- const [codename = "", ...rest] = baseName.split("-");
7423
- const masked = codename.slice(0, 3) + "*".repeat(Math.max(0, codename.length - 3));
7424
- return [masked, ...rest].join("-");
7425
- }
7426
- function renderModelName(model) {
7427
- const publicName = getPublicModelDisplayName(model);
7428
- if (publicName) {
7429
- return publicName;
7430
- }
7431
- if (process.env.USER_TYPE === "ant") {
7432
- const resolved = parseUserSpecifiedModel(model);
7433
- const antModel = resolveAntModel(model);
7434
- if (antModel) {
7435
- const baseName = antModel.model.replace(/\[1m\]$/i, "");
7436
- const masked = maskModelCodename(baseName);
7437
- const suffix = has1mContext(resolved) ? "[1m]" : "";
7438
- return masked + suffix;
7439
- }
7440
- if (resolved !== model) {
7441
- return `${model} (${resolved})`;
7442
- }
7443
- return resolved;
7444
- }
7445
- return model;
7446
- }
7447
- function getPublicModelName(model) {
7448
- const publicName = getPublicModelDisplayName(model);
7449
- if (publicName) {
7450
- return `${publicName}`;
7451
- }
7452
- return `${model}`;
7453
- }
7454
- function parseUserSpecifiedModel(modelInput) {
7455
- const modelInputTrimmed = modelInput.trim();
7456
- const normalizedModel = modelInputTrimmed.toLowerCase();
7457
- const has1mTag = has1mContext(normalizedModel);
7458
- const modelString = has1mTag ? normalizedModel.replace(/\[1m]$/i, "").trim() : normalizedModel;
7459
- if (isModelAlias(modelString)) {
7460
- switch (modelString) {
7461
- case "opusplan":
7462
- return getDefaultSonnetModel() + (has1mTag ? "[1m]" : "");
7463
- case "sonnet":
7464
- return getDefaultSonnetModel() + (has1mTag ? "[1m]" : "");
7465
- case "haiku":
7466
- return getDefaultHaikuModel() + (has1mTag ? "[1m]" : "");
7467
- case "opus":
7468
- return getDefaultOpusModel() + (has1mTag ? "[1m]" : "");
7469
- case "best":
7470
- return getBestModel();
7471
- default:
7472
- }
7473
- }
7474
- if (getAPIProvider() === "firstParty" && isLegacyOpusFirstParty(modelString) && isLegacyModelRemapEnabled()) {
7475
- return getDefaultOpusModel() + (has1mTag ? "[1m]" : "");
7476
- }
7477
- if (process.env.USER_TYPE === "ant") {
7478
- const has1mAntTag = has1mContext(normalizedModel);
7479
- const baseAntModel = normalizedModel.replace(/\[1m]$/i, "").trim();
7480
- const antModel = resolveAntModel(baseAntModel);
7481
- if (antModel) {
7482
- const suffix = has1mAntTag ? "[1m]" : "";
7483
- return antModel.model + suffix;
7484
- }
7485
- }
7486
- if (has1mTag) {
7487
- return modelInputTrimmed.replace(/\[1m\]$/i, "").trim() + "[1m]";
7488
- }
7489
- return modelInputTrimmed;
7490
- }
7491
- function resolveSkillModelOverride(skillModel, currentModel) {
7492
- if (has1mContext(skillModel) || !has1mContext(currentModel)) {
7493
- return skillModel;
7494
- }
7495
- if (modelSupports1M(parseUserSpecifiedModel(skillModel))) {
7496
- return skillModel + "[1m]";
7497
- }
7498
- return skillModel;
7499
- }
7500
- function isLegacyOpusFirstParty(model) {
7501
- return LEGACY_OPUS_FIRSTPARTY.includes(model);
7502
- }
7503
- function isLegacyModelRemapEnabled() {
7504
- return !isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP);
7505
- }
7506
- function modelDisplayString(model) {
7507
- if (model === null) {
7508
- if (process.env.USER_TYPE === "ant") {
7509
- return `Default for Ants (${renderDefaultModelSetting(getDefaultMainLoopModelSetting())})`;
7510
- } else if (isClaudeAISubscriber()) {
7511
- return `Default (${getClaudeAiUserDefaultModelDescription()})`;
7512
- }
7513
- return `Default (${getDefaultMainLoopModel()})`;
7514
- }
7515
- const resolvedModel = parseUserSpecifiedModel(model);
7516
- return model === resolvedModel ? resolvedModel : `${model} (${resolvedModel})`;
7517
- }
7518
- function getMarketingNameForModel(modelId) {
7519
- if (getAPIProvider() === "foundry") {
7520
- return;
7521
- }
7522
- const has1m = modelId.toLowerCase().includes("[1m]");
7523
- const canonical = getCanonicalName(modelId);
7524
- if (canonical.includes("claude-opus-4-6")) {
7525
- return has1m ? "Opus 4.6 (with 1M context)" : "Opus 4.6";
7526
- }
7527
- if (canonical.includes("claude-opus-4-5")) {
7528
- return "Opus 4.5";
7529
- }
7530
- if (canonical.includes("claude-opus-4-1")) {
7531
- return "Opus 4.1";
7532
- }
7533
- if (canonical.includes("claude-opus-4")) {
7534
- return "Opus 4";
7535
- }
7536
- if (canonical.includes("claude-sonnet-4-6")) {
7537
- return has1m ? "Sonnet 4.6 (with 1M context)" : "Sonnet 4.6";
7538
- }
7539
- if (canonical.includes("claude-sonnet-4-5")) {
7540
- return has1m ? "Sonnet 4.5 (with 1M context)" : "Sonnet 4.5";
7541
- }
7542
- if (canonical.includes("claude-sonnet-4")) {
7543
- return has1m ? "Sonnet 4 (with 1M context)" : "Sonnet 4";
7544
- }
7545
- if (canonical.includes("claude-3-7-sonnet")) {
7546
- return "3.7 Sonnet";
7547
- }
7548
- if (canonical.includes("claude-3-5-sonnet")) {
7549
- return "3.5 Sonnet";
7550
- }
7551
- if (canonical.includes("claude-haiku-4-5")) {
7552
- return "Haiku 4.5";
7553
- }
7554
- if (canonical.includes("claude-3-5-haiku")) {
7555
- return "3.5 Haiku";
7556
- }
7557
- return;
7558
- }
7559
- function normalizeModelStringForAPI(model) {
7560
- return model.replace(/\[(1|2)m\]/gi, "");
7561
- }
7562
- var LEGACY_OPUS_FIRSTPARTY;
7563
- var init_model = __esm(() => {
7564
- init_state();
7565
- init_antModels();
7566
- init_auth();
7567
- init_context();
7568
- init_envUtils();
7569
- init_modelStrings();
7570
- init_modelCost();
7571
- init_settings2();
7572
- init_providers();
7573
- init_figures();
7574
- init_modelAllowlist();
7575
- init_aliases();
7576
- init_stringUtils();
7577
- LEGACY_OPUS_FIRSTPARTY = [
7578
- "claude-opus-4-20250514",
7579
- "claude-opus-4-1-20250805",
7580
- "claude-opus-4-0",
7581
- "claude-opus-4-1"
7582
- ];
7583
- });
7584
-
7585
- // src/utils/fastMode.ts
7586
- function isFastModeEnabled() {
7587
- return !isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_FAST_MODE);
7588
- }
7589
- function isFastModeAvailable() {
7590
- if (!isFastModeEnabled()) {
7591
- return false;
7592
- }
7593
- return getFastModeUnavailableReason() === null;
7594
- }
7595
- function getDisabledReasonMessage(disabledReason, authType) {
7596
- switch (disabledReason) {
7597
- case "free":
7598
- return authType === "oauth" ? "Fast mode requires a paid subscription" : "Fast mode unavailable during evaluation. Please purchase credits.";
7599
- case "preference":
7600
- return "Fast mode has been disabled by your organization";
7601
- case "extra_usage_disabled":
7602
- return "Fast mode requires extra usage billing \xB7 /extra-usage to enable";
7603
- case "network_error":
7604
- return "Fast mode unavailable due to network connectivity issues";
7605
- case "unknown":
7606
- return "Fast mode is currently unavailable";
7607
- }
7608
- }
7609
- function getFastModeUnavailableReason() {
7610
- if (!isFastModeEnabled()) {
7611
- return "Fast mode is not available";
7612
- }
7613
- const statigReason = getFeatureValue_CACHED_MAY_BE_STALE("tengu_penguins_off", null);
7614
- if (statigReason !== null) {
7615
- logForDebugging(`Fast mode unavailable: ${statigReason}`);
7616
- return statigReason;
7617
- }
7618
- if (!isInBundledMode() && getFeatureValue_CACHED_MAY_BE_STALE("tengu_marble_sandcastle", false)) {
7619
- return "Fast mode requires the native binary \xB7 Install from: https://claude.com/product/claude-code";
7620
- }
7621
- if (getIsNonInteractiveSession() && preferThirdPartyAuthentication() && !getKairosActive()) {
7622
- const flagFastMode = getSettingsForSource("flagSettings")?.fastMode;
7623
- if (!flagFastMode) {
7624
- const reason = "Fast mode is not available in the Agent SDK";
7625
- logForDebugging(`Fast mode unavailable: ${reason}`);
7626
- return reason;
7627
- }
7628
- }
7629
- if (getAPIProvider() !== "firstParty") {
7630
- const reason = "Fast mode is not available on Bedrock, Vertex, or Foundry";
7631
- logForDebugging(`Fast mode unavailable: ${reason}`);
7632
- return reason;
7633
- }
7634
- if (orgStatus.status === "disabled") {
7635
- if (orgStatus.reason === "network_error" || orgStatus.reason === "unknown") {
7636
- if (isEnvTruthy(process.env.CLAUDE_CODE_SKIP_FAST_MODE_NETWORK_ERRORS)) {
7637
- return null;
7638
- }
7639
- }
7640
- const authType = getClaudeAIOAuthTokens() !== null ? "oauth" : "api-key";
7641
- const reason = getDisabledReasonMessage(orgStatus.reason, authType);
7642
- logForDebugging(`Fast mode unavailable: ${reason}`);
7643
- return reason;
7644
- }
7645
- return null;
7646
- }
7647
- function getFastModeModel() {
7648
- return "opus" + (isOpus1mMergeEnabled() ? "[1m]" : "");
7649
- }
7650
- function getInitialFastModeSetting(model) {
7651
- if (!isFastModeEnabled()) {
7652
- return false;
7653
- }
7654
- if (!isFastModeAvailable()) {
7655
- return false;
7656
- }
7657
- if (!isFastModeSupportedByModel(model)) {
7658
- return false;
7659
- }
7660
- const settings = getInitialSettings();
7661
- if (settings.fastModePerSessionOptIn) {
7662
- return false;
7663
- }
7664
- return settings.fastMode === true;
7665
- }
7666
- function isFastModeSupportedByModel(modelSetting) {
7667
- if (!isFastModeEnabled()) {
7668
- return false;
7669
- }
7670
- const model = modelSetting ?? getDefaultMainLoopModelSetting();
7671
- const parsedModel = parseUserSpecifiedModel(model);
7672
- return parsedModel.toLowerCase().includes("opus-4-6");
7673
- }
7674
- function getFastModeRuntimeState() {
7675
- if (runtimeState.status === "cooldown" && Date.now() >= runtimeState.resetAt) {
7676
- if (isFastModeEnabled() && !hasLoggedCooldownExpiry) {
7677
- logForDebugging("Fast mode cooldown expired, re-enabling fast mode");
7678
- hasLoggedCooldownExpiry = true;
7679
- cooldownExpired.emit();
7680
- }
7681
- runtimeState = { status: "active" };
7682
- }
7683
- return runtimeState;
7684
- }
7685
- function triggerFastModeCooldown(resetTimestamp, reason) {
7686
- if (!isFastModeEnabled()) {
7687
- return;
7688
- }
7689
- runtimeState = { status: "cooldown", resetAt: resetTimestamp, reason };
7690
- hasLoggedCooldownExpiry = false;
7691
- const cooldownDurationMs = resetTimestamp - Date.now();
7692
- logForDebugging(`Fast mode cooldown triggered (${reason}), duration ${Math.round(cooldownDurationMs / 1000)}s`);
7693
- logEvent("tengu_fast_mode_fallback_triggered", {
7694
- cooldown_duration_ms: cooldownDurationMs,
7695
- cooldown_reason: reason
7696
- });
7697
- cooldownTriggered.emit(resetTimestamp, reason);
7698
- }
7699
- function clearFastModeCooldown() {
7700
- runtimeState = { status: "active" };
7701
- }
7702
- function handleFastModeRejectedByAPI() {
7703
- if (orgStatus.status === "disabled") {
7704
- return;
7705
- }
7706
- orgStatus = { status: "disabled", reason: "preference" };
7707
- updateSettingsForSource("userSettings", { fastMode: undefined });
7708
- saveGlobalConfig((current) => ({
7709
- ...current,
7710
- penguinModeOrgEnabled: false
7711
- }));
7712
- orgFastModeChange.emit(false);
7713
- }
7714
- function getOverageDisabledMessage(reason) {
7715
- switch (reason) {
7716
- case "out_of_credits":
7717
- return "Fast mode disabled \xB7 extra usage credits exhausted";
7718
- case "org_level_disabled":
7719
- case "org_service_level_disabled":
7720
- return "Fast mode disabled \xB7 extra usage disabled by your organization";
7721
- case "org_level_disabled_until":
7722
- return "Fast mode disabled \xB7 extra usage spending cap reached";
7723
- case "member_level_disabled":
7724
- return "Fast mode disabled \xB7 extra usage disabled for your account";
7725
- case "seat_tier_level_disabled":
7726
- case "seat_tier_zero_credit_limit":
7727
- case "member_zero_credit_limit":
7728
- return "Fast mode disabled \xB7 extra usage not available for your plan";
7729
- case "overage_not_provisioned":
7730
- case "no_limits_configured":
7731
- return "Fast mode requires extra usage billing \xB7 /extra-usage to enable";
7732
- default:
7733
- return "Fast mode disabled \xB7 extra usage not available";
7734
- }
7735
- }
7736
- function isOutOfCreditsReason(reason) {
7737
- return reason === "org_level_disabled_until" || reason === "out_of_credits";
7738
- }
7739
- function handleFastModeOverageRejection(reason) {
7740
- const message = getOverageDisabledMessage(reason);
7741
- logForDebugging(`Fast mode overage rejection: ${reason ?? "unknown"} \u2014 ${message}`);
7742
- logEvent("tengu_fast_mode_overage_rejected", {
7743
- overage_disabled_reason: reason ?? "unknown"
7744
- });
7745
- if (!isOutOfCreditsReason(reason)) {
7746
- updateSettingsForSource("userSettings", { fastMode: undefined });
7747
- saveGlobalConfig((current) => ({
7748
- ...current,
7749
- penguinModeOrgEnabled: false
7750
- }));
7751
- }
7752
- overageRejection.emit(message);
7753
- }
7754
- function isFastModeCooldown() {
7755
- return getFastModeRuntimeState().status === "cooldown";
7756
- }
7757
- function getFastModeState(model, fastModeUserEnabled) {
7758
- const enabled = isFastModeEnabled() && isFastModeAvailable() && !!fastModeUserEnabled && isFastModeSupportedByModel(model);
7759
- if (enabled && isFastModeCooldown()) {
7760
- return "cooldown";
7761
- }
7762
- if (enabled) {
7763
- return "on";
7764
- }
7765
- return "off";
7766
- }
7767
- async function fetchFastModeStatus(auth) {
7768
- const endpoint = `${getOauthConfig().BASE_API_URL}/api/claude_code_penguin_mode`;
7769
- const headers = "accessToken" in auth ? {
7770
- Authorization: `Bearer ${auth.accessToken}`,
7771
- "anthropic-beta": OAUTH_BETA_HEADER
7772
- } : { "x-api-key": auth.apiKey };
7773
- const response = await axios_default.get(endpoint, { headers });
7774
- return response.data;
7775
- }
7776
- function resolveFastModeStatusFromCache() {
7777
- if (!isFastModeEnabled()) {
7778
- return;
7779
- }
7780
- if (orgStatus.status !== "pending") {
7781
- return;
7782
- }
7783
- const isAnt = process.env.USER_TYPE === "ant";
7784
- const cachedEnabled = getGlobalConfig().penguinModeOrgEnabled === true;
7785
- orgStatus = isAnt || cachedEnabled ? { status: "enabled" } : { status: "disabled", reason: "unknown" };
7786
- }
7787
- async function prefetchFastModeStatus() {
7788
- if (isEssentialTrafficOnly()) {
7789
- return;
7790
- }
7791
- if (!isFastModeEnabled()) {
7792
- return;
7793
- }
7794
- if (inflightPrefetch) {
7795
- logForDebugging("Fast mode prefetch in progress, returning in-flight promise");
7796
- return inflightPrefetch;
7797
- }
7798
- const apiKey = getAnthropicApiKey();
7799
- const hasUsableOAuth = getClaudeAIOAuthTokens()?.accessToken && hasProfileScope();
7800
- if (!hasUsableOAuth && !apiKey) {
7801
- const isAnt = process.env.USER_TYPE === "ant";
7802
- const cachedEnabled = getGlobalConfig().penguinModeOrgEnabled === true;
7803
- orgStatus = isAnt || cachedEnabled ? { status: "enabled" } : { status: "disabled", reason: "preference" };
7804
- return;
7805
- }
7806
- const now = Date.now();
7807
- if (now - lastPrefetchAt < PREFETCH_MIN_INTERVAL_MS) {
7808
- logForDebugging("Skipping fast mode prefetch, fetched recently");
7809
- return;
7810
- }
7811
- lastPrefetchAt = now;
7812
- const fetchWithCurrentAuth = async () => {
7813
- const currentTokens = getClaudeAIOAuthTokens();
7814
- const auth = currentTokens?.accessToken && hasProfileScope() ? { accessToken: currentTokens.accessToken } : apiKey ? { apiKey } : null;
7815
- if (!auth) {
7816
- throw new Error("No auth available");
7817
- }
7818
- return fetchFastModeStatus(auth);
7819
- };
7820
- async function doFetch() {
7821
- try {
7822
- let status;
7823
- try {
7824
- status = await fetchWithCurrentAuth();
7825
- } catch (err) {
7826
- const isAuthError = axios_default.isAxiosError(err) && (err.response?.status === 401 || err.response?.status === 403 && typeof err.response?.data === "string" && err.response.data.includes("OAuth token has been revoked"));
7827
- if (isAuthError) {
7828
- const failedAccessToken = getClaudeAIOAuthTokens()?.accessToken;
7829
- if (failedAccessToken) {
7830
- await handleOAuth401Error(failedAccessToken);
7831
- status = await fetchWithCurrentAuth();
7832
- } else {
7833
- throw err;
7834
- }
7835
- } else {
7836
- throw err;
7837
- }
7838
- }
7839
- const previousEnabled = orgStatus.status !== "pending" ? orgStatus.status === "enabled" : getGlobalConfig().penguinModeOrgEnabled;
7840
- orgStatus = status.enabled ? { status: "enabled" } : {
7841
- status: "disabled",
7842
- reason: status.disabled_reason ?? "preference"
7843
- };
7844
- if (previousEnabled !== status.enabled) {
7845
- if (!status.enabled) {
7846
- updateSettingsForSource("userSettings", { fastMode: undefined });
7847
- }
7848
- saveGlobalConfig((current) => ({
7849
- ...current,
7850
- penguinModeOrgEnabled: status.enabled
7851
- }));
7852
- orgFastModeChange.emit(status.enabled);
7853
- }
7854
- logForDebugging(`Org fast mode: ${status.enabled ? "enabled" : `disabled (${status.disabled_reason ?? "preference"})`}`);
7855
- } catch (err) {
7856
- const isAnt = process.env.USER_TYPE === "ant";
7857
- const cachedEnabled = getGlobalConfig().penguinModeOrgEnabled === true;
7858
- orgStatus = isAnt || cachedEnabled ? { status: "enabled" } : { status: "disabled", reason: "network_error" };
7859
- logForDebugging(`Failed to fetch org fast mode status, defaulting to ${orgStatus.status === "enabled" ? "enabled (cached)" : "disabled (network_error)"}: ${err}`, { level: "error" });
7860
- logEvent("tengu_org_penguin_mode_fetch_failed", {});
7861
- } finally {
7862
- inflightPrefetch = null;
7863
- }
7864
- }
7865
- inflightPrefetch = doFetch();
7866
- return inflightPrefetch;
7867
- }
7868
- 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;
7869
- var init_fastMode = __esm(() => {
7870
- init_axios();
7871
- init_oauth();
7872
- init_growthbook();
7873
- init_state();
7874
- init_analytics();
7875
- init_auth();
7876
- init_bundledMode();
7877
- init_config();
7878
- init_debug();
7879
- init_envUtils();
7880
- init_model();
7881
- init_providers();
7882
- init_privacyLevel();
7883
- init_settings2();
7884
- init_signal();
7885
- runtimeState = { status: "active" };
7886
- cooldownTriggered = createSignal();
7887
- cooldownExpired = createSignal();
7888
- onCooldownTriggered = cooldownTriggered.subscribe;
7889
- onCooldownExpired = cooldownExpired.subscribe;
7890
- overageRejection = createSignal();
7891
- onFastModeOverageRejection = overageRejection.subscribe;
7892
- orgStatus = { status: "pending" };
7893
- orgFastModeChange = createSignal();
7894
- onOrgFastModeChanged = orgFastModeChange.subscribe;
7895
- });
7896
-
7897
- // src/utils/model/modelSupportOverrides.ts
7898
- var ANTHROPIC_TIERS, OPENAI_TIERS, get3PModelCapabilityOverride;
7899
- var init_modelSupportOverrides = __esm(() => {
7900
- init_memoize();
7901
- init_providers();
7902
- ANTHROPIC_TIERS = [
7903
- {
7904
- modelEnvVar: "ANTHROPIC_DEFAULT_OPUS_MODEL",
7905
- capabilitiesEnvVar: "ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES"
7906
- },
7907
- {
7908
- modelEnvVar: "ANTHROPIC_DEFAULT_SONNET_MODEL",
7909
- capabilitiesEnvVar: "ANTHROPIC_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES"
7910
- },
7911
- {
7912
- modelEnvVar: "ANTHROPIC_DEFAULT_HAIKU_MODEL",
7913
- capabilitiesEnvVar: "ANTHROPIC_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES"
7914
- }
7915
- ];
7916
- OPENAI_TIERS = [
7917
- {
7918
- modelEnvVar: "OPENAI_DEFAULT_OPUS_MODEL",
7919
- capabilitiesEnvVar: "OPENAI_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES"
7920
- },
7921
- {
7922
- modelEnvVar: "OPENAI_DEFAULT_SONNET_MODEL",
7923
- capabilitiesEnvVar: "OPENAI_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES"
7924
- },
7925
- {
7926
- modelEnvVar: "OPENAI_DEFAULT_HAIKU_MODEL",
7927
- capabilitiesEnvVar: "OPENAI_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES"
7928
- }
7929
- ];
7930
- get3PModelCapabilityOverride = memoize_default((model, capability) => {
7931
- if (getAPIProvider() === "firstParty") {
7932
- return;
7933
- }
7934
- const m = model.toLowerCase();
7935
- const tiers = getAPIProvider() === "openai" ? OPENAI_TIERS : ANTHROPIC_TIERS;
7936
- for (const tier of tiers) {
7937
- const pinned = process.env[tier.modelEnvVar];
7938
- const capabilities = process.env[tier.capabilitiesEnvVar];
7939
- if (!pinned || capabilities === undefined)
7940
- continue;
7941
- if (m !== pinned.toLowerCase())
7942
- continue;
7943
- return capabilities.toLowerCase().split(",").map((s) => s.trim()).includes(capability);
7944
- }
7945
- return;
7946
- }, (model, capability) => `${model.toLowerCase()}:${capability}`);
7947
- });
7948
-
7949
- // src/utils/betas.ts
7950
- function partitionBetasByAllowlist(betas) {
7951
- const allowed = [];
7952
- const disallowed = [];
7953
- for (const beta of betas) {
7954
- if (ALLOWED_SDK_BETAS.includes(beta)) {
7955
- allowed.push(beta);
7956
- } else {
7957
- disallowed.push(beta);
7958
- }
7959
- }
7960
- return { allowed, disallowed };
7961
- }
7962
- function filterAllowedSdkBetas(sdkBetas) {
7963
- if (!sdkBetas || sdkBetas.length === 0) {
7964
- return;
7965
- }
7966
- if (isClaudeAISubscriber()) {
7967
- console.warn("Warning: Custom betas are only available for API key users. Ignoring provided betas.");
7968
- return;
7969
- }
7970
- const { allowed, disallowed } = partitionBetasByAllowlist(sdkBetas);
7971
- for (const beta of disallowed) {
7972
- console.warn(`Warning: Beta header '${beta}' is not allowed. Only the following betas are supported: ${ALLOWED_SDK_BETAS.join(", ")}`);
7973
- }
7974
- return allowed.length > 0 ? allowed : undefined;
7975
- }
7976
- function modelSupportsISP(model) {
7977
- const supported3P = get3PModelCapabilityOverride(model, "interleaved_thinking");
7978
- if (supported3P !== undefined) {
7979
- return supported3P;
7980
- }
7981
- const canonical = getCanonicalName(model);
7982
- const provider = getAPIProvider();
7983
- if (provider === "foundry") {
7984
- return true;
7985
- }
7986
- if (provider === "firstParty") {
7987
- return !canonical.includes("claude-3-");
7988
- }
7989
- return canonical.includes("claude-opus-4") || canonical.includes("claude-sonnet-4");
7990
- }
7991
- function vertexModelSupportsWebSearch(model) {
7992
- const canonical = getCanonicalName(model);
7993
- return canonical.includes("claude-opus-4") || canonical.includes("claude-sonnet-4") || canonical.includes("claude-haiku-4");
7994
- }
7995
- function modelSupportsContextManagement(model) {
7996
- const canonical = getCanonicalName(model);
7997
- const provider = getAPIProvider();
7998
- if (provider === "foundry") {
7999
- return true;
8000
- }
8001
- if (provider === "firstParty") {
8002
- return !canonical.includes("claude-3-");
8003
- }
8004
- return canonical.includes("claude-opus-4") || canonical.includes("claude-sonnet-4") || canonical.includes("claude-haiku-4");
8005
- }
8006
- function modelSupportsStructuredOutputs(model) {
8007
- const canonical = getCanonicalName(model);
8008
- const provider = getAPIProvider();
8009
- if (provider !== "firstParty" && provider !== "foundry") {
8010
- return false;
8011
- }
8012
- return canonical.includes("claude-sonnet-4-6") || canonical.includes("claude-sonnet-4-5") || canonical.includes("claude-opus-4-1") || canonical.includes("claude-opus-4-5") || canonical.includes("claude-opus-4-6") || canonical.includes("claude-haiku-4-5");
8013
- }
8014
- function modelSupportsAutoMode(model) {
8015
- if (false) {}
8016
- return false;
8017
- }
8018
- function getToolSearchBetaHeader() {
8019
- const provider = getAPIProvider();
8020
- if (provider === "vertex" || provider === "bedrock") {
8021
- return TOOL_SEARCH_BETA_HEADER_3P;
8022
- }
8023
- return TOOL_SEARCH_BETA_HEADER_1P;
8024
- }
8025
- function shouldIncludeFirstPartyOnlyBetas() {
8026
- return (getAPIProvider() === "firstParty" || getAPIProvider() === "foundry") && !isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS);
8027
- }
8028
- function shouldUseGlobalCacheScope() {
8029
- return getAPIProvider() === "firstParty" && !isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS);
8030
- }
8031
- function getMergedBetas(model, options) {
8032
- const baseBetas = [...getModelBetas(model)];
8033
- if (options?.isAgenticQuery) {
8034
- if (!baseBetas.includes(CLAUDE_CODE_20250219_BETA_HEADER)) {
8035
- baseBetas.push(CLAUDE_CODE_20250219_BETA_HEADER);
8036
- }
8037
- if (process.env.USER_TYPE === "ant" && process.env.CLAUDE_CODE_ENTRYPOINT === "cli" && CLI_INTERNAL_BETA_HEADER && !baseBetas.includes(CLI_INTERNAL_BETA_HEADER)) {
8038
- baseBetas.push(CLI_INTERNAL_BETA_HEADER);
8039
- }
8040
- }
8041
- const sdkBetas = getSdkBetas();
8042
- if (!sdkBetas || sdkBetas.length === 0) {
8043
- return baseBetas;
8044
- }
8045
- return [...baseBetas, ...sdkBetas.filter((b) => !baseBetas.includes(b))];
8046
- }
8047
- function clearBetasCaches() {
8048
- getAllModelBetas.cache?.clear?.();
8049
- getModelBetas.cache?.clear?.();
8050
- getBedrockExtraBodyParamsBetas.cache?.clear?.();
8051
- }
8052
- var ALLOWED_SDK_BETAS, getAllModelBetas, getModelBetas, getBedrockExtraBodyParamsBetas;
8053
- var init_betas2 = __esm(() => {
8054
- init_memoize();
8055
- init_growthbook();
8056
- init_state();
8057
- init_betas();
8058
- init_oauth();
8059
- init_auth();
8060
- init_context();
8061
- init_envUtils();
8062
- init_model();
8063
- init_modelSupportOverrides();
8064
- init_providers();
8065
- init_settings2();
8066
- ALLOWED_SDK_BETAS = [CONTEXT_1M_BETA_HEADER];
8067
- getAllModelBetas = memoize_default((model) => {
8068
- const betaHeaders = [];
8069
- const isHaiku = getCanonicalName(model).includes("haiku");
8070
- const provider = getAPIProvider();
8071
- const includeFirstPartyOnlyBetas = shouldIncludeFirstPartyOnlyBetas();
8072
- if (!isHaiku) {
8073
- betaHeaders.push(CLAUDE_CODE_20250219_BETA_HEADER);
8074
- if (process.env.USER_TYPE === "ant" && process.env.CLAUDE_CODE_ENTRYPOINT === "cli") {
8075
- if (CLI_INTERNAL_BETA_HEADER) {
8076
- betaHeaders.push(CLI_INTERNAL_BETA_HEADER);
8077
- }
8078
- }
8079
- }
8080
- if (isClaudeAISubscriber()) {
8081
- betaHeaders.push(OAUTH_BETA_HEADER);
8082
- }
8083
- if (has1mContext(model)) {
8084
- betaHeaders.push(CONTEXT_1M_BETA_HEADER);
8085
- }
8086
- if (!isEnvTruthy(process.env.DISABLE_INTERLEAVED_THINKING) && modelSupportsISP(model)) {
8087
- betaHeaders.push(INTERLEAVED_THINKING_BETA_HEADER);
8088
- }
8089
- if (includeFirstPartyOnlyBetas && modelSupportsISP(model) && !getIsNonInteractiveSession() && getInitialSettings().showThinkingSummaries !== true) {
8090
- betaHeaders.push(REDACT_THINKING_BETA_HEADER);
8091
- }
8092
- const antOptedIntoToolClearing = isEnvTruthy(process.env.USE_API_CONTEXT_MANAGEMENT) && process.env.USER_TYPE === "ant";
8093
- const thinkingPreservationEnabled = modelSupportsContextManagement(model);
8094
- if (shouldIncludeFirstPartyOnlyBetas() && (antOptedIntoToolClearing || thinkingPreservationEnabled)) {
8095
- betaHeaders.push(CONTEXT_MANAGEMENT_BETA_HEADER);
8096
- }
8097
- const strictToolsEnabled = checkStatsigFeatureGate_CACHED_MAY_BE_STALE("tengu_tool_pear");
8098
- const tokenEfficientToolsEnabled = !strictToolsEnabled && getFeatureValue_CACHED_MAY_BE_STALE("tengu_amber_json_tools", false);
8099
- if (includeFirstPartyOnlyBetas && modelSupportsStructuredOutputs(model) && strictToolsEnabled) {
8100
- betaHeaders.push(STRUCTURED_OUTPUTS_BETA_HEADER);
8101
- }
8102
- if (process.env.USER_TYPE === "ant" && includeFirstPartyOnlyBetas && tokenEfficientToolsEnabled) {
8103
- betaHeaders.push(TOKEN_EFFICIENT_TOOLS_BETA_HEADER);
8104
- }
8105
- if (provider === "vertex" && vertexModelSupportsWebSearch(model)) {
8106
- betaHeaders.push(WEB_SEARCH_BETA_HEADER);
8107
- }
8108
- if (provider === "foundry") {
8109
- betaHeaders.push(WEB_SEARCH_BETA_HEADER);
8110
- }
8111
- if (includeFirstPartyOnlyBetas) {
8112
- betaHeaders.push(PROMPT_CACHING_SCOPE_BETA_HEADER);
8113
- }
8114
- if (process.env.ANTHROPIC_BETAS) {
8115
- betaHeaders.push(...process.env.ANTHROPIC_BETAS.split(",").map((_) => _.trim()).filter(Boolean));
8116
- }
8117
- return betaHeaders;
8118
- });
8119
- getModelBetas = memoize_default((model) => {
8120
- const modelBetas = getAllModelBetas(model);
8121
- if (getAPIProvider() === "bedrock") {
8122
- return modelBetas.filter((b) => !BEDROCK_EXTRA_PARAMS_HEADERS.has(b));
8123
- }
8124
- return modelBetas;
8125
- });
8126
- getBedrockExtraBodyParamsBetas = memoize_default((model) => {
8127
- const modelBetas = getAllModelBetas(model);
8128
- return modelBetas.filter((b) => BEDROCK_EXTRA_PARAMS_HEADERS.has(b));
8129
- });
8130
- });
8131
-
8132
- // src/utils/secureStorage/fallbackStorage.ts
8133
- function createFallbackStorage(primary, secondary) {
8134
- return {
8135
- name: `${primary.name}-with-${secondary.name}-fallback`,
8136
- read() {
8137
- const result = primary.read();
8138
- if (result !== null && result !== undefined) {
8139
- return result;
8140
- }
8141
- return secondary.read() || {};
8142
- },
8143
- async readAsync() {
8144
- const result = await primary.readAsync();
8145
- if (result !== null && result !== undefined) {
8146
- return result;
8147
- }
8148
- return await secondary.readAsync() || {};
8149
- },
8150
- update(data) {
8151
- const primaryDataBefore = primary.read();
8152
- const result = primary.update(data);
8153
- if (result.success) {
8154
- if (primaryDataBefore === null) {
8155
- secondary.delete();
8156
- }
8157
- return result;
8158
- }
8159
- const fallbackResult = secondary.update(data);
8160
- if (fallbackResult.success) {
8161
- if (primaryDataBefore !== null) {
8162
- primary.delete();
8163
- }
8164
- return {
8165
- success: true,
8166
- warning: fallbackResult.warning
8167
- };
8168
- }
8169
- return { success: false };
8170
- },
8171
- delete() {
8172
- const primarySuccess = primary.delete();
8173
- const secondarySuccess = secondary.delete();
8174
- return primarySuccess || secondarySuccess;
8175
- }
8176
- };
8177
- }
8178
- var init_fallbackStorage = () => {};
8179
-
8180
- // src/utils/secureStorage/macOsKeychainStorage.ts
8181
- async function doReadAsync() {
8182
- try {
8183
- const storageServiceName = getMacOsKeychainStorageServiceName(CREDENTIALS_SERVICE_SUFFIX);
8184
- const username = getUsername();
8185
- const { stdout, code } = await execFileNoThrow("security", ["find-generic-password", "-a", username, "-w", "-s", storageServiceName], { useCwd: false, preserveOutputOnError: false });
8186
- if (code === 0 && stdout) {
8187
- return jsonParse(stdout.trim());
8188
- }
8189
- } catch (_e) {}
8190
- return null;
8191
- }
8192
- function isMacOsKeychainLocked() {
8193
- if (keychainLockedCache !== undefined)
8194
- return keychainLockedCache;
8195
- if (process.platform !== "darwin") {
8196
- keychainLockedCache = false;
8197
- return false;
8198
- }
8199
- try {
8200
- const result = execaSync("security", ["show-keychain-info"], {
8201
- reject: false,
8202
- stdio: ["ignore", "pipe", "pipe"]
8203
- });
8204
- keychainLockedCache = result.exitCode === 36;
8205
- } catch {
8206
- keychainLockedCache = false;
8207
- }
8208
- return keychainLockedCache;
8209
- }
8210
- var SECURITY_STDIN_LINE_LIMIT, macOsKeychainStorage, keychainLockedCache;
8211
- var init_macOsKeychainStorage = __esm(() => {
8212
- init_execa();
8213
- init_debug();
8214
- init_execFileNoThrow();
8215
- init_execFileNoThrowPortable();
8216
- init_slowOperations();
8217
- init_macOsKeychainHelpers();
8218
- SECURITY_STDIN_LINE_LIMIT = 4096 - 64;
8219
- macOsKeychainStorage = {
8220
- name: "keychain",
8221
- read() {
8222
- const prev = keychainCacheState.cache;
8223
- if (Date.now() - prev.cachedAt < KEYCHAIN_CACHE_TTL_MS) {
8224
- return prev.data;
8225
- }
8226
- try {
8227
- const storageServiceName = getMacOsKeychainStorageServiceName(CREDENTIALS_SERVICE_SUFFIX);
8228
- const username = getUsername();
8229
- const result = execSyncWithDefaults_DEPRECATED(`security find-generic-password -a "${username}" -w -s "${storageServiceName}"`);
8230
- if (result) {
8231
- const data = jsonParse(result);
8232
- keychainCacheState.cache = { data, cachedAt: Date.now() };
8233
- return data;
8234
- }
8235
- } catch (_e) {}
8236
- if (prev.data !== null) {
8237
- logForDebugging("[keychain] read failed; serving stale cache", {
8238
- level: "warn"
8239
- });
8240
- keychainCacheState.cache = { data: prev.data, cachedAt: Date.now() };
8241
- return prev.data;
8242
- }
8243
- keychainCacheState.cache = { data: null, cachedAt: Date.now() };
8244
- return null;
8245
- },
8246
- async readAsync() {
8247
- const prev = keychainCacheState.cache;
8248
- if (Date.now() - prev.cachedAt < KEYCHAIN_CACHE_TTL_MS) {
8249
- return prev.data;
8250
- }
8251
- if (keychainCacheState.readInFlight) {
8252
- return keychainCacheState.readInFlight;
8253
- }
8254
- const gen = keychainCacheState.generation;
8255
- const promise = doReadAsync().then((data) => {
8256
- if (gen === keychainCacheState.generation) {
8257
- if (data === null && prev.data !== null) {
8258
- logForDebugging("[keychain] readAsync failed; serving stale cache", {
8259
- level: "warn"
8260
- });
8261
- }
8262
- const next = data ?? prev.data;
8263
- keychainCacheState.cache = { data: next, cachedAt: Date.now() };
8264
- keychainCacheState.readInFlight = null;
8265
- return next;
8266
- }
8267
- return data;
8268
- });
8269
- keychainCacheState.readInFlight = promise;
8270
- return promise;
8271
- },
8272
- update(data) {
8273
- clearKeychainCache();
8274
- try {
8275
- const storageServiceName = getMacOsKeychainStorageServiceName(CREDENTIALS_SERVICE_SUFFIX);
8276
- const username = getUsername();
8277
- const jsonString = jsonStringify(data);
8278
- const hexValue = Buffer.from(jsonString, "utf-8").toString("hex");
8279
- const command = `add-generic-password -U -a "${username}" -s "${storageServiceName}" -X "${hexValue}"
8280
- `;
8281
- let result;
8282
- if (command.length <= SECURITY_STDIN_LINE_LIMIT) {
8283
- result = execaSync("security", ["-i"], {
8284
- input: command,
8285
- stdio: ["pipe", "pipe", "pipe"],
8286
- reject: false
8287
- });
8288
- } else {
8289
- logForDebugging(`Keychain payload (${jsonString.length}B JSON) exceeds security -i stdin limit; using argv`, { level: "warn" });
8290
- result = execaSync("security", [
8291
- "add-generic-password",
8292
- "-U",
8293
- "-a",
8294
- username,
8295
- "-s",
8296
- storageServiceName,
8297
- "-X",
8298
- hexValue
8299
- ], { stdio: ["ignore", "pipe", "pipe"], reject: false });
8300
- }
8301
- if (result.exitCode !== 0) {
8302
- return { success: false };
8303
- }
8304
- keychainCacheState.cache = { data, cachedAt: Date.now() };
8305
- return { success: true };
8306
- } catch (_e) {
8307
- return { success: false };
8308
- }
8309
- },
8310
- delete() {
8311
- clearKeychainCache();
8312
- try {
8313
- const storageServiceName = getMacOsKeychainStorageServiceName(CREDENTIALS_SERVICE_SUFFIX);
8314
- const username = getUsername();
8315
- execSyncWithDefaults_DEPRECATED(`security delete-generic-password -a "${username}" -s "${storageServiceName}"`);
8316
- return true;
8317
- } catch (_e) {
8318
- return false;
8319
- }
8320
- }
8321
- };
8322
- });
8323
-
8324
- // src/utils/secureStorage/plainTextStorage.ts
8325
- import { chmodSync as chmodSync2 } from "fs";
8326
- import { join as join10 } from "path";
8327
- function getStoragePath() {
8328
- const storageDir = getClaudeConfigHomeDir();
8329
- const storageFileName = ".credentials.json";
8330
- return { storageDir, storagePath: join10(storageDir, storageFileName) };
8331
- }
8332
- var plainTextStorage;
8333
- var init_plainTextStorage = __esm(() => {
8334
- init_envUtils();
8335
- init_errors();
8336
- init_fsOperations();
8337
- init_slowOperations();
8338
- plainTextStorage = {
8339
- name: "plaintext",
8340
- read() {
8341
- const { storagePath } = getStoragePath();
8342
- try {
8343
- const data = getFsImplementation().readFileSync(storagePath, {
8344
- encoding: "utf8"
8345
- });
8346
- return jsonParse(data);
8347
- } catch {
8348
- return null;
8349
- }
8350
- },
8351
- async readAsync() {
8352
- const { storagePath } = getStoragePath();
8353
- try {
8354
- const data = await getFsImplementation().readFile(storagePath, {
8355
- encoding: "utf8"
8356
- });
8357
- return jsonParse(data);
8358
- } catch {
8359
- return null;
8360
- }
8361
- },
8362
- update(data) {
8363
- try {
8364
- const { storageDir, storagePath } = getStoragePath();
8365
- try {
8366
- getFsImplementation().mkdirSync(storageDir);
8367
- } catch (e) {
8368
- const code = getErrnoCode(e);
8369
- if (code !== "EEXIST") {
8370
- throw e;
8371
- }
8372
- }
8373
- writeFileSync_DEPRECATED(storagePath, jsonStringify(data), {
8374
- encoding: "utf8",
8375
- flush: false
8376
- });
8377
- chmodSync2(storagePath, 384);
8378
- return {
8379
- success: true,
8380
- warning: "Warning: Storing credentials in plaintext."
8381
- };
8382
- } catch {
8383
- return { success: false };
8384
- }
8385
- },
8386
- delete() {
8387
- const { storagePath } = getStoragePath();
8388
- try {
8389
- getFsImplementation().unlinkSync(storagePath);
8390
- return true;
8391
- } catch (e) {
8392
- const code = getErrnoCode(e);
8393
- if (code === "ENOENT") {
8394
- return true;
8395
- }
8396
- return false;
8397
- }
8398
- }
8399
- };
8400
- });
8401
-
8402
- // src/utils/secureStorage/index.ts
8403
- function getSecureStorage() {
8404
- if (process.platform === "darwin") {
8405
- return createFallbackStorage(macOsKeychainStorage, plainTextStorage);
8406
- }
8407
- return plainTextStorage;
8408
- }
8409
- var init_secureStorage = __esm(() => {
8410
- init_fallbackStorage();
8411
- init_macOsKeychainStorage();
8412
- init_plainTextStorage();
8413
- });
8414
-
8415
- // src/utils/toolSchemaCache.ts
8416
- function getToolSchemaCache() {
8417
- return TOOL_SCHEMA_CACHE;
8418
- }
8419
- function clearToolSchemaCache() {
8420
- TOOL_SCHEMA_CACHE.clear();
8421
- }
8422
- var TOOL_SCHEMA_CACHE;
8423
- var init_toolSchemaCache = __esm(() => {
8424
- TOOL_SCHEMA_CACHE = new Map;
8425
- });
8426
-
8427
- export { logEventTo1P, shutdown1PEventLogging, init_firstPartyEventLogger, isEqual_default, init_isEqual, init_lodash, _baseSet_default, init__baseSet, pickBy_default, init_pickBy, _baseFor_default, init__baseFor, isPlainObject_default, init_isPlainObject, _overRest_default, init__overRest, _setToString_default, init__setToString, detectEncodingForResolvedPath, readFileSyncWithMetadata, readFileSync, init_fileRead, pathExists, MAX_OUTPUT_SIZE, readFileSafe, getFileModificationTime, getFileModificationTimeAsync, writeTextContent, detectFileEncoding, detectLineEndings, convertLeadingTabsToSpaces, getDisplayPath, findSimilarFile, FILE_NOT_FOUND_CWD_NOTE, suggestPathUnderCwd, isCompactLinePrefixEnabled, addLineNumbers, stripLineNumberPrefix, isDirEmpty, readFileSyncCached, getDesktopPath, isFileWithinReadSizeLimit, normalizePathForComparison, pathsEqual, init_file, isPathGitignored, init_gitignore, SETTING_SOURCES, getSettingSourceName, getSourceDisplayName, getSettingSourceDisplayNameLowercase, getSettingSourceDisplayNameCapitalized, parseSettingSourcesFlag, getEnabledSettingSources, isSettingSourceEnabled, SOURCES, init_constants, consumeInternalWrite, clearInternalWrites, init_internalWrites, getManagedFilePath, getManagedSettingsDropInDir, init_managedPath, BLACK_CIRCLE, BULLET_OPERATOR, TEARDROP_ASTERISK, UP_ARROW, DOWN_ARROW, LIGHTNING_BOLT, EFFORT_LOW, EFFORT_MEDIUM, EFFORT_HIGH, EFFORT_MAX, PLAY_ICON, PAUSE_ICON, REFRESH_ARROW, DIAMOND_OPEN, DIAMOND_FILLED, REFERENCE_MARK, FLAG_ICON, BLOCKQUOTE_BAR, init_figures, EXTERNAL_PERMISSION_MODES, PERMISSION_MODES, init_permissions, permissionModeSchema, externalPermissionModeSchema, isExternalPermissionMode, toExternalPermissionMode, permissionModeFromString, permissionModeTitle, isDefaultMode, permissionModeSymbol, getModeColor, init_PermissionMode, HOOK_EVENTS, init_agentSdkTypes, DEFAULT_HOOK_SHELL, init_shellProvider, HooksSchema, ALLOWED_OFFICIAL_MARKETPLACE_NAMES, isMarketplaceAutoUpdate, validateOfficialNameSource, PluginHooksSchema, LspServerConfigSchema, PluginManifestSchema, isLocalPluginSource, isLocalMarketplaceSource, PluginMarketplaceEntrySchema, PluginMarketplaceSchema, PluginIdSchema, InstalledPluginsFileSchemaV1, InstalledPluginsFileSchemaV2, KnownMarketplacesFileSchema, init_schemas, mcpInfoFromString, getMcpPrefix, buildMcpToolName, getToolNameForPermissionCheck, getMcpDisplayName, extractMcpToolDisplayName, init_mcpStringUtils, AGENT_TOOL_NAME, LEGACY_AGENT_TOOL_NAME, VERIFICATION_AGENT_TYPE, ONE_SHOT_BUILTIN_AGENT_TYPES, init_constants2 as init_constants1, TASK_OUTPUT_TOOL_NAME, init_constants3 as init_constants2, TASK_STOP_TOOL_NAME, DESCRIPTION, init_prompt, BRIEF_TOOL_NAME, LEGACY_BRIEF_TOOL_NAME, DESCRIPTION2 as DESCRIPTION1, BRIEF_TOOL_PROMPT, exports_prompt, init_prompt2 as init_prompt1, normalizeLegacyToolName, getLegacyToolNames, permissionRuleValueFromString, permissionRuleValueToString, init_permissionRuleParser, escapeRegExp, capitalize, plural, firstLineOf, countCharInString, normalizeFullWidthDigits, normalizeFullWidthSpace, safeJoinLines, EndTruncatingAccumulator, truncateToLines, init_stringUtils, CUSTOMIZATION_SURFACES, SettingsSchema, isMcpServerNameEntry, isMcpServerCommandEntry, isMcpServerUrlEntry, init_types2 as init_types, validateSettingsFileContent, init_validation, startMdmRawRead, init_rawRead, ensureMdmSettingsLoaded, getMdmSettings, getHkcuSettings, setMdmSettingsCache, refreshMdmSettings, init_settings, getManagedFileSettingsPresence, parseSettingsFile, getSettingsRootPathForSource, getSettingsFilePathForSource, getRelativeSettingsFilePathForSource, getSettingsForSource, getPolicySettingsOrigin, updateSettingsForSource, getManagedSettingsKeysForLogging, getInitialSettings, getSettings_DEPRECATED, getSettingsWithSources, getSettingsWithErrors, hasSkipDangerousModePermissionPrompt, hasAutoModeOptIn, rawSettingsContainsKey, init_settings2 as init_settings1, isAutoMemoryEnabled, isExtractModeActive, getMemoryBaseDir, hasAutoMemPathOverride, getAutoMemPath, getAutoMemEntrypoint, isAutoMemPath, init_paths, NOTIFICATION_CHANNELS, EDITOR_MODES, TEAMMATE_MODES, init_configConstants, DEFAULT_GLOBAL_CONFIG, GLOBAL_CONFIG_KEYS, isGlobalConfigKey, PROJECT_CONFIG_KEYS, resetTrustDialogAcceptedCacheForTesting, checkHasTrustDialogAccepted, isPathTrusted, isProjectConfigKey, saveGlobalConfig, getGlobalConfigWriteCount, CONFIG_WRITE_DISPLAY_THRESHOLD, getGlobalConfig, getRemoteControlAtStartup, getCustomApiKeyStatus, enableConfigs, getProjectPathForConfig, getCurrentProjectConfig, saveCurrentProjectConfig, isAutoUpdaterDisabled, shouldSkipPluginAutoupdate, formatAutoUpdaterDisabledReason, getAutoUpdaterDisabledReason, getOrCreateUserID, recordFirstStartTime, getMemoryPath, getManagedClaudeRulesDir, getUserClaudeRulesDir, _getConfigForTesting, _wouldLoseAuthStateForTesting, _setGlobalConfigCacheForTesting, init_config, sequential, init_sequential, getBedrockRegionPrefix, applyBedrockRegionPrefix, getInferenceProfileBackingModel, init_bedrock, CLAUDE_OPUS_4_6_CONFIG, ALL_MODEL_CONFIGS, init_configs, getAPIProvider, getAPIProviderForStatsig, isFirstPartyAnthropicBaseUrl, init_providers, getModelStrings2 as getModelStrings, ensureModelStringsInitialized, init_modelStrings, hasConsoleBillingAccess, hasClaudeAiBillingAccess, init_billing, getMockHeaderless429Message, getMockHeaders, applyMockHeaders, shouldProcessMockLimits, isMockFastModeRateLimitScenario, checkMockFastModeRateLimit, init_mockRateLimits, CCR_SESSION_INGRESS_TOKEN_PATH, maybePersistTokenForSubprocesses, readTokenFromWellKnownFile, init_authFileDescriptor, clearKeychainCache, init_macOsKeychainHelpers, normalizeApiKeyForConfig, init_authPortable, CONTEXT_1M_BETA_HEADER, CONTEXT_MANAGEMENT_BETA_HEADER, STRUCTURED_OUTPUTS_BETA_HEADER, EFFORT_BETA_HEADER, TASK_BUDGETS_BETA_HEADER, PROMPT_CACHING_SCOPE_BETA_HEADER, FAST_MODE_BETA_HEADER, REDACT_THINKING_BETA_HEADER, AFK_MODE_BETA_HEADER, ADVISOR_BETA_HEADER, VERTEX_COUNT_TOKENS_ALLOWED_BETAS, init_betas, getAntModelOverrideConfig, getAntModels, resolveAntModel, init_antModels, 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, formatModelPricing, init_modelCost, MODEL_ALIASES, init_aliases, isModelAllowed, init_modelAllowlist, getSmallFastModel, isNonCustomOpusModel, getUserSpecifiedModelSetting, getMainLoopModel, getDefaultOpusModel, getDefaultSonnetModel, getDefaultHaikuModel, getRuntimeMainLoopModel, getDefaultMainLoopModelSetting, getDefaultMainLoopModel, getCanonicalName, getClaudeAiUserDefaultModelDescription, renderDefaultModelSetting, getOpus46PricingSuffix, isOpus1mMergeEnabled, renderModelSetting, getPublicModelDisplayName, renderModelName, getPublicModelName, parseUserSpecifiedModel, resolveSkillModelOverride, isLegacyModelRemapEnabled, modelDisplayString, getMarketingNameForModel, normalizeModelStringForAPI, init_model, 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, get3PModelCapabilityOverride, init_modelSupportOverrides, filterAllowedSdkBetas, modelSupportsStructuredOutputs, modelSupportsAutoMode, getToolSearchBetaHeader, shouldIncludeFirstPartyOnlyBetas, shouldUseGlobalCacheScope, getModelBetas, getBedrockExtraBodyParamsBetas, getMergedBetas, clearBetasCaches, init_betas2 as init_betas1, isMacOsKeychainLocked, init_macOsKeychainStorage, getSecureStorage, init_secureStorage, startKeychainPrefetch, ensureKeychainPrefetchCompleted, init_keychainPrefetch, getToolSchemaCache, clearToolSchemaCache, init_toolSchemaCache, isAnthropicAuthEnabled, getAuthTokenSource, getAnthropicApiKey, hasAnthropicApiKeyAuth, getAnthropicApiKeyWithSource, getConfiguredApiKeyHelper, isAwsAuthRefreshFromProjectSettings, isAwsCredentialExportFromProjectSettings, refreshAndGetAwsCredentials, clearAwsCredentialsCache, calculateApiKeyHelperTTL, getApiKeyHelperElapsedMs, getApiKeyFromApiKeyHelper, getApiKeyFromApiKeyHelperCached, clearApiKeyHelperCache, prefetchApiKeyFromApiKeyHelperIfSafe, refreshAwsAuth, isGcpAuthRefreshFromProjectSettings, checkGcpCredentialsValid, refreshGcpAuth, refreshGcpCredentialsIfNeeded, clearGcpCredentialsCache, prefetchGcpCredentialsIfSafe, prefetchAwsCredentialsAndBedRockInfoIfSafe, getApiKeyFromConfigOrMacOSKeychain, saveApiKey, isCustomApiKeyApproved, removeApiKey, saveOAuthTokensIfNeeded, getClaudeAIOAuthTokens, clearOAuthTokenCache, handleOAuth401Error, getClaudeAIOAuthTokensAsync, checkAndRefreshOAuthTokenIfNeeded, isClaudeAISubscriber, hasProfileScope, is1PApiCustomer, getOauthAccountInfo, isOverageProvisioningAllowed, hasOpusAccess, getSubscriptionType, isMaxSubscriber, isTeamSubscriber, isTeamPremiumSubscriber, isEnterpriseSubscriber, isProSubscriber, getRateLimitTier, getSubscriptionName, isUsing3PServices, isOtelHeadersHelperFromProjectOrLocalSettings, getOtelHeadersFromHelper, isConsumerSubscriber, getAccountInformation, validateForceLoginOrg, init_auth, getClaudeCodeUserAgent, init_userAgent, WORKLOAD_CRON, getWorkload, runWithWorkload, init_workloadContext, getUserAgent, getMCPUserAgent, getWebFetchUserAgent, getAuthHeaders, withOAuth401Retry, init_http, initUser, resetUserCache, getGitEmail, init_user, onGrowthBookRefresh, hasGrowthBookEnvOverride, initializeGrowthBook, getFeatureValue_CACHED_MAY_BE_STALE, getFeatureValue_CACHED_WITH_REFRESH, checkStatsigFeatureGate_CACHED_MAY_BE_STALE, checkSecurityRestrictionGate, checkGate_CACHED_OR_BLOCKING, refreshGrowthBookAfterAuthChange, resetGrowthBook, getDynamicConfig_BLOCKS_ON_INIT, getDynamicConfig_CACHED_MAY_BE_STALE, init_growthbook };
5827
+ export { logEventTo1P, shutdown1PEventLogging, init_firstPartyEventLogger, isEqual_default, init_isEqual, init_lodash, _baseSet_default, init__baseSet, pickBy_default, init_pickBy, _baseFor_default, init__baseFor, isPlainObject_default, init_isPlainObject, _overRest_default, init__overRest, _setToString_default, init__setToString, detectEncodingForResolvedPath, readFileSyncWithMetadata, readFileSync, init_fileRead, pathExists, MAX_OUTPUT_SIZE, readFileSafe, getFileModificationTime, getFileModificationTimeAsync, writeTextContent, detectFileEncoding, detectLineEndings, convertLeadingTabsToSpaces, getDisplayPath, findSimilarFile, FILE_NOT_FOUND_CWD_NOTE, suggestPathUnderCwd, isCompactLinePrefixEnabled, addLineNumbers, stripLineNumberPrefix, isDirEmpty, readFileSyncCached, getDesktopPath, isFileWithinReadSizeLimit, normalizePathForComparison, pathsEqual, init_file, isPathGitignored, init_gitignore, SETTING_SOURCES, getSettingSourceName, getSourceDisplayName, getSettingSourceDisplayNameLowercase, getSettingSourceDisplayNameCapitalized, parseSettingSourcesFlag, getEnabledSettingSources, isSettingSourceEnabled, SOURCES, init_constants, consumeInternalWrite, clearInternalWrites, init_internalWrites, getManagedFilePath, getManagedSettingsDropInDir, init_managedPath, BLACK_CIRCLE, BULLET_OPERATOR, TEARDROP_ASTERISK, UP_ARROW, DOWN_ARROW, LIGHTNING_BOLT, EFFORT_LOW, EFFORT_MEDIUM, EFFORT_HIGH, EFFORT_MAX, PLAY_ICON, PAUSE_ICON, REFRESH_ARROW, DIAMOND_OPEN, DIAMOND_FILLED, REFERENCE_MARK, FLAG_ICON, BLOCKQUOTE_BAR, init_figures, EXTERNAL_PERMISSION_MODES, PERMISSION_MODES, init_permissions, permissionModeSchema, externalPermissionModeSchema, isExternalPermissionMode, toExternalPermissionMode, permissionModeFromString, permissionModeTitle, isDefaultMode, permissionModeSymbol, getModeColor, init_PermissionMode, HOOK_EVENTS, init_agentSdkTypes, DEFAULT_HOOK_SHELL, init_shellProvider, HooksSchema, ALLOWED_OFFICIAL_MARKETPLACE_NAMES, isMarketplaceAutoUpdate, validateOfficialNameSource, PluginHooksSchema, LspServerConfigSchema, PluginManifestSchema, isLocalPluginSource, isLocalMarketplaceSource, PluginMarketplaceEntrySchema, PluginMarketplaceSchema, PluginIdSchema, InstalledPluginsFileSchemaV1, InstalledPluginsFileSchemaV2, KnownMarketplacesFileSchema, init_schemas, mcpInfoFromString, getMcpPrefix, buildMcpToolName, getToolNameForPermissionCheck, getMcpDisplayName, extractMcpToolDisplayName, init_mcpStringUtils, AGENT_TOOL_NAME, LEGACY_AGENT_TOOL_NAME, VERIFICATION_AGENT_TYPE, ONE_SHOT_BUILTIN_AGENT_TYPES, init_constants2 as init_constants1, TASK_OUTPUT_TOOL_NAME, init_constants3 as init_constants2, TASK_STOP_TOOL_NAME, DESCRIPTION, init_prompt, BRIEF_TOOL_NAME, LEGACY_BRIEF_TOOL_NAME, DESCRIPTION2 as DESCRIPTION1, BRIEF_TOOL_PROMPT, exports_prompt, init_prompt2 as init_prompt1, normalizeLegacyToolName, getLegacyToolNames, permissionRuleValueFromString, permissionRuleValueToString, init_permissionRuleParser, escapeRegExp, capitalize, plural, firstLineOf, countCharInString, normalizeFullWidthDigits, normalizeFullWidthSpace, safeJoinLines, EndTruncatingAccumulator, truncateToLines, init_stringUtils, CUSTOMIZATION_SURFACES, SettingsSchema, isMcpServerNameEntry, isMcpServerCommandEntry, isMcpServerUrlEntry, init_types2 as init_types, validateSettingsFileContent, init_validation, startMdmRawRead, init_rawRead, ensureMdmSettingsLoaded, getMdmSettings, getHkcuSettings, setMdmSettingsCache, refreshMdmSettings, init_settings, getManagedFileSettingsPresence, parseSettingsFile, getSettingsRootPathForSource, getSettingsFilePathForSource, getRelativeSettingsFilePathForSource, getSettingsForSource, getPolicySettingsOrigin, updateSettingsForSource, getManagedSettingsKeysForLogging, getInitialSettings, getSettings_DEPRECATED, getSettingsWithSources, getSettingsWithErrors, hasSkipDangerousModePermissionPrompt, hasAutoModeOptIn, rawSettingsContainsKey, init_settings2 as init_settings1, isAutoMemoryEnabled, isExtractModeActive, getMemoryBaseDir, hasAutoMemPathOverride, getAutoMemPath, getAutoMemEntrypoint, isAutoMemPath, init_paths, NOTIFICATION_CHANNELS, EDITOR_MODES, TEAMMATE_MODES, init_configConstants, DEFAULT_GLOBAL_CONFIG, GLOBAL_CONFIG_KEYS, isGlobalConfigKey, PROJECT_CONFIG_KEYS, resetTrustDialogAcceptedCacheForTesting, checkHasTrustDialogAccepted, isPathTrusted, isProjectConfigKey, saveGlobalConfig, getGlobalConfigWriteCount, CONFIG_WRITE_DISPLAY_THRESHOLD, getGlobalConfig, getRemoteControlAtStartup, getCustomApiKeyStatus, enableConfigs, getProjectPathForConfig, getCurrentProjectConfig, saveCurrentProjectConfig, isAutoUpdaterDisabled, shouldSkipPluginAutoupdate, formatAutoUpdaterDisabledReason, getAutoUpdaterDisabledReason, getOrCreateUserID, recordFirstStartTime, getMemoryPath, getManagedClaudeRulesDir, getUserClaudeRulesDir, _getConfigForTesting, _wouldLoseAuthStateForTesting, _setGlobalConfigCacheForTesting, init_config, CCR_SESSION_INGRESS_TOKEN_PATH, maybePersistTokenForSubprocesses, readTokenFromWellKnownFile, init_authFileDescriptor, CREDENTIALS_SERVICE_SUFFIX, getMacOsKeychainStorageServiceName, getUsername, KEYCHAIN_CACHE_TTL_MS, keychainCacheState, clearKeychainCache, init_macOsKeychainHelpers, normalizeApiKeyForConfig, init_authPortable, startKeychainPrefetch, ensureKeychainPrefetchCompleted, init_keychainPrefetch, getAuthTokenSource, getAnthropicApiKey, getAnthropicApiKeyWithSource, getConfiguredApiKeyHelper, getApiKeyHelperElapsedMs, getApiKeyFromApiKeyHelper, clearApiKeyHelperCache, prefetchApiKeyFromApiKeyHelperIfSafe, getApiKeyFromConfigOrMacOSKeychain, removeApiKey, is1PApiCustomer, isUsing3PServices, getAccountInformation, init_auth, getClaudeCodeUserAgent, init_userAgent, WORKLOAD_CRON, getWorkload, runWithWorkload, init_workloadContext, getUserAgent, getMCPUserAgent, getWebFetchUserAgent, getAuthHeaders, init_http, initUser, resetUserCache, getGitEmail, init_user, onGrowthBookRefresh, hasGrowthBookEnvOverride, initializeGrowthBook, getFeatureValue_CACHED_MAY_BE_STALE, getFeatureValue_CACHED_WITH_REFRESH, checkStatsigFeatureGate_CACHED_MAY_BE_STALE, checkSecurityRestrictionGate, checkGate_CACHED_OR_BLOCKING, refreshGrowthBookAfterAuthChange, resetGrowthBook, getDynamicConfig_BLOCKS_ON_INIT, getDynamicConfig_CACHED_MAY_BE_STALE, init_growthbook };