@rainhole/rain-code 1.1.0
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.
- package/README.md +172 -0
- package/dist/chunk-06b2745w.js +3583 -0
- package/dist/chunk-06saje2v.js +39 -0
- package/dist/chunk-07069jq1.js +30 -0
- package/dist/chunk-0731m51q.js +8 -0
- package/dist/chunk-0bs2528v.js +192 -0
- package/dist/chunk-0fj1d707.js +313 -0
- package/dist/chunk-0gdkvtx4.js +117 -0
- package/dist/chunk-0jd8rpt4.js +34257 -0
- package/dist/chunk-0paqc2yw.js +15 -0
- package/dist/chunk-0pk0w4j1.js +332 -0
- package/dist/chunk-0rpb2bdp.js +8 -0
- package/dist/chunk-0rvwew67.js +9300 -0
- package/dist/chunk-0sa1g8jf.js +318 -0
- package/dist/chunk-0vkfrmqm.js +690 -0
- package/dist/chunk-0xgxxqhr.js +708 -0
- package/dist/chunk-0xjaqda8.js +1124 -0
- package/dist/chunk-0zep39v0.js +81 -0
- package/dist/chunk-1141xmr4.js +8 -0
- package/dist/chunk-12hn2mhy.js +17 -0
- package/dist/chunk-12rjry89.js +81 -0
- package/dist/chunk-168xb8v1.js +436 -0
- package/dist/chunk-1cwdhk7a.js +969 -0
- package/dist/chunk-1cx0fd76.js +132 -0
- package/dist/chunk-1erfksyp.js +107 -0
- package/dist/chunk-1h1tc4mw.js +126 -0
- package/dist/chunk-1h2famwb.js +49 -0
- package/dist/chunk-1jnbys9f.js +1811 -0
- package/dist/chunk-1k4fp6ft.js +389 -0
- package/dist/chunk-1mjn8xxc.js +22 -0
- package/dist/chunk-1mn6r4y2.js +747 -0
- package/dist/chunk-1p8myfza.js +1568 -0
- package/dist/chunk-1vthytca.js +79 -0
- package/dist/chunk-1y32rx73.js +145 -0
- package/dist/chunk-200781fd.js +64 -0
- package/dist/chunk-205mmm67.js +100 -0
- package/dist/chunk-209eh6ak.js +9381 -0
- package/dist/chunk-21mfpnva.js +85 -0
- package/dist/chunk-238g70xa.js +36 -0
- package/dist/chunk-24k6t9fa.js +151 -0
- package/dist/chunk-29gg6hx0.js +2992 -0
- package/dist/chunk-2a42s11t.js +412 -0
- package/dist/chunk-2ekjxh7d.js +289 -0
- package/dist/chunk-2eykm0j0.js +20 -0
- package/dist/chunk-2fwze72g.js +24 -0
- package/dist/chunk-2gzv8nrw.js +205 -0
- package/dist/chunk-2k995y2x.js +880 -0
- package/dist/chunk-2nayx6q1.js +63 -0
- package/dist/chunk-2pg9pmvc.js +182 -0
- package/dist/chunk-2qp2hc02.js +36 -0
- package/dist/chunk-2rj0dnps.js +436 -0
- package/dist/chunk-2t0xa4dt.js +145 -0
- package/dist/chunk-2ym6tnww.js +216 -0
- package/dist/chunk-30bpz5m2.js +34 -0
- package/dist/chunk-30rst83v.js +168 -0
- package/dist/chunk-36b2q5fg.js +1299 -0
- package/dist/chunk-3c25bcsw.js +17 -0
- package/dist/chunk-3ewzhjyb.js +207 -0
- package/dist/chunk-3h8a89gy.js +46 -0
- package/dist/chunk-3nk79af8.js +8 -0
- package/dist/chunk-3sfr7j85.js +884 -0
- package/dist/chunk-3w6s9m5w.js +16 -0
- package/dist/chunk-3x52v1wb.js +660 -0
- package/dist/chunk-404qm8xt.js +1715 -0
- package/dist/chunk-42fjay4q.js +141 -0
- package/dist/chunk-48649h96.js +8590 -0
- package/dist/chunk-495d85x1.js +8066 -0
- package/dist/chunk-4anj5saq.js +111 -0
- package/dist/chunk-4asynmj4.js +259 -0
- package/dist/chunk-4ck9wve9.js +225 -0
- package/dist/chunk-4cp6193g.js +9076 -0
- package/dist/chunk-4g3v8y12.js +23 -0
- package/dist/chunk-4geyher8.js +244 -0
- package/dist/chunk-4hv90qcz.js +8 -0
- package/dist/chunk-4jhr03e7.js +61 -0
- package/dist/chunk-4jm600zv.js +13 -0
- package/dist/chunk-4nspekjp.js +69 -0
- package/dist/chunk-4ptqcw4p.js +16 -0
- package/dist/chunk-4qj8cqbh.js +173 -0
- package/dist/chunk-4wxsg6a0.js +122 -0
- package/dist/chunk-4zfkzkt6.js +37 -0
- package/dist/chunk-54dckh8a.js +1169 -0
- package/dist/chunk-54y13759.js +650 -0
- package/dist/chunk-54yf6e8d.js +91 -0
- package/dist/chunk-57qz90z8.js +154 -0
- package/dist/chunk-59k0mjnc.js +120 -0
- package/dist/chunk-59p9jye4.js +104 -0
- package/dist/chunk-5c753bd4.js +64 -0
- package/dist/chunk-5cw6zwep.js +106 -0
- package/dist/chunk-5eaf3j24.js +133 -0
- package/dist/chunk-5me7398b.js +81 -0
- package/dist/chunk-5pevjsyw.js +118 -0
- package/dist/chunk-5q3c2rf4.js +107 -0
- package/dist/chunk-5xwtnq4g.js +146 -0
- package/dist/chunk-5z28bqne.js +6748 -0
- package/dist/chunk-613f6fbv.js +63 -0
- package/dist/chunk-641hawvm.js +95 -0
- package/dist/chunk-64c1avct.js +13 -0
- package/dist/chunk-64hks9ax.js +456 -0
- package/dist/chunk-677as3nh.js +15 -0
- package/dist/chunk-6bd8brc4.js +48 -0
- package/dist/chunk-6cs6mmez.js +112 -0
- package/dist/chunk-6dj5t602.js +341 -0
- package/dist/chunk-6e8vht4y.js +780 -0
- package/dist/chunk-6gr3c3w9.js +378 -0
- package/dist/chunk-6hkd32eh.js +83 -0
- package/dist/chunk-6jqxvef0.js +198 -0
- package/dist/chunk-6mh3vfa4.js +115 -0
- package/dist/chunk-6mpw9h55.js +1071 -0
- package/dist/chunk-6p4cyhb3.js +16 -0
- package/dist/chunk-6qvgnepd.js +26 -0
- package/dist/chunk-6r2bhsvt.js +6956 -0
- package/dist/chunk-6tq2v3rk.js +186 -0
- package/dist/chunk-7316m01k.js +125 -0
- package/dist/chunk-73rpbt04.js +1947 -0
- package/dist/chunk-75zk7zr1.js +309 -0
- package/dist/chunk-760252na.js +101 -0
- package/dist/chunk-764ec4ja.js +173 -0
- package/dist/chunk-76vgnv24.js +108 -0
- package/dist/chunk-7739pg2c.js +4261 -0
- package/dist/chunk-7a7hxy3d.js +167 -0
- package/dist/chunk-7aw745vx.js +40175 -0
- package/dist/chunk-7b6bg1r4.js +16128 -0
- package/dist/chunk-7ca4qskp.js +99 -0
- package/dist/chunk-7deph26x.js +311 -0
- package/dist/chunk-7ds8zqar.js +108 -0
- package/dist/chunk-7fqxw3d2.js +479 -0
- package/dist/chunk-7nysf9yd.js +266 -0
- package/dist/chunk-7tascxe2.js +90 -0
- package/dist/chunk-7wm5s02e.js +216 -0
- package/dist/chunk-7xmw2tcz.js +277 -0
- package/dist/chunk-7xyswgjh.js +8 -0
- package/dist/chunk-7zkhadkb.js +220 -0
- package/dist/chunk-8225arm6.js +6374 -0
- package/dist/chunk-83hfzbx3.js +10 -0
- package/dist/chunk-85tag8nv.js +1391 -0
- package/dist/chunk-8bd8q5xw.js +359 -0
- package/dist/chunk-8bwqtasa.js +213 -0
- package/dist/chunk-8g5pe1gr.js +37 -0
- package/dist/chunk-8g747a8x.js +26 -0
- package/dist/chunk-8h6sdj66.js +447 -0
- package/dist/chunk-8mm8b6dd.js +19 -0
- package/dist/chunk-8ndwn6st.js +120 -0
- package/dist/chunk-8pn8tvgg.js +637 -0
- package/dist/chunk-8tnn9kcb.js +131 -0
- package/dist/chunk-8tnsngw2.js +31 -0
- package/dist/chunk-8x5w267y.js +112 -0
- package/dist/chunk-8y12jxg8.js +10 -0
- package/dist/chunk-8ymf4e6z.js +48 -0
- package/dist/chunk-90mt0m1w.js +102 -0
- package/dist/chunk-90wp6wez.js +10510 -0
- package/dist/chunk-91ew1d6f.js +2689 -0
- package/dist/chunk-97jsc1kn.js +231 -0
- package/dist/chunk-993pnm45.js +4521 -0
- package/dist/chunk-9a0rsdre.js +46 -0
- package/dist/chunk-9d7fmqkw.js +41 -0
- package/dist/chunk-9dgaq0g4.js +667 -0
- package/dist/chunk-9f52phb8.js +138 -0
- package/dist/chunk-9fbpqghc.js +105 -0
- package/dist/chunk-9hzxd5q3.js +122 -0
- package/dist/chunk-9kyrssch.js +28 -0
- package/dist/chunk-9q93n4w6.js +308 -0
- package/dist/chunk-9s0xs06y.js +581 -0
- package/dist/chunk-9x5zgy22.js +12 -0
- package/dist/chunk-9zdcb9jy.js +105 -0
- package/dist/chunk-a136cvvz.js +27 -0
- package/dist/chunk-a4psxnr1.js +224 -0
- package/dist/chunk-a4twdmhf.js +45 -0
- package/dist/chunk-a7rhvq9b.js +106 -0
- package/dist/chunk-a8ejc632.js +3094 -0
- package/dist/chunk-a9vdeb6y.js +258 -0
- package/dist/chunk-a9zh40sj.js +48 -0
- package/dist/chunk-aawg48hh.js +4102 -0
- package/dist/chunk-ad2f3890.js +65 -0
- package/dist/chunk-ae7ar1jk.js +105 -0
- package/dist/chunk-ak3hdbe4.js +234 -0
- package/dist/chunk-as4e9g8f.js +298 -0
- package/dist/chunk-ase86y73.js +15 -0
- package/dist/chunk-awb4vc41.js +69 -0
- package/dist/chunk-b4bep0aq.js +5041 -0
- package/dist/chunk-b4wg70y1.js +54 -0
- package/dist/chunk-b81hd3m6.js +32 -0
- package/dist/chunk-b9knmzt0.js +106 -0
- package/dist/chunk-besmz4ym.js +32 -0
- package/dist/chunk-bgpkemkg.js +65 -0
- package/dist/chunk-bj8x29tz.js +54 -0
- package/dist/chunk-bkqsnwrq.js +239 -0
- package/dist/chunk-bnf662he.js +359 -0
- package/dist/chunk-bq00fcsd.js +165 -0
- package/dist/chunk-brz2c4cq.js +275 -0
- package/dist/chunk-bsa118r4.js +502 -0
- package/dist/chunk-bsengrbt.js +2737 -0
- package/dist/chunk-bt64sq5y.js +19 -0
- package/dist/chunk-bxcfz5gy.js +56 -0
- package/dist/chunk-bxs2a71m.js +213 -0
- package/dist/chunk-byv2p9hn.js +397 -0
- package/dist/chunk-c03am3es.js +29 -0
- package/dist/chunk-c2ahb7yg.js +105 -0
- package/dist/chunk-c2qm0t6p.js +111 -0
- package/dist/chunk-c42h9gzx.js +71 -0
- package/dist/chunk-c47xbxqw.js +38 -0
- package/dist/chunk-c5vkve4j.js +68 -0
- package/dist/chunk-c6sjhj89.js +1284 -0
- package/dist/chunk-ca147npg.js +27 -0
- package/dist/chunk-caxx597g.js +71 -0
- package/dist/chunk-cbrt5vsb.js +31 -0
- package/dist/chunk-ce0z23ct.js +443 -0
- package/dist/chunk-cefsp8h1.js +155 -0
- package/dist/chunk-cfv996bs.js +22 -0
- package/dist/chunk-cgfdkzhb.js +12 -0
- package/dist/chunk-chsyvavm.js +3435 -0
- package/dist/chunk-cmsknj6n.js +28228 -0
- package/dist/chunk-cn8bkmvj.js +264 -0
- package/dist/chunk-crmjpsqe.js +68 -0
- package/dist/chunk-cthpw4pj.js +849 -0
- package/dist/chunk-cwy9nj4y.js +134 -0
- package/dist/chunk-cyagce56.js +155 -0
- package/dist/chunk-cynewytp.js +227 -0
- package/dist/chunk-cznf6k4g.js +46 -0
- package/dist/chunk-d0954t9j.js +267 -0
- package/dist/chunk-d1qhftze.js +118 -0
- package/dist/chunk-d4mdda98.js +94 -0
- package/dist/chunk-d4rnqevg.js +41 -0
- package/dist/chunk-d7886r6a.js +13870 -0
- package/dist/chunk-dd1qvamk.js +678 -0
- package/dist/chunk-dg4je8qj.js +183 -0
- package/dist/chunk-dggvswz1.js +104 -0
- package/dist/chunk-dgqrcy74.js +48 -0
- package/dist/chunk-dm3n2qgd.js +24 -0
- package/dist/chunk-dnh7jtpb.js +37 -0
- package/dist/chunk-dsenyfax.js +105 -0
- package/dist/chunk-dtf0a7rr.js +655 -0
- package/dist/chunk-dxdb7bs1.js +60 -0
- package/dist/chunk-e0pth8g7.js +79 -0
- package/dist/chunk-e36y0q82.js +109 -0
- package/dist/chunk-ef55cwrv.js +267 -0
- package/dist/chunk-efh644hv.js +915 -0
- package/dist/chunk-ehtwnxpg.js +1591 -0
- package/dist/chunk-ejahyhd8.js +120 -0
- package/dist/chunk-ejk1bpzz.js +472 -0
- package/dist/chunk-emef71ea.js +202 -0
- package/dist/chunk-en7v028t.js +333 -0
- package/dist/chunk-eqp1rfft.js +17 -0
- package/dist/chunk-ewadzrm8.js +103 -0
- package/dist/chunk-exh7z6tv.js +132 -0
- package/dist/chunk-f0npbgyf.js +340 -0
- package/dist/chunk-f2qkc8ce.js +229 -0
- package/dist/chunk-f49sb3q7.js +40 -0
- package/dist/chunk-f5ma3nh5.js +3436 -0
- package/dist/chunk-fbv4apne.js +51 -0
- package/dist/chunk-fday7sfg.js +269 -0
- package/dist/chunk-feyzykye.js +10 -0
- package/dist/chunk-fgqwr70t.js +241 -0
- package/dist/chunk-fhy7zs1w.js +943 -0
- package/dist/chunk-fmw3f68k.js +432 -0
- package/dist/chunk-fmwqvpqm.js +506 -0
- package/dist/chunk-fn1apgre.js +66 -0
- package/dist/chunk-fpy4nam9.js +21933 -0
- package/dist/chunk-fqy0erkw.js +908 -0
- package/dist/chunk-ftqwza3a.js +43 -0
- package/dist/chunk-fyc5fepv.js +10 -0
- package/dist/chunk-fz0ch109.js +329 -0
- package/dist/chunk-fzhn8z8j.js +253 -0
- package/dist/chunk-g12brv6y.js +321 -0
- package/dist/chunk-g338npwr.js +1061 -0
- package/dist/chunk-g5tpks28.js +795 -0
- package/dist/chunk-g63tgj4f.js +58 -0
- package/dist/chunk-g827r0mk.js +266 -0
- package/dist/chunk-g8wzsxgc.js +2534 -0
- package/dist/chunk-gey7mwcw.js +36 -0
- package/dist/chunk-gghb9pks.js +120 -0
- package/dist/chunk-grdpaf1p.js +606 -0
- package/dist/chunk-gx8016vp.js +125 -0
- package/dist/chunk-h0qngp9w.js +157 -0
- package/dist/chunk-h0rbjg6x.js +55 -0
- package/dist/chunk-h1mr3371.js +121 -0
- package/dist/chunk-h3xwdgpd.js +68 -0
- package/dist/chunk-h4b85amj.js +2331 -0
- package/dist/chunk-h6d137aa.js +20 -0
- package/dist/chunk-h9n7z00d.js +95 -0
- package/dist/chunk-hakdhagh.js +16606 -0
- package/dist/chunk-hd8531ec.js +685 -0
- package/dist/chunk-heq3rn8t.js +33068 -0
- package/dist/chunk-hfvxc9fd.js +542 -0
- package/dist/chunk-hgpd0qmm.js +371 -0
- package/dist/chunk-hh7cmy4k.js +20 -0
- package/dist/chunk-hhjs87wh.js +1407 -0
- package/dist/chunk-hjtvdvgj.js +208 -0
- package/dist/chunk-hk9xz7gk.js +118 -0
- package/dist/chunk-hknbjky3.js +160798 -0
- package/dist/chunk-htsbqyf9.js +338 -0
- package/dist/chunk-htx7jmxk.js +78 -0
- package/dist/chunk-hzhe8ygc.js +547 -0
- package/dist/chunk-j2k4p94p.js +55 -0
- package/dist/chunk-j3a4p81y.js +184 -0
- package/dist/chunk-j46rb9m9.js +544 -0
- package/dist/chunk-j5bth84e.js +97 -0
- package/dist/chunk-j64ga6ta.js +8035 -0
- package/dist/chunk-j6jh72hw.js +140 -0
- package/dist/chunk-j9gxwbe3.js +349 -0
- package/dist/chunk-jaaxk89e.js +113 -0
- package/dist/chunk-jd32zbps.js +15 -0
- package/dist/chunk-jdgeec04.js +4249 -0
- package/dist/chunk-jk826edv.js +174 -0
- package/dist/chunk-jnhkref0.js +30 -0
- package/dist/chunk-jsx72hep.js +208 -0
- package/dist/chunk-jx817w05.js +11 -0
- package/dist/chunk-jzmz18nn.js +65 -0
- package/dist/chunk-k0p9w03v.js +4957 -0
- package/dist/chunk-k3s4yk22.js +477 -0
- package/dist/chunk-kfd89dsd.js +21 -0
- package/dist/chunk-kgfz4522.js +126 -0
- package/dist/chunk-kn6zg6bd.js +524 -0
- package/dist/chunk-kp9vkzj6.js +120 -0
- package/dist/chunk-kraf793v.js +118 -0
- package/dist/chunk-kw0r30h3.js +208 -0
- package/dist/chunk-kwekc97v.js +18 -0
- package/dist/chunk-m2bcpk8j.js +30 -0
- package/dist/chunk-m2kp5f7p.js +4389 -0
- package/dist/chunk-m74w3187.js +164 -0
- package/dist/chunk-m88q4jmb.js +61 -0
- package/dist/chunk-man6wb4n.js +1456 -0
- package/dist/chunk-mdk3xgya.js +42 -0
- package/dist/chunk-mf4g439x.js +82 -0
- package/dist/chunk-mg8g0xqs.js +71 -0
- package/dist/chunk-mkwzrqvf.js +38 -0
- package/dist/chunk-mn61mk4v.js +351 -0
- package/dist/chunk-ms09sxcj.js +908 -0
- package/dist/chunk-mtn1anwe.js +2351 -0
- package/dist/chunk-mv0zm0qj.js +65 -0
- package/dist/chunk-mx28h61f.js +1147 -0
- package/dist/chunk-mxbf8ajn.js +1067 -0
- package/dist/chunk-n0qaeaa5.js +256 -0
- package/dist/chunk-n34z5cw8.js +74 -0
- package/dist/chunk-n55ehz77.js +120 -0
- package/dist/chunk-n7ttdtk0.js +641 -0
- package/dist/chunk-n9ktjngj.js +336 -0
- package/dist/chunk-nb2ntesh.js +149 -0
- package/dist/chunk-netzwgv1.js +154 -0
- package/dist/chunk-nh3cd07f.js +14358 -0
- package/dist/chunk-nka1g8f4.js +773 -0
- package/dist/chunk-nm97cw83.js +458 -0
- package/dist/chunk-nq0fxyxh.js +752 -0
- package/dist/chunk-nt837qt9.js +21 -0
- package/dist/chunk-nx87c0vw.js +250 -0
- package/dist/chunk-nxw6y6xm.js +862 -0
- package/dist/chunk-nzt717xg.js +32 -0
- package/dist/chunk-p2816w9z.js +1486 -0
- package/dist/chunk-p2d5nh3g.js +342 -0
- package/dist/chunk-p9cdykwf.js +72 -0
- package/dist/chunk-paxw1ryd.js +227 -0
- package/dist/chunk-ph5g4d1j.js +109 -0
- package/dist/chunk-pp42p8y3.js +574 -0
- package/dist/chunk-ppdn71n4.js +400 -0
- package/dist/chunk-ppwjyveh.js +8 -0
- package/dist/chunk-ps49ymvj.js +43 -0
- package/dist/chunk-pshjyzq4.js +17656 -0
- package/dist/chunk-pw8nf9rt.js +126 -0
- package/dist/chunk-pwwa7s62.js +11 -0
- package/dist/chunk-py3zxq5j.js +129 -0
- package/dist/chunk-pyz1qswz.js +300 -0
- package/dist/chunk-q50q8mc5.js +157 -0
- package/dist/chunk-q7tpyeb3.js +39 -0
- package/dist/chunk-q82r31er.js +151 -0
- package/dist/chunk-qajrkk97.js +298 -0
- package/dist/chunk-qcpxnyeh.js +110 -0
- package/dist/chunk-qeabchwr.js +132 -0
- package/dist/chunk-qm7nbd10.js +755 -0
- package/dist/chunk-qm8j7kxr.js +280 -0
- package/dist/chunk-qmwgg5zy.js +136 -0
- package/dist/chunk-qnfx3qtx.js +617 -0
- package/dist/chunk-qp2qdcda.js +100 -0
- package/dist/chunk-qphaajd7.js +305 -0
- package/dist/chunk-qt21xxgm.js +419 -0
- package/dist/chunk-qy2z2p0b.js +122 -0
- package/dist/chunk-qyz8q0dj.js +689 -0
- package/dist/chunk-qz2x630m.js +49145 -0
- package/dist/chunk-qzq5n1yn.js +76 -0
- package/dist/chunk-r0ya57xw.js +170 -0
- package/dist/chunk-r7j395t6.js +122 -0
- package/dist/chunk-r7trcrs7.js +62 -0
- package/dist/chunk-re4yh70t.js +1095 -0
- package/dist/chunk-rhte1r8g.js +272 -0
- package/dist/chunk-rhw4ayb1.js +6851 -0
- package/dist/chunk-rn0v1hk8.js +34 -0
- package/dist/chunk-rphakhme.js +281 -0
- package/dist/chunk-rrtzz2pv.js +32 -0
- package/dist/chunk-rtnjk8ge.js +726 -0
- package/dist/chunk-rwhswkma.js +87 -0
- package/dist/chunk-rxd4kn2g.js +308 -0
- package/dist/chunk-s083x8ry.js +2840 -0
- package/dist/chunk-s16sn02n.js +365 -0
- package/dist/chunk-s1s8qfdh.js +182 -0
- package/dist/chunk-s2bwz69v.js +473 -0
- package/dist/chunk-s3pzvdss.js +50 -0
- package/dist/chunk-s9y6t0mt.js +291 -0
- package/dist/chunk-sd36yzx8.js +954 -0
- package/dist/chunk-se8xzw8h.js +87 -0
- package/dist/chunk-sg66v252.js +1648 -0
- package/dist/chunk-sg7gf3hj.js +1585 -0
- package/dist/chunk-spx24x6j.js +98 -0
- package/dist/chunk-sybxpy18.js +73 -0
- package/dist/chunk-szj5wvdy.js +28 -0
- package/dist/chunk-t0gb304x.js +182 -0
- package/dist/chunk-t3fr4skc.js +165 -0
- package/dist/chunk-t58wfamm.js +5368 -0
- package/dist/chunk-t6s2kkm3.js +104 -0
- package/dist/chunk-t8hv0x81.js +116 -0
- package/dist/chunk-tezak8rx.js +6157 -0
- package/dist/chunk-th5y3hj5.js +189 -0
- package/dist/chunk-tj0d3870.js +180 -0
- package/dist/chunk-tjgsawpx.js +40 -0
- package/dist/chunk-ts2p6bv1.js +224 -0
- package/dist/chunk-ttk5dzz8.js +25 -0
- package/dist/chunk-tv9pcdnz.js +51 -0
- package/dist/chunk-ty99rgvw.js +122 -0
- package/dist/chunk-tzgp8av2.js +61 -0
- package/dist/chunk-v1kzp02e.js +785 -0
- package/dist/chunk-v2c9dq7t.js +275 -0
- package/dist/chunk-v3aq3heg.js +620 -0
- package/dist/chunk-v78fj8by.js +145 -0
- package/dist/chunk-v9smspw2.js +4301 -0
- package/dist/chunk-var1et7e.js +66 -0
- package/dist/chunk-vchrkvet.js +120 -0
- package/dist/chunk-vest0y6x.js +3830 -0
- package/dist/chunk-vf5sd1nq.js +12 -0
- package/dist/chunk-vf612n57.js +472 -0
- package/dist/chunk-vgpy9md6.js +339 -0
- package/dist/chunk-vkzt82ry.js +644 -0
- package/dist/chunk-vsh80y0c.js +100 -0
- package/dist/chunk-vxkdxhyk.js +103 -0
- package/dist/chunk-vxt6ywm9.js +485 -0
- package/dist/chunk-vyjeh50y.js +2149 -0
- package/dist/chunk-vytdzvqs.js +1181 -0
- package/dist/chunk-w0qks2ja.js +1030 -0
- package/dist/chunk-wfz0qffj.js +3939 -0
- package/dist/chunk-wp1568nt.js +828 -0
- package/dist/chunk-wpckhx7b.js +66 -0
- package/dist/chunk-wpvkvwvc.js +41 -0
- package/dist/chunk-ws5d6qs4.js +655 -0
- package/dist/chunk-wsnxrrb5.js +986 -0
- package/dist/chunk-wyavftcj.js +103 -0
- package/dist/chunk-wybh0bvv.js +121 -0
- package/dist/chunk-wzpdet3m.js +843 -0
- package/dist/chunk-x2dp18yj.js +74 -0
- package/dist/chunk-x6r4v44b.js +8 -0
- package/dist/chunk-x7r5k0hf.js +423 -0
- package/dist/chunk-xahk20z8.js +877 -0
- package/dist/chunk-xajwdaxm.js +295 -0
- package/dist/chunk-xkt36p6r.js +61 -0
- package/dist/chunk-xnav6j8h.js +490 -0
- package/dist/chunk-xrj294jg.js +440 -0
- package/dist/chunk-xsq9ae7x.js +90 -0
- package/dist/chunk-xt9z9t7b.js +40 -0
- package/dist/chunk-xv3era3s.js +8 -0
- package/dist/chunk-y1784krc.js +19 -0
- package/dist/chunk-y289fz8y.js +116 -0
- package/dist/chunk-y3r7v9pq.js +336 -0
- package/dist/chunk-y98z50mm.js +158 -0
- package/dist/chunk-yhce3x0q.js +64 -0
- package/dist/chunk-yhhf6n9p.js +338 -0
- package/dist/chunk-ykr34msh.js +411 -0
- package/dist/chunk-yks9ggzn.js +103 -0
- package/dist/chunk-ym5r3jnk.js +2007 -0
- package/dist/chunk-ypa349qq.js +148 -0
- package/dist/chunk-yzx3mhfd.js +110 -0
- package/dist/chunk-z1bs6d7k.js +24 -0
- package/dist/chunk-z2dp53wn.js +17 -0
- package/dist/chunk-z3k0k30d.js +882 -0
- package/dist/chunk-z42cqdtf.js +107 -0
- package/dist/chunk-z7asrz6j.js +259 -0
- package/dist/chunk-za09fhhh.js +716 -0
- package/dist/chunk-zae0t3p4.js +252 -0
- package/dist/chunk-zbsw794g.js +259 -0
- package/dist/chunk-ze6zvkg6.js +22820 -0
- package/dist/chunk-zejm280k.js +39 -0
- package/dist/chunk-zk2wsm7d.js +15 -0
- package/dist/chunk-znf2b75k.js +113 -0
- package/dist/chunk-zqpnvsdz.js +24 -0
- package/dist/chunk-zs2gdkj5.js +433 -0
- package/dist/chunk-zseb1639.js +37 -0
- package/dist/chunk-zsgha506.js +63 -0
- package/dist/chunk-zvsfgmq8.js +146 -0
- package/dist/chunk-zw5xd7m9.js +160 -0
- package/dist/chunk-zzm33q8x.js +8 -0
- package/dist/cli.js +97 -0
- package/dist/download-ripgrep.js +24821 -0
- package/dist/vendor/audio-capture/arm64-darwin/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/arm64-linux/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/arm64-win32/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/x64-darwin/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/x64-linux/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/x64-win32/audio-capture.node +0 -0
- package/package.json +178 -0
- package/scripts/download-ripgrep.ts +335 -0
- package/scripts/postinstall.cjs +319 -0
|
@@ -0,0 +1,1391 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
envDynamic,
|
|
4
|
+
getFeatureValue_CACHED_MAY_BE_STALE,
|
|
5
|
+
getOauthAccountInfo,
|
|
6
|
+
getOrCreateUserID,
|
|
7
|
+
init_auth,
|
|
8
|
+
init_config1 as init_config,
|
|
9
|
+
init_envDynamic,
|
|
10
|
+
init_growthbook,
|
|
11
|
+
init_metadata,
|
|
12
|
+
sanitizeToolNameForAnalytics
|
|
13
|
+
} from "./chunk-7b6bg1r4.js";
|
|
14
|
+
import {
|
|
15
|
+
getAgentId,
|
|
16
|
+
getAgentName,
|
|
17
|
+
getParentSessionId,
|
|
18
|
+
init_teammate
|
|
19
|
+
} from "./chunk-1cwdhk7a.js";
|
|
20
|
+
import {
|
|
21
|
+
require_src
|
|
22
|
+
} from "./chunk-p2816w9z.js";
|
|
23
|
+
import {
|
|
24
|
+
djb2Hash,
|
|
25
|
+
init_hash
|
|
26
|
+
} from "./chunk-8tnsngw2.js";
|
|
27
|
+
import {
|
|
28
|
+
init_cleanupRegistry,
|
|
29
|
+
init_debug,
|
|
30
|
+
init_errors,
|
|
31
|
+
init_slowOperations,
|
|
32
|
+
jsonParse,
|
|
33
|
+
jsonStringify,
|
|
34
|
+
logForDebugging
|
|
35
|
+
} from "./chunk-404qm8xt.js";
|
|
36
|
+
import {
|
|
37
|
+
init_envUtils,
|
|
38
|
+
isEnvTruthy
|
|
39
|
+
} from "./chunk-jaaxk89e.js";
|
|
40
|
+
import {
|
|
41
|
+
getEventLogger,
|
|
42
|
+
getIsNonInteractiveSession,
|
|
43
|
+
getPromptId,
|
|
44
|
+
getSessionId,
|
|
45
|
+
init_state
|
|
46
|
+
} from "./chunk-h4b85amj.js";
|
|
47
|
+
import {
|
|
48
|
+
__esm,
|
|
49
|
+
__toESM
|
|
50
|
+
} from "./chunk-qp2qdcda.js";
|
|
51
|
+
|
|
52
|
+
// src/utils/taggedId.ts
|
|
53
|
+
function base58Encode(n) {
|
|
54
|
+
const base = BigInt(BASE_58_CHARS.length);
|
|
55
|
+
const result = new Array(ENCODED_LENGTH).fill(BASE_58_CHARS[0]);
|
|
56
|
+
let i = ENCODED_LENGTH - 1;
|
|
57
|
+
let value = n;
|
|
58
|
+
while (value > 0n) {
|
|
59
|
+
const rem = Number(value % base);
|
|
60
|
+
result[i] = BASE_58_CHARS[rem];
|
|
61
|
+
value = value / base;
|
|
62
|
+
i--;
|
|
63
|
+
}
|
|
64
|
+
return result.join("");
|
|
65
|
+
}
|
|
66
|
+
function uuidToBigInt(uuid) {
|
|
67
|
+
const hex = uuid.replace(/-/g, "");
|
|
68
|
+
if (hex.length !== 32) {
|
|
69
|
+
throw new Error(`Invalid UUID hex length: ${hex.length}`);
|
|
70
|
+
}
|
|
71
|
+
return BigInt("0x" + hex);
|
|
72
|
+
}
|
|
73
|
+
function toTaggedId(tag, uuid) {
|
|
74
|
+
const n = uuidToBigInt(uuid);
|
|
75
|
+
return `${tag}_${VERSION}${base58Encode(n)}`;
|
|
76
|
+
}
|
|
77
|
+
var BASE_58_CHARS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz", VERSION = "01", ENCODED_LENGTH = 22;
|
|
78
|
+
var init_taggedId = () => {};
|
|
79
|
+
|
|
80
|
+
// src/utils/telemetryAttributes.ts
|
|
81
|
+
function shouldIncludeAttribute(envVar) {
|
|
82
|
+
const defaultValue = METRICS_CARDINALITY_DEFAULTS[envVar];
|
|
83
|
+
const envValue = process.env[envVar];
|
|
84
|
+
if (envValue === undefined) {
|
|
85
|
+
return defaultValue;
|
|
86
|
+
}
|
|
87
|
+
return isEnvTruthy(envValue);
|
|
88
|
+
}
|
|
89
|
+
function getTelemetryAttributes() {
|
|
90
|
+
const userId = getOrCreateUserID();
|
|
91
|
+
const sessionId = getSessionId();
|
|
92
|
+
const attributes = {
|
|
93
|
+
"user.id": userId
|
|
94
|
+
};
|
|
95
|
+
if (shouldIncludeAttribute("OTEL_METRICS_INCLUDE_SESSION_ID")) {
|
|
96
|
+
attributes["session.id"] = sessionId;
|
|
97
|
+
}
|
|
98
|
+
if (shouldIncludeAttribute("OTEL_METRICS_INCLUDE_VERSION")) {
|
|
99
|
+
attributes["app.version"] = "2.1.888";
|
|
100
|
+
}
|
|
101
|
+
const oauthAccount = getOauthAccountInfo();
|
|
102
|
+
if (oauthAccount) {
|
|
103
|
+
const orgId = oauthAccount.organizationUuid;
|
|
104
|
+
const email = oauthAccount.emailAddress;
|
|
105
|
+
const accountUuid = oauthAccount.accountUuid;
|
|
106
|
+
if (orgId)
|
|
107
|
+
attributes["organization.id"] = orgId;
|
|
108
|
+
if (email)
|
|
109
|
+
attributes["user.email"] = email;
|
|
110
|
+
if (accountUuid && shouldIncludeAttribute("OTEL_METRICS_INCLUDE_ACCOUNT_UUID")) {
|
|
111
|
+
attributes["user.account_uuid"] = accountUuid;
|
|
112
|
+
attributes["user.account_id"] = process.env.CLAUDE_CODE_ACCOUNT_TAGGED_ID || toTaggedId("user", accountUuid);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (envDynamic.terminal) {
|
|
116
|
+
attributes["terminal.type"] = envDynamic.terminal;
|
|
117
|
+
}
|
|
118
|
+
return attributes;
|
|
119
|
+
}
|
|
120
|
+
var METRICS_CARDINALITY_DEFAULTS;
|
|
121
|
+
var init_telemetryAttributes = __esm(() => {
|
|
122
|
+
init_state();
|
|
123
|
+
init_auth();
|
|
124
|
+
init_config();
|
|
125
|
+
init_envDynamic();
|
|
126
|
+
init_envUtils();
|
|
127
|
+
init_taggedId();
|
|
128
|
+
METRICS_CARDINALITY_DEFAULTS = {
|
|
129
|
+
OTEL_METRICS_INCLUDE_SESSION_ID: true,
|
|
130
|
+
OTEL_METRICS_INCLUDE_VERSION: false,
|
|
131
|
+
OTEL_METRICS_INCLUDE_ACCOUNT_UUID: true
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// src/utils/telemetry/events.ts
|
|
136
|
+
function isUserPromptLoggingEnabled() {
|
|
137
|
+
return isEnvTruthy(process.env.OTEL_LOG_USER_PROMPTS);
|
|
138
|
+
}
|
|
139
|
+
function redactIfDisabled(content) {
|
|
140
|
+
return isUserPromptLoggingEnabled() ? content : "<REDACTED>";
|
|
141
|
+
}
|
|
142
|
+
async function logOTelEvent(eventName, metadata = {}) {
|
|
143
|
+
const eventLogger = getEventLogger();
|
|
144
|
+
if (!eventLogger) {
|
|
145
|
+
if (!hasWarnedNoEventLogger) {
|
|
146
|
+
hasWarnedNoEventLogger = true;
|
|
147
|
+
logForDebugging(`[3P telemetry] Event dropped (no event logger initialized): ${eventName}`, { level: "warn" });
|
|
148
|
+
}
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (false) {}
|
|
152
|
+
const attributes = {
|
|
153
|
+
...getTelemetryAttributes(),
|
|
154
|
+
"event.name": eventName,
|
|
155
|
+
"event.timestamp": new Date().toISOString(),
|
|
156
|
+
"event.sequence": eventSequence++
|
|
157
|
+
};
|
|
158
|
+
const promptId = getPromptId();
|
|
159
|
+
if (promptId) {
|
|
160
|
+
attributes["prompt.id"] = promptId;
|
|
161
|
+
}
|
|
162
|
+
const workspaceDir = process.env.CLAUDE_CODE_WORKSPACE_HOST_PATHS;
|
|
163
|
+
if (workspaceDir) {
|
|
164
|
+
attributes["workspace.host_paths"] = workspaceDir.split("|");
|
|
165
|
+
}
|
|
166
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
167
|
+
if (value !== undefined) {
|
|
168
|
+
attributes[key] = value;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
eventLogger.emit({
|
|
172
|
+
body: `claude_code.${eventName}`,
|
|
173
|
+
attributes
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
var eventSequence = 0, hasWarnedNoEventLogger = false;
|
|
177
|
+
var init_events = __esm(() => {
|
|
178
|
+
init_state();
|
|
179
|
+
init_debug();
|
|
180
|
+
init_envUtils();
|
|
181
|
+
init_telemetryAttributes();
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// src/utils/telemetry/perfettoTracing.ts
|
|
185
|
+
function stringToNumericHash(str) {
|
|
186
|
+
return Math.abs(djb2Hash(str)) || 1;
|
|
187
|
+
}
|
|
188
|
+
function getProcessIdForAgent(agentId) {
|
|
189
|
+
const existing = agentIdToProcessId.get(agentId);
|
|
190
|
+
if (existing !== undefined)
|
|
191
|
+
return existing;
|
|
192
|
+
processIdCounter++;
|
|
193
|
+
agentIdToProcessId.set(agentId, processIdCounter);
|
|
194
|
+
return processIdCounter;
|
|
195
|
+
}
|
|
196
|
+
function getCurrentAgentInfo() {
|
|
197
|
+
const agentId = getAgentId() ?? getSessionId();
|
|
198
|
+
const agentName = getAgentName() ?? "main";
|
|
199
|
+
const parentSessionId = getParentSessionId();
|
|
200
|
+
const existing = agentRegistry.get(agentId);
|
|
201
|
+
if (existing)
|
|
202
|
+
return existing;
|
|
203
|
+
const info = {
|
|
204
|
+
agentId,
|
|
205
|
+
agentName,
|
|
206
|
+
parentAgentId: parentSessionId,
|
|
207
|
+
processId: agentId === getSessionId() ? 1 : getProcessIdForAgent(agentId),
|
|
208
|
+
threadId: stringToNumericHash(agentName)
|
|
209
|
+
};
|
|
210
|
+
agentRegistry.set(agentId, info);
|
|
211
|
+
totalAgentCount++;
|
|
212
|
+
return info;
|
|
213
|
+
}
|
|
214
|
+
function getTimestamp() {
|
|
215
|
+
return (Date.now() - startTimeMs) * 1000;
|
|
216
|
+
}
|
|
217
|
+
function generateSpanId() {
|
|
218
|
+
return `span_${++spanIdCounter}`;
|
|
219
|
+
}
|
|
220
|
+
function initializePerfettoTracing() {
|
|
221
|
+
const envValue = process.env.CLAUDE_CODE_PERFETTO_TRACE;
|
|
222
|
+
logForDebugging(`[Perfetto] initializePerfettoTracing called, env value: ${envValue}`);
|
|
223
|
+
if (false) {}
|
|
224
|
+
}
|
|
225
|
+
function emitProcessMetadata(agentInfo) {
|
|
226
|
+
if (!isEnabled)
|
|
227
|
+
return;
|
|
228
|
+
metadataEvents.push({
|
|
229
|
+
name: "process_name",
|
|
230
|
+
cat: "__metadata",
|
|
231
|
+
ph: "M",
|
|
232
|
+
ts: 0,
|
|
233
|
+
pid: agentInfo.processId,
|
|
234
|
+
tid: 0,
|
|
235
|
+
args: { name: agentInfo.agentName }
|
|
236
|
+
});
|
|
237
|
+
metadataEvents.push({
|
|
238
|
+
name: "thread_name",
|
|
239
|
+
cat: "__metadata",
|
|
240
|
+
ph: "M",
|
|
241
|
+
ts: 0,
|
|
242
|
+
pid: agentInfo.processId,
|
|
243
|
+
tid: agentInfo.threadId,
|
|
244
|
+
args: { name: agentInfo.agentName }
|
|
245
|
+
});
|
|
246
|
+
if (agentInfo.parentAgentId) {
|
|
247
|
+
metadataEvents.push({
|
|
248
|
+
name: "parent_agent",
|
|
249
|
+
cat: "__metadata",
|
|
250
|
+
ph: "M",
|
|
251
|
+
ts: 0,
|
|
252
|
+
pid: agentInfo.processId,
|
|
253
|
+
tid: 0,
|
|
254
|
+
args: {
|
|
255
|
+
parent_agent_id: agentInfo.parentAgentId
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function isPerfettoTracingEnabled() {
|
|
261
|
+
return isEnabled;
|
|
262
|
+
}
|
|
263
|
+
function registerAgent(agentId, agentName, parentAgentId) {
|
|
264
|
+
if (!isEnabled)
|
|
265
|
+
return;
|
|
266
|
+
const info = {
|
|
267
|
+
agentId,
|
|
268
|
+
agentName,
|
|
269
|
+
parentAgentId,
|
|
270
|
+
processId: getProcessIdForAgent(agentId),
|
|
271
|
+
threadId: stringToNumericHash(agentName)
|
|
272
|
+
};
|
|
273
|
+
agentRegistry.set(agentId, info);
|
|
274
|
+
totalAgentCount++;
|
|
275
|
+
emitProcessMetadata(info);
|
|
276
|
+
}
|
|
277
|
+
function unregisterAgent(agentId) {
|
|
278
|
+
if (!isEnabled)
|
|
279
|
+
return;
|
|
280
|
+
agentRegistry.delete(agentId);
|
|
281
|
+
agentIdToProcessId.delete(agentId);
|
|
282
|
+
}
|
|
283
|
+
function startLLMRequestPerfettoSpan(args) {
|
|
284
|
+
if (!isEnabled)
|
|
285
|
+
return "";
|
|
286
|
+
const spanId = generateSpanId();
|
|
287
|
+
const agentInfo = getCurrentAgentInfo();
|
|
288
|
+
pendingSpans.set(spanId, {
|
|
289
|
+
name: "API Call",
|
|
290
|
+
category: "api",
|
|
291
|
+
startTime: getTimestamp(),
|
|
292
|
+
agentInfo,
|
|
293
|
+
args: {
|
|
294
|
+
model: args.model,
|
|
295
|
+
prompt_tokens: args.promptTokens,
|
|
296
|
+
message_id: args.messageId,
|
|
297
|
+
is_speculative: args.isSpeculative ?? false,
|
|
298
|
+
query_source: args.querySource
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
events.push({
|
|
302
|
+
name: "API Call",
|
|
303
|
+
cat: "api",
|
|
304
|
+
ph: "B",
|
|
305
|
+
ts: pendingSpans.get(spanId).startTime,
|
|
306
|
+
pid: agentInfo.processId,
|
|
307
|
+
tid: agentInfo.threadId,
|
|
308
|
+
args: pendingSpans.get(spanId).args
|
|
309
|
+
});
|
|
310
|
+
return spanId;
|
|
311
|
+
}
|
|
312
|
+
function endLLMRequestPerfettoSpan(spanId, metadata) {
|
|
313
|
+
if (!isEnabled || !spanId)
|
|
314
|
+
return;
|
|
315
|
+
const pending = pendingSpans.get(spanId);
|
|
316
|
+
if (!pending)
|
|
317
|
+
return;
|
|
318
|
+
const endTime = getTimestamp();
|
|
319
|
+
const duration = endTime - pending.startTime;
|
|
320
|
+
const promptTokens = metadata.promptTokens ?? pending.args.prompt_tokens;
|
|
321
|
+
const ttftMs = metadata.ttftMs;
|
|
322
|
+
const ttltMs = metadata.ttltMs;
|
|
323
|
+
const outputTokens = metadata.outputTokens;
|
|
324
|
+
const cacheReadTokens = metadata.cacheReadTokens;
|
|
325
|
+
const itps = ttftMs !== undefined && promptTokens !== undefined && ttftMs > 0 ? Math.round(promptTokens / (ttftMs / 1000) * 100) / 100 : undefined;
|
|
326
|
+
const samplingMs = ttltMs !== undefined && ttftMs !== undefined ? ttltMs - ttftMs : undefined;
|
|
327
|
+
const otps = samplingMs !== undefined && outputTokens !== undefined && samplingMs > 0 ? Math.round(outputTokens / (samplingMs / 1000) * 100) / 100 : undefined;
|
|
328
|
+
const cacheHitRate = cacheReadTokens !== undefined && promptTokens !== undefined && promptTokens > 0 ? Math.round(cacheReadTokens / promptTokens * 1e4) / 100 : undefined;
|
|
329
|
+
const requestSetupMs = metadata.requestSetupMs;
|
|
330
|
+
const attemptStartTimes = metadata.attemptStartTimes;
|
|
331
|
+
const args = {
|
|
332
|
+
...pending.args,
|
|
333
|
+
ttft_ms: ttftMs,
|
|
334
|
+
ttlt_ms: ttltMs,
|
|
335
|
+
prompt_tokens: promptTokens,
|
|
336
|
+
output_tokens: outputTokens,
|
|
337
|
+
cache_read_tokens: cacheReadTokens,
|
|
338
|
+
cache_creation_tokens: metadata.cacheCreationTokens,
|
|
339
|
+
message_id: metadata.messageId ?? pending.args.message_id,
|
|
340
|
+
success: metadata.success ?? true,
|
|
341
|
+
error: metadata.error,
|
|
342
|
+
duration_ms: duration / 1000,
|
|
343
|
+
request_setup_ms: requestSetupMs,
|
|
344
|
+
itps,
|
|
345
|
+
otps,
|
|
346
|
+
cache_hit_rate_pct: cacheHitRate
|
|
347
|
+
};
|
|
348
|
+
const setupUs = requestSetupMs !== undefined && requestSetupMs > 0 ? requestSetupMs * 1000 : 0;
|
|
349
|
+
if (setupUs > 0) {
|
|
350
|
+
const setupEndTs = pending.startTime + setupUs;
|
|
351
|
+
events.push({
|
|
352
|
+
name: "Request Setup",
|
|
353
|
+
cat: "api,setup",
|
|
354
|
+
ph: "B",
|
|
355
|
+
ts: pending.startTime,
|
|
356
|
+
pid: pending.agentInfo.processId,
|
|
357
|
+
tid: pending.agentInfo.threadId,
|
|
358
|
+
args: {
|
|
359
|
+
request_setup_ms: requestSetupMs,
|
|
360
|
+
attempt_count: attemptStartTimes?.length ?? 1
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
if (attemptStartTimes && attemptStartTimes.length > 1) {
|
|
364
|
+
const baseWallMs = attemptStartTimes[0];
|
|
365
|
+
for (let i = 0;i < attemptStartTimes.length - 1; i++) {
|
|
366
|
+
const attemptStartUs = pending.startTime + (attemptStartTimes[i] - baseWallMs) * 1000;
|
|
367
|
+
const attemptEndUs = pending.startTime + (attemptStartTimes[i + 1] - baseWallMs) * 1000;
|
|
368
|
+
events.push({
|
|
369
|
+
name: `Attempt ${i + 1} (retry)`,
|
|
370
|
+
cat: "api,retry",
|
|
371
|
+
ph: "B",
|
|
372
|
+
ts: attemptStartUs,
|
|
373
|
+
pid: pending.agentInfo.processId,
|
|
374
|
+
tid: pending.agentInfo.threadId,
|
|
375
|
+
args: { attempt: i + 1 }
|
|
376
|
+
});
|
|
377
|
+
events.push({
|
|
378
|
+
name: `Attempt ${i + 1} (retry)`,
|
|
379
|
+
cat: "api,retry",
|
|
380
|
+
ph: "E",
|
|
381
|
+
ts: attemptEndUs,
|
|
382
|
+
pid: pending.agentInfo.processId,
|
|
383
|
+
tid: pending.agentInfo.threadId
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
events.push({
|
|
388
|
+
name: "Request Setup",
|
|
389
|
+
cat: "api,setup",
|
|
390
|
+
ph: "E",
|
|
391
|
+
ts: setupEndTs,
|
|
392
|
+
pid: pending.agentInfo.processId,
|
|
393
|
+
tid: pending.agentInfo.threadId
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
if (ttftMs !== undefined) {
|
|
397
|
+
const firstTokenStartTs = pending.startTime + setupUs;
|
|
398
|
+
const firstTokenEndTs = firstTokenStartTs + ttftMs * 1000;
|
|
399
|
+
events.push({
|
|
400
|
+
name: "First Token",
|
|
401
|
+
cat: "api,ttft",
|
|
402
|
+
ph: "B",
|
|
403
|
+
ts: firstTokenStartTs,
|
|
404
|
+
pid: pending.agentInfo.processId,
|
|
405
|
+
tid: pending.agentInfo.threadId,
|
|
406
|
+
args: {
|
|
407
|
+
ttft_ms: ttftMs,
|
|
408
|
+
prompt_tokens: promptTokens,
|
|
409
|
+
itps,
|
|
410
|
+
cache_hit_rate_pct: cacheHitRate
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
events.push({
|
|
414
|
+
name: "First Token",
|
|
415
|
+
cat: "api,ttft",
|
|
416
|
+
ph: "E",
|
|
417
|
+
ts: firstTokenEndTs,
|
|
418
|
+
pid: pending.agentInfo.processId,
|
|
419
|
+
tid: pending.agentInfo.threadId
|
|
420
|
+
});
|
|
421
|
+
const actualSamplingMs = ttltMs !== undefined ? ttltMs - ttftMs - setupUs / 1000 : undefined;
|
|
422
|
+
if (actualSamplingMs !== undefined && actualSamplingMs > 0) {
|
|
423
|
+
events.push({
|
|
424
|
+
name: "Sampling",
|
|
425
|
+
cat: "api,sampling",
|
|
426
|
+
ph: "B",
|
|
427
|
+
ts: firstTokenEndTs,
|
|
428
|
+
pid: pending.agentInfo.processId,
|
|
429
|
+
tid: pending.agentInfo.threadId,
|
|
430
|
+
args: {
|
|
431
|
+
sampling_ms: actualSamplingMs,
|
|
432
|
+
output_tokens: outputTokens,
|
|
433
|
+
otps
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
events.push({
|
|
437
|
+
name: "Sampling",
|
|
438
|
+
cat: "api,sampling",
|
|
439
|
+
ph: "E",
|
|
440
|
+
ts: firstTokenEndTs + actualSamplingMs * 1000,
|
|
441
|
+
pid: pending.agentInfo.processId,
|
|
442
|
+
tid: pending.agentInfo.threadId
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
events.push({
|
|
447
|
+
name: pending.name,
|
|
448
|
+
cat: pending.category,
|
|
449
|
+
ph: "E",
|
|
450
|
+
ts: endTime,
|
|
451
|
+
pid: pending.agentInfo.processId,
|
|
452
|
+
tid: pending.agentInfo.threadId,
|
|
453
|
+
args
|
|
454
|
+
});
|
|
455
|
+
pendingSpans.delete(spanId);
|
|
456
|
+
}
|
|
457
|
+
function startToolPerfettoSpan(toolName, args) {
|
|
458
|
+
if (!isEnabled)
|
|
459
|
+
return "";
|
|
460
|
+
const spanId = generateSpanId();
|
|
461
|
+
const agentInfo = getCurrentAgentInfo();
|
|
462
|
+
pendingSpans.set(spanId, {
|
|
463
|
+
name: `Tool: ${toolName}`,
|
|
464
|
+
category: "tool",
|
|
465
|
+
startTime: getTimestamp(),
|
|
466
|
+
agentInfo,
|
|
467
|
+
args: {
|
|
468
|
+
tool_name: toolName,
|
|
469
|
+
...args
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
events.push({
|
|
473
|
+
name: `Tool: ${toolName}`,
|
|
474
|
+
cat: "tool",
|
|
475
|
+
ph: "B",
|
|
476
|
+
ts: pendingSpans.get(spanId).startTime,
|
|
477
|
+
pid: agentInfo.processId,
|
|
478
|
+
tid: agentInfo.threadId,
|
|
479
|
+
args: pendingSpans.get(spanId).args
|
|
480
|
+
});
|
|
481
|
+
return spanId;
|
|
482
|
+
}
|
|
483
|
+
function endToolPerfettoSpan(spanId, metadata) {
|
|
484
|
+
if (!isEnabled || !spanId)
|
|
485
|
+
return;
|
|
486
|
+
const pending = pendingSpans.get(spanId);
|
|
487
|
+
if (!pending)
|
|
488
|
+
return;
|
|
489
|
+
const endTime = getTimestamp();
|
|
490
|
+
const duration = endTime - pending.startTime;
|
|
491
|
+
const args = {
|
|
492
|
+
...pending.args,
|
|
493
|
+
success: metadata?.success ?? true,
|
|
494
|
+
error: metadata?.error,
|
|
495
|
+
result_tokens: metadata?.resultTokens,
|
|
496
|
+
duration_ms: duration / 1000
|
|
497
|
+
};
|
|
498
|
+
events.push({
|
|
499
|
+
name: pending.name,
|
|
500
|
+
cat: pending.category,
|
|
501
|
+
ph: "E",
|
|
502
|
+
ts: endTime,
|
|
503
|
+
pid: pending.agentInfo.processId,
|
|
504
|
+
tid: pending.agentInfo.threadId,
|
|
505
|
+
args
|
|
506
|
+
});
|
|
507
|
+
pendingSpans.delete(spanId);
|
|
508
|
+
}
|
|
509
|
+
function startUserInputPerfettoSpan(context) {
|
|
510
|
+
if (!isEnabled)
|
|
511
|
+
return "";
|
|
512
|
+
const spanId = generateSpanId();
|
|
513
|
+
const agentInfo = getCurrentAgentInfo();
|
|
514
|
+
pendingSpans.set(spanId, {
|
|
515
|
+
name: "Waiting for User Input",
|
|
516
|
+
category: "user_input",
|
|
517
|
+
startTime: getTimestamp(),
|
|
518
|
+
agentInfo,
|
|
519
|
+
args: {
|
|
520
|
+
context
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
events.push({
|
|
524
|
+
name: "Waiting for User Input",
|
|
525
|
+
cat: "user_input",
|
|
526
|
+
ph: "B",
|
|
527
|
+
ts: pendingSpans.get(spanId).startTime,
|
|
528
|
+
pid: agentInfo.processId,
|
|
529
|
+
tid: agentInfo.threadId,
|
|
530
|
+
args: pendingSpans.get(spanId).args
|
|
531
|
+
});
|
|
532
|
+
return spanId;
|
|
533
|
+
}
|
|
534
|
+
function endUserInputPerfettoSpan(spanId, metadata) {
|
|
535
|
+
if (!isEnabled || !spanId)
|
|
536
|
+
return;
|
|
537
|
+
const pending = pendingSpans.get(spanId);
|
|
538
|
+
if (!pending)
|
|
539
|
+
return;
|
|
540
|
+
const endTime = getTimestamp();
|
|
541
|
+
const duration = endTime - pending.startTime;
|
|
542
|
+
const args = {
|
|
543
|
+
...pending.args,
|
|
544
|
+
decision: metadata?.decision,
|
|
545
|
+
source: metadata?.source,
|
|
546
|
+
duration_ms: duration / 1000
|
|
547
|
+
};
|
|
548
|
+
events.push({
|
|
549
|
+
name: pending.name,
|
|
550
|
+
cat: pending.category,
|
|
551
|
+
ph: "E",
|
|
552
|
+
ts: endTime,
|
|
553
|
+
pid: pending.agentInfo.processId,
|
|
554
|
+
tid: pending.agentInfo.threadId,
|
|
555
|
+
args
|
|
556
|
+
});
|
|
557
|
+
pendingSpans.delete(spanId);
|
|
558
|
+
}
|
|
559
|
+
function startInteractionPerfettoSpan(userPrompt) {
|
|
560
|
+
if (!isEnabled)
|
|
561
|
+
return "";
|
|
562
|
+
const spanId = generateSpanId();
|
|
563
|
+
const agentInfo = getCurrentAgentInfo();
|
|
564
|
+
pendingSpans.set(spanId, {
|
|
565
|
+
name: "Interaction",
|
|
566
|
+
category: "interaction",
|
|
567
|
+
startTime: getTimestamp(),
|
|
568
|
+
agentInfo,
|
|
569
|
+
args: {
|
|
570
|
+
user_prompt_length: userPrompt?.length
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
events.push({
|
|
574
|
+
name: "Interaction",
|
|
575
|
+
cat: "interaction",
|
|
576
|
+
ph: "B",
|
|
577
|
+
ts: pendingSpans.get(spanId).startTime,
|
|
578
|
+
pid: agentInfo.processId,
|
|
579
|
+
tid: agentInfo.threadId,
|
|
580
|
+
args: pendingSpans.get(spanId).args
|
|
581
|
+
});
|
|
582
|
+
return spanId;
|
|
583
|
+
}
|
|
584
|
+
function endInteractionPerfettoSpan(spanId) {
|
|
585
|
+
if (!isEnabled || !spanId)
|
|
586
|
+
return;
|
|
587
|
+
const pending = pendingSpans.get(spanId);
|
|
588
|
+
if (!pending)
|
|
589
|
+
return;
|
|
590
|
+
const endTime = getTimestamp();
|
|
591
|
+
const duration = endTime - pending.startTime;
|
|
592
|
+
events.push({
|
|
593
|
+
name: pending.name,
|
|
594
|
+
cat: pending.category,
|
|
595
|
+
ph: "E",
|
|
596
|
+
ts: endTime,
|
|
597
|
+
pid: pending.agentInfo.processId,
|
|
598
|
+
tid: pending.agentInfo.threadId,
|
|
599
|
+
args: {
|
|
600
|
+
...pending.args,
|
|
601
|
+
duration_ms: duration / 1000
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
pendingSpans.delete(spanId);
|
|
605
|
+
}
|
|
606
|
+
var isEnabled = false, metadataEvents, events, pendingSpans, agentRegistry, totalAgentCount = 0, startTimeMs = 0, spanIdCounter = 0, processIdCounter = 1, agentIdToProcessId, STALE_SPAN_TTL_MS, STALE_SPAN_CLEANUP_INTERVAL_MS;
|
|
607
|
+
var init_perfettoTracing = __esm(() => {
|
|
608
|
+
init_state();
|
|
609
|
+
init_cleanupRegistry();
|
|
610
|
+
init_debug();
|
|
611
|
+
init_envUtils();
|
|
612
|
+
init_errors();
|
|
613
|
+
init_hash();
|
|
614
|
+
init_slowOperations();
|
|
615
|
+
init_teammate();
|
|
616
|
+
metadataEvents = [];
|
|
617
|
+
events = [];
|
|
618
|
+
pendingSpans = new Map;
|
|
619
|
+
agentRegistry = new Map;
|
|
620
|
+
agentIdToProcessId = new Map;
|
|
621
|
+
STALE_SPAN_TTL_MS = 30 * 60 * 1000;
|
|
622
|
+
STALE_SPAN_CLEANUP_INTERVAL_MS = 60 * 1000;
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
// src/utils/telemetry/betaSessionTracing.ts
|
|
626
|
+
import { createHash } from "crypto";
|
|
627
|
+
function clearBetaTracingState() {
|
|
628
|
+
seenHashes.clear();
|
|
629
|
+
lastReportedMessageHash.clear();
|
|
630
|
+
}
|
|
631
|
+
function isBetaTracingEnabled() {
|
|
632
|
+
const baseEnabled = isEnvTruthy(process.env.ENABLE_BETA_TRACING_DETAILED) && Boolean(process.env.BETA_TRACING_ENDPOINT);
|
|
633
|
+
if (!baseEnabled) {
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
636
|
+
if (process.env.USER_TYPE !== "ant") {
|
|
637
|
+
return getIsNonInteractiveSession() || getFeatureValue_CACHED_MAY_BE_STALE("tengu_trace_lantern", false);
|
|
638
|
+
}
|
|
639
|
+
return true;
|
|
640
|
+
}
|
|
641
|
+
function truncateContent(content, maxSize = MAX_CONTENT_SIZE) {
|
|
642
|
+
if (content.length <= maxSize) {
|
|
643
|
+
return { content, truncated: false };
|
|
644
|
+
}
|
|
645
|
+
return {
|
|
646
|
+
content: content.slice(0, maxSize) + `
|
|
647
|
+
|
|
648
|
+
[TRUNCATED - Content exceeds 60KB limit]`,
|
|
649
|
+
truncated: true
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
function shortHash(content) {
|
|
653
|
+
return createHash("sha256").update(content).digest("hex").slice(0, 12);
|
|
654
|
+
}
|
|
655
|
+
function hashSystemPrompt(systemPrompt) {
|
|
656
|
+
return `sp_${shortHash(systemPrompt)}`;
|
|
657
|
+
}
|
|
658
|
+
function hashMessage(message) {
|
|
659
|
+
const content = jsonStringify(message.message.content);
|
|
660
|
+
return `msg_${shortHash(content)}`;
|
|
661
|
+
}
|
|
662
|
+
function extractSystemReminderContent(text) {
|
|
663
|
+
const match = text.trim().match(SYSTEM_REMINDER_REGEX);
|
|
664
|
+
return match && match[1] ? match[1].trim() : null;
|
|
665
|
+
}
|
|
666
|
+
function formatMessagesForContext(messages) {
|
|
667
|
+
const contextParts = [];
|
|
668
|
+
const systemReminders = [];
|
|
669
|
+
for (const message of messages) {
|
|
670
|
+
const content = message.message.content;
|
|
671
|
+
if (typeof content === "string") {
|
|
672
|
+
const reminderContent = extractSystemReminderContent(content);
|
|
673
|
+
if (reminderContent) {
|
|
674
|
+
systemReminders.push(reminderContent);
|
|
675
|
+
} else {
|
|
676
|
+
contextParts.push(`[USER]
|
|
677
|
+
${content}`);
|
|
678
|
+
}
|
|
679
|
+
} else if (Array.isArray(content)) {
|
|
680
|
+
for (const block of content) {
|
|
681
|
+
if (block.type === "text") {
|
|
682
|
+
const reminderContent = extractSystemReminderContent(block.text);
|
|
683
|
+
if (reminderContent) {
|
|
684
|
+
systemReminders.push(reminderContent);
|
|
685
|
+
} else {
|
|
686
|
+
contextParts.push(`[USER]
|
|
687
|
+
${block.text}`);
|
|
688
|
+
}
|
|
689
|
+
} else if (block.type === "tool_result") {
|
|
690
|
+
const resultContent = typeof block.content === "string" ? block.content : jsonStringify(block.content);
|
|
691
|
+
const reminderContent = extractSystemReminderContent(resultContent);
|
|
692
|
+
if (reminderContent) {
|
|
693
|
+
systemReminders.push(reminderContent);
|
|
694
|
+
} else {
|
|
695
|
+
contextParts.push(`[TOOL RESULT: ${block.tool_use_id}]
|
|
696
|
+
${resultContent}`);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
return { contextParts, systemReminders };
|
|
703
|
+
}
|
|
704
|
+
function addBetaInteractionAttributes(span, userPrompt) {
|
|
705
|
+
if (!isBetaTracingEnabled()) {
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
const { content: truncatedPrompt, truncated } = truncateContent(`[USER PROMPT]
|
|
709
|
+
${userPrompt}`);
|
|
710
|
+
span.setAttributes({
|
|
711
|
+
new_context: truncatedPrompt,
|
|
712
|
+
...truncated && {
|
|
713
|
+
new_context_truncated: true,
|
|
714
|
+
new_context_original_length: userPrompt.length
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
function addBetaLLMRequestAttributes(span, newContext, messagesForAPI) {
|
|
719
|
+
if (!isBetaTracingEnabled()) {
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
if (newContext?.systemPrompt) {
|
|
723
|
+
const promptHash = hashSystemPrompt(newContext.systemPrompt);
|
|
724
|
+
const preview = newContext.systemPrompt.slice(0, 500);
|
|
725
|
+
span.setAttribute("system_prompt_hash", promptHash);
|
|
726
|
+
span.setAttribute("system_prompt_preview", preview);
|
|
727
|
+
span.setAttribute("system_prompt_length", newContext.systemPrompt.length);
|
|
728
|
+
if (!seenHashes.has(promptHash)) {
|
|
729
|
+
seenHashes.add(promptHash);
|
|
730
|
+
const { content: truncatedPrompt, truncated } = truncateContent(newContext.systemPrompt);
|
|
731
|
+
logOTelEvent("system_prompt", {
|
|
732
|
+
system_prompt_hash: promptHash,
|
|
733
|
+
system_prompt: truncatedPrompt,
|
|
734
|
+
system_prompt_length: String(newContext.systemPrompt.length),
|
|
735
|
+
...truncated && { system_prompt_truncated: "true" }
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
if (newContext?.tools) {
|
|
740
|
+
try {
|
|
741
|
+
const toolsArray = jsonParse(newContext.tools);
|
|
742
|
+
const toolsWithHashes = toolsArray.map((tool) => {
|
|
743
|
+
const toolJson = jsonStringify(tool);
|
|
744
|
+
const toolHash = shortHash(toolJson);
|
|
745
|
+
return {
|
|
746
|
+
name: typeof tool.name === "string" ? tool.name : "unknown",
|
|
747
|
+
hash: toolHash,
|
|
748
|
+
json: toolJson
|
|
749
|
+
};
|
|
750
|
+
});
|
|
751
|
+
span.setAttribute("tools", jsonStringify(toolsWithHashes.map(({ name, hash }) => ({ name, hash }))));
|
|
752
|
+
span.setAttribute("tools_count", toolsWithHashes.length);
|
|
753
|
+
for (const { name, hash, json } of toolsWithHashes) {
|
|
754
|
+
if (!seenHashes.has(`tool_${hash}`)) {
|
|
755
|
+
seenHashes.add(`tool_${hash}`);
|
|
756
|
+
const { content: truncatedTool, truncated } = truncateContent(json);
|
|
757
|
+
logOTelEvent("tool", {
|
|
758
|
+
tool_name: sanitizeToolNameForAnalytics(name),
|
|
759
|
+
tool_hash: hash,
|
|
760
|
+
tool: truncatedTool,
|
|
761
|
+
...truncated && { tool_truncated: "true" }
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
} catch {
|
|
766
|
+
span.setAttribute("tools_parse_error", true);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
if (messagesForAPI && messagesForAPI.length > 0 && newContext?.querySource) {
|
|
770
|
+
const querySource = newContext.querySource;
|
|
771
|
+
const lastHash = lastReportedMessageHash.get(querySource);
|
|
772
|
+
let startIndex = 0;
|
|
773
|
+
if (lastHash) {
|
|
774
|
+
for (let i = 0;i < messagesForAPI.length; i++) {
|
|
775
|
+
const msg = messagesForAPI[i];
|
|
776
|
+
if (msg && hashMessage(msg) === lastHash) {
|
|
777
|
+
startIndex = i + 1;
|
|
778
|
+
break;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
const newMessages = messagesForAPI.slice(startIndex).filter((m) => m.type === "user");
|
|
783
|
+
if (newMessages.length > 0) {
|
|
784
|
+
const { contextParts, systemReminders } = formatMessagesForContext(newMessages);
|
|
785
|
+
if (contextParts.length > 0) {
|
|
786
|
+
const fullContext = contextParts.join(`
|
|
787
|
+
|
|
788
|
+
---
|
|
789
|
+
|
|
790
|
+
`);
|
|
791
|
+
const { content: truncatedContext, truncated } = truncateContent(fullContext);
|
|
792
|
+
span.setAttributes({
|
|
793
|
+
new_context: truncatedContext,
|
|
794
|
+
new_context_message_count: newMessages.length,
|
|
795
|
+
...truncated && {
|
|
796
|
+
new_context_truncated: true,
|
|
797
|
+
new_context_original_length: fullContext.length
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
if (systemReminders.length > 0) {
|
|
802
|
+
const fullReminders = systemReminders.join(`
|
|
803
|
+
|
|
804
|
+
---
|
|
805
|
+
|
|
806
|
+
`);
|
|
807
|
+
const { content: truncatedReminders, truncated: remindersTruncated } = truncateContent(fullReminders);
|
|
808
|
+
span.setAttributes({
|
|
809
|
+
system_reminders: truncatedReminders,
|
|
810
|
+
system_reminders_count: systemReminders.length,
|
|
811
|
+
...remindersTruncated && {
|
|
812
|
+
system_reminders_truncated: true,
|
|
813
|
+
system_reminders_original_length: fullReminders.length
|
|
814
|
+
}
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
const lastMessage = messagesForAPI[messagesForAPI.length - 1];
|
|
818
|
+
if (lastMessage) {
|
|
819
|
+
lastReportedMessageHash.set(querySource, hashMessage(lastMessage));
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
function addBetaLLMResponseAttributes(endAttributes, metadata) {
|
|
825
|
+
if (!isBetaTracingEnabled() || !metadata) {
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
if (metadata.modelOutput !== undefined) {
|
|
829
|
+
const { content: modelOutput, truncated: outputTruncated } = truncateContent(metadata.modelOutput);
|
|
830
|
+
endAttributes["response.model_output"] = modelOutput;
|
|
831
|
+
if (outputTruncated) {
|
|
832
|
+
endAttributes["response.model_output_truncated"] = true;
|
|
833
|
+
endAttributes["response.model_output_original_length"] = metadata.modelOutput.length;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
if (process.env.USER_TYPE === "ant" && metadata.thinkingOutput !== undefined) {
|
|
837
|
+
const { content: thinkingOutput, truncated: thinkingTruncated } = truncateContent(metadata.thinkingOutput);
|
|
838
|
+
endAttributes["response.thinking_output"] = thinkingOutput;
|
|
839
|
+
if (thinkingTruncated) {
|
|
840
|
+
endAttributes["response.thinking_output_truncated"] = true;
|
|
841
|
+
endAttributes["response.thinking_output_original_length"] = metadata.thinkingOutput.length;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
function addBetaToolInputAttributes(span, toolName, toolInput) {
|
|
846
|
+
if (!isBetaTracingEnabled()) {
|
|
847
|
+
return;
|
|
848
|
+
}
|
|
849
|
+
const { content: truncatedInput, truncated } = truncateContent(`[TOOL INPUT: ${toolName}]
|
|
850
|
+
${toolInput}`);
|
|
851
|
+
span.setAttributes({
|
|
852
|
+
tool_input: truncatedInput,
|
|
853
|
+
...truncated && {
|
|
854
|
+
tool_input_truncated: true,
|
|
855
|
+
tool_input_original_length: toolInput.length
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
function addBetaToolResultAttributes(endAttributes, toolName, toolResult) {
|
|
860
|
+
if (!isBetaTracingEnabled()) {
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
const { content: truncatedResult, truncated } = truncateContent(`[TOOL RESULT: ${toolName}]
|
|
864
|
+
${toolResult}`);
|
|
865
|
+
endAttributes["new_context"] = truncatedResult;
|
|
866
|
+
if (truncated) {
|
|
867
|
+
endAttributes["new_context_truncated"] = true;
|
|
868
|
+
endAttributes["new_context_original_length"] = toolResult.length;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
var seenHashes, lastReportedMessageHash, MAX_CONTENT_SIZE, SYSTEM_REMINDER_REGEX;
|
|
872
|
+
var init_betaSessionTracing = __esm(() => {
|
|
873
|
+
init_state();
|
|
874
|
+
init_growthbook();
|
|
875
|
+
init_metadata();
|
|
876
|
+
init_envUtils();
|
|
877
|
+
init_slowOperations();
|
|
878
|
+
init_events();
|
|
879
|
+
seenHashes = new Set;
|
|
880
|
+
lastReportedMessageHash = new Map;
|
|
881
|
+
MAX_CONTENT_SIZE = 60 * 1024;
|
|
882
|
+
SYSTEM_REMINDER_REGEX = /^<system-reminder>\n?([\s\S]*?)\n?<\/system-reminder>$/;
|
|
883
|
+
});
|
|
884
|
+
|
|
885
|
+
// src/utils/telemetry/sessionTracing.ts
|
|
886
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
887
|
+
function getSpanId(span) {
|
|
888
|
+
return span.spanContext().spanId || "";
|
|
889
|
+
}
|
|
890
|
+
function ensureCleanupInterval() {
|
|
891
|
+
if (_cleanupIntervalStarted)
|
|
892
|
+
return;
|
|
893
|
+
_cleanupIntervalStarted = true;
|
|
894
|
+
const interval = setInterval(() => {
|
|
895
|
+
const cutoff = Date.now() - SPAN_TTL_MS;
|
|
896
|
+
for (const [spanId, weakRef] of activeSpans) {
|
|
897
|
+
const ctx = weakRef.deref();
|
|
898
|
+
if (ctx === undefined) {
|
|
899
|
+
activeSpans.delete(spanId);
|
|
900
|
+
strongSpans.delete(spanId);
|
|
901
|
+
} else if (ctx.startTime < cutoff) {
|
|
902
|
+
if (!ctx.ended)
|
|
903
|
+
ctx.span.end();
|
|
904
|
+
activeSpans.delete(spanId);
|
|
905
|
+
strongSpans.delete(spanId);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}, 60000);
|
|
909
|
+
if (typeof interval.unref === "function") {
|
|
910
|
+
interval.unref();
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
function isEnhancedTelemetryEnabled() {
|
|
914
|
+
if (false) {}
|
|
915
|
+
return false;
|
|
916
|
+
}
|
|
917
|
+
function isAnyTracingEnabled() {
|
|
918
|
+
return isEnhancedTelemetryEnabled() || isBetaTracingEnabled();
|
|
919
|
+
}
|
|
920
|
+
function getTracer() {
|
|
921
|
+
return import_api.trace.getTracer("com.anthropic.claude_code.tracing", "1.0.0");
|
|
922
|
+
}
|
|
923
|
+
function createSpanAttributes(spanType, customAttributes = {}) {
|
|
924
|
+
const baseAttributes = getTelemetryAttributes();
|
|
925
|
+
const attributes = {
|
|
926
|
+
...baseAttributes,
|
|
927
|
+
"span.type": spanType,
|
|
928
|
+
...customAttributes
|
|
929
|
+
};
|
|
930
|
+
return attributes;
|
|
931
|
+
}
|
|
932
|
+
function startInteractionSpan(userPrompt) {
|
|
933
|
+
ensureCleanupInterval();
|
|
934
|
+
const perfettoSpanId = isPerfettoTracingEnabled() ? startInteractionPerfettoSpan(userPrompt) : undefined;
|
|
935
|
+
if (!isAnyTracingEnabled()) {
|
|
936
|
+
if (perfettoSpanId) {
|
|
937
|
+
const dummySpan = import_api.trace.getActiveSpan() || getTracer().startSpan("dummy");
|
|
938
|
+
const spanId2 = getSpanId(dummySpan);
|
|
939
|
+
const spanContextObj2 = {
|
|
940
|
+
span: dummySpan,
|
|
941
|
+
startTime: Date.now(),
|
|
942
|
+
attributes: {},
|
|
943
|
+
perfettoSpanId
|
|
944
|
+
};
|
|
945
|
+
activeSpans.set(spanId2, new WeakRef(spanContextObj2));
|
|
946
|
+
interactionContext.enterWith(spanContextObj2);
|
|
947
|
+
return dummySpan;
|
|
948
|
+
}
|
|
949
|
+
return import_api.trace.getActiveSpan() || getTracer().startSpan("dummy");
|
|
950
|
+
}
|
|
951
|
+
const tracer = getTracer();
|
|
952
|
+
const isUserPromptLoggingEnabled2 = isEnvTruthy(process.env.OTEL_LOG_USER_PROMPTS);
|
|
953
|
+
const promptToLog = isUserPromptLoggingEnabled2 ? userPrompt : "<REDACTED>";
|
|
954
|
+
interactionSequence++;
|
|
955
|
+
const attributes = createSpanAttributes("interaction", {
|
|
956
|
+
user_prompt: promptToLog,
|
|
957
|
+
user_prompt_length: userPrompt.length,
|
|
958
|
+
"interaction.sequence": interactionSequence
|
|
959
|
+
});
|
|
960
|
+
const span = tracer.startSpan("claude_code.interaction", {
|
|
961
|
+
attributes
|
|
962
|
+
});
|
|
963
|
+
addBetaInteractionAttributes(span, userPrompt);
|
|
964
|
+
const spanId = getSpanId(span);
|
|
965
|
+
const spanContextObj = {
|
|
966
|
+
span,
|
|
967
|
+
startTime: Date.now(),
|
|
968
|
+
attributes,
|
|
969
|
+
perfettoSpanId
|
|
970
|
+
};
|
|
971
|
+
activeSpans.set(spanId, new WeakRef(spanContextObj));
|
|
972
|
+
interactionContext.enterWith(spanContextObj);
|
|
973
|
+
return span;
|
|
974
|
+
}
|
|
975
|
+
function endInteractionSpan() {
|
|
976
|
+
const spanContext = interactionContext.getStore();
|
|
977
|
+
if (!spanContext) {
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
if (spanContext.ended) {
|
|
981
|
+
return;
|
|
982
|
+
}
|
|
983
|
+
if (spanContext.perfettoSpanId) {
|
|
984
|
+
endInteractionPerfettoSpan(spanContext.perfettoSpanId);
|
|
985
|
+
}
|
|
986
|
+
if (!isAnyTracingEnabled()) {
|
|
987
|
+
spanContext.ended = true;
|
|
988
|
+
activeSpans.delete(getSpanId(spanContext.span));
|
|
989
|
+
interactionContext.enterWith(undefined);
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
const duration = Date.now() - spanContext.startTime;
|
|
993
|
+
spanContext.span.setAttributes({
|
|
994
|
+
"interaction.duration_ms": duration
|
|
995
|
+
});
|
|
996
|
+
spanContext.span.end();
|
|
997
|
+
spanContext.ended = true;
|
|
998
|
+
activeSpans.delete(getSpanId(spanContext.span));
|
|
999
|
+
interactionContext.enterWith(undefined);
|
|
1000
|
+
}
|
|
1001
|
+
function startLLMRequestSpan(model, newContext, messagesForAPI, fastMode) {
|
|
1002
|
+
const perfettoSpanId = isPerfettoTracingEnabled() ? startLLMRequestPerfettoSpan({
|
|
1003
|
+
model,
|
|
1004
|
+
querySource: newContext?.querySource,
|
|
1005
|
+
messageId: undefined
|
|
1006
|
+
}) : undefined;
|
|
1007
|
+
if (!isAnyTracingEnabled()) {
|
|
1008
|
+
if (perfettoSpanId) {
|
|
1009
|
+
const dummySpan = import_api.trace.getActiveSpan() || getTracer().startSpan("dummy");
|
|
1010
|
+
const spanId2 = getSpanId(dummySpan);
|
|
1011
|
+
const spanContextObj2 = {
|
|
1012
|
+
span: dummySpan,
|
|
1013
|
+
startTime: Date.now(),
|
|
1014
|
+
attributes: { model },
|
|
1015
|
+
perfettoSpanId
|
|
1016
|
+
};
|
|
1017
|
+
activeSpans.set(spanId2, new WeakRef(spanContextObj2));
|
|
1018
|
+
strongSpans.set(spanId2, spanContextObj2);
|
|
1019
|
+
return dummySpan;
|
|
1020
|
+
}
|
|
1021
|
+
return import_api.trace.getActiveSpan() || getTracer().startSpan("dummy");
|
|
1022
|
+
}
|
|
1023
|
+
const tracer = getTracer();
|
|
1024
|
+
const parentSpanCtx = interactionContext.getStore();
|
|
1025
|
+
const attributes = createSpanAttributes("llm_request", {
|
|
1026
|
+
model,
|
|
1027
|
+
"llm_request.context": parentSpanCtx ? "interaction" : "standalone",
|
|
1028
|
+
speed: fastMode ? "fast" : "normal"
|
|
1029
|
+
});
|
|
1030
|
+
const ctx = parentSpanCtx ? import_api.trace.setSpan(import_api.context.active(), parentSpanCtx.span) : import_api.context.active();
|
|
1031
|
+
const span = tracer.startSpan("claude_code.llm_request", { attributes }, ctx);
|
|
1032
|
+
if (newContext?.querySource) {
|
|
1033
|
+
span.setAttribute("query_source", newContext.querySource);
|
|
1034
|
+
}
|
|
1035
|
+
addBetaLLMRequestAttributes(span, newContext, messagesForAPI);
|
|
1036
|
+
const spanId = getSpanId(span);
|
|
1037
|
+
const spanContextObj = {
|
|
1038
|
+
span,
|
|
1039
|
+
startTime: Date.now(),
|
|
1040
|
+
attributes,
|
|
1041
|
+
perfettoSpanId
|
|
1042
|
+
};
|
|
1043
|
+
activeSpans.set(spanId, new WeakRef(spanContextObj));
|
|
1044
|
+
strongSpans.set(spanId, spanContextObj);
|
|
1045
|
+
return span;
|
|
1046
|
+
}
|
|
1047
|
+
function endLLMRequestSpan(span, metadata) {
|
|
1048
|
+
let llmSpanContext;
|
|
1049
|
+
if (span) {
|
|
1050
|
+
const spanId2 = getSpanId(span);
|
|
1051
|
+
llmSpanContext = activeSpans.get(spanId2)?.deref();
|
|
1052
|
+
} else {
|
|
1053
|
+
llmSpanContext = Array.from(activeSpans.values()).findLast((r) => {
|
|
1054
|
+
const ctx = r.deref();
|
|
1055
|
+
return ctx?.attributes["span.type"] === "llm_request" || ctx?.attributes["model"];
|
|
1056
|
+
})?.deref();
|
|
1057
|
+
}
|
|
1058
|
+
if (!llmSpanContext) {
|
|
1059
|
+
return;
|
|
1060
|
+
}
|
|
1061
|
+
const duration = Date.now() - llmSpanContext.startTime;
|
|
1062
|
+
if (llmSpanContext.perfettoSpanId) {
|
|
1063
|
+
endLLMRequestPerfettoSpan(llmSpanContext.perfettoSpanId, {
|
|
1064
|
+
ttftMs: metadata?.ttftMs,
|
|
1065
|
+
ttltMs: duration,
|
|
1066
|
+
promptTokens: metadata?.inputTokens,
|
|
1067
|
+
outputTokens: metadata?.outputTokens,
|
|
1068
|
+
cacheReadTokens: metadata?.cacheReadTokens,
|
|
1069
|
+
cacheCreationTokens: metadata?.cacheCreationTokens,
|
|
1070
|
+
success: metadata?.success,
|
|
1071
|
+
error: metadata?.error,
|
|
1072
|
+
requestSetupMs: metadata?.requestSetupMs,
|
|
1073
|
+
attemptStartTimes: metadata?.attemptStartTimes
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
if (!isAnyTracingEnabled()) {
|
|
1077
|
+
const spanId2 = getSpanId(llmSpanContext.span);
|
|
1078
|
+
activeSpans.delete(spanId2);
|
|
1079
|
+
strongSpans.delete(spanId2);
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
const endAttributes = {
|
|
1083
|
+
duration_ms: duration
|
|
1084
|
+
};
|
|
1085
|
+
if (metadata) {
|
|
1086
|
+
if (metadata.inputTokens !== undefined)
|
|
1087
|
+
endAttributes["input_tokens"] = metadata.inputTokens;
|
|
1088
|
+
if (metadata.outputTokens !== undefined)
|
|
1089
|
+
endAttributes["output_tokens"] = metadata.outputTokens;
|
|
1090
|
+
if (metadata.cacheReadTokens !== undefined)
|
|
1091
|
+
endAttributes["cache_read_tokens"] = metadata.cacheReadTokens;
|
|
1092
|
+
if (metadata.cacheCreationTokens !== undefined)
|
|
1093
|
+
endAttributes["cache_creation_tokens"] = metadata.cacheCreationTokens;
|
|
1094
|
+
if (metadata.success !== undefined)
|
|
1095
|
+
endAttributes["success"] = metadata.success;
|
|
1096
|
+
if (metadata.statusCode !== undefined)
|
|
1097
|
+
endAttributes["status_code"] = metadata.statusCode;
|
|
1098
|
+
if (metadata.error !== undefined)
|
|
1099
|
+
endAttributes["error"] = metadata.error;
|
|
1100
|
+
if (metadata.attempt !== undefined)
|
|
1101
|
+
endAttributes["attempt"] = metadata.attempt;
|
|
1102
|
+
if (metadata.hasToolCall !== undefined)
|
|
1103
|
+
endAttributes["response.has_tool_call"] = metadata.hasToolCall;
|
|
1104
|
+
if (metadata.ttftMs !== undefined)
|
|
1105
|
+
endAttributes["ttft_ms"] = metadata.ttftMs;
|
|
1106
|
+
addBetaLLMResponseAttributes(endAttributes, metadata);
|
|
1107
|
+
}
|
|
1108
|
+
llmSpanContext.span.setAttributes(endAttributes);
|
|
1109
|
+
llmSpanContext.span.end();
|
|
1110
|
+
const spanId = getSpanId(llmSpanContext.span);
|
|
1111
|
+
activeSpans.delete(spanId);
|
|
1112
|
+
strongSpans.delete(spanId);
|
|
1113
|
+
}
|
|
1114
|
+
function startToolSpan(toolName, toolAttributes, toolInput) {
|
|
1115
|
+
const perfettoSpanId = isPerfettoTracingEnabled() ? startToolPerfettoSpan(toolName, toolAttributes) : undefined;
|
|
1116
|
+
if (!isAnyTracingEnabled()) {
|
|
1117
|
+
if (perfettoSpanId) {
|
|
1118
|
+
const dummySpan = import_api.trace.getActiveSpan() || getTracer().startSpan("dummy");
|
|
1119
|
+
const spanId2 = getSpanId(dummySpan);
|
|
1120
|
+
const spanContextObj2 = {
|
|
1121
|
+
span: dummySpan,
|
|
1122
|
+
startTime: Date.now(),
|
|
1123
|
+
attributes: { "span.type": "tool", tool_name: toolName },
|
|
1124
|
+
perfettoSpanId
|
|
1125
|
+
};
|
|
1126
|
+
activeSpans.set(spanId2, new WeakRef(spanContextObj2));
|
|
1127
|
+
toolContext.enterWith(spanContextObj2);
|
|
1128
|
+
return dummySpan;
|
|
1129
|
+
}
|
|
1130
|
+
return import_api.trace.getActiveSpan() || getTracer().startSpan("dummy");
|
|
1131
|
+
}
|
|
1132
|
+
const tracer = getTracer();
|
|
1133
|
+
const parentSpanCtx = interactionContext.getStore();
|
|
1134
|
+
const attributes = createSpanAttributes("tool", {
|
|
1135
|
+
tool_name: toolName,
|
|
1136
|
+
...toolAttributes
|
|
1137
|
+
});
|
|
1138
|
+
const ctx = parentSpanCtx ? import_api.trace.setSpan(import_api.context.active(), parentSpanCtx.span) : import_api.context.active();
|
|
1139
|
+
const span = tracer.startSpan("claude_code.tool", { attributes }, ctx);
|
|
1140
|
+
if (toolInput) {
|
|
1141
|
+
addBetaToolInputAttributes(span, toolName, toolInput);
|
|
1142
|
+
}
|
|
1143
|
+
const spanId = getSpanId(span);
|
|
1144
|
+
const spanContextObj = {
|
|
1145
|
+
span,
|
|
1146
|
+
startTime: Date.now(),
|
|
1147
|
+
attributes,
|
|
1148
|
+
perfettoSpanId
|
|
1149
|
+
};
|
|
1150
|
+
activeSpans.set(spanId, new WeakRef(spanContextObj));
|
|
1151
|
+
toolContext.enterWith(spanContextObj);
|
|
1152
|
+
return span;
|
|
1153
|
+
}
|
|
1154
|
+
function startToolBlockedOnUserSpan() {
|
|
1155
|
+
const perfettoSpanId = isPerfettoTracingEnabled() ? startUserInputPerfettoSpan("tool_permission") : undefined;
|
|
1156
|
+
if (!isAnyTracingEnabled()) {
|
|
1157
|
+
if (perfettoSpanId) {
|
|
1158
|
+
const dummySpan = import_api.trace.getActiveSpan() || getTracer().startSpan("dummy");
|
|
1159
|
+
const spanId2 = getSpanId(dummySpan);
|
|
1160
|
+
const spanContextObj2 = {
|
|
1161
|
+
span: dummySpan,
|
|
1162
|
+
startTime: Date.now(),
|
|
1163
|
+
attributes: { "span.type": "tool.blocked_on_user" },
|
|
1164
|
+
perfettoSpanId
|
|
1165
|
+
};
|
|
1166
|
+
activeSpans.set(spanId2, new WeakRef(spanContextObj2));
|
|
1167
|
+
strongSpans.set(spanId2, spanContextObj2);
|
|
1168
|
+
return dummySpan;
|
|
1169
|
+
}
|
|
1170
|
+
return import_api.trace.getActiveSpan() || getTracer().startSpan("dummy");
|
|
1171
|
+
}
|
|
1172
|
+
const tracer = getTracer();
|
|
1173
|
+
const parentSpanCtx = toolContext.getStore();
|
|
1174
|
+
const attributes = createSpanAttributes("tool.blocked_on_user");
|
|
1175
|
+
const ctx = parentSpanCtx ? import_api.trace.setSpan(import_api.context.active(), parentSpanCtx.span) : import_api.context.active();
|
|
1176
|
+
const span = tracer.startSpan("claude_code.tool.blocked_on_user", { attributes }, ctx);
|
|
1177
|
+
const spanId = getSpanId(span);
|
|
1178
|
+
const spanContextObj = {
|
|
1179
|
+
span,
|
|
1180
|
+
startTime: Date.now(),
|
|
1181
|
+
attributes,
|
|
1182
|
+
perfettoSpanId
|
|
1183
|
+
};
|
|
1184
|
+
activeSpans.set(spanId, new WeakRef(spanContextObj));
|
|
1185
|
+
strongSpans.set(spanId, spanContextObj);
|
|
1186
|
+
return span;
|
|
1187
|
+
}
|
|
1188
|
+
function endToolBlockedOnUserSpan(decision, source) {
|
|
1189
|
+
const blockedSpanContext = Array.from(activeSpans.values()).findLast((r) => r.deref()?.attributes["span.type"] === "tool.blocked_on_user")?.deref();
|
|
1190
|
+
if (!blockedSpanContext) {
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1193
|
+
if (blockedSpanContext.perfettoSpanId) {
|
|
1194
|
+
endUserInputPerfettoSpan(blockedSpanContext.perfettoSpanId, {
|
|
1195
|
+
decision,
|
|
1196
|
+
source
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1199
|
+
if (!isAnyTracingEnabled()) {
|
|
1200
|
+
const spanId2 = getSpanId(blockedSpanContext.span);
|
|
1201
|
+
activeSpans.delete(spanId2);
|
|
1202
|
+
strongSpans.delete(spanId2);
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
const duration = Date.now() - blockedSpanContext.startTime;
|
|
1206
|
+
const attributes = {
|
|
1207
|
+
duration_ms: duration
|
|
1208
|
+
};
|
|
1209
|
+
if (decision) {
|
|
1210
|
+
attributes["decision"] = decision;
|
|
1211
|
+
}
|
|
1212
|
+
if (source) {
|
|
1213
|
+
attributes["source"] = source;
|
|
1214
|
+
}
|
|
1215
|
+
blockedSpanContext.span.setAttributes(attributes);
|
|
1216
|
+
blockedSpanContext.span.end();
|
|
1217
|
+
const spanId = getSpanId(blockedSpanContext.span);
|
|
1218
|
+
activeSpans.delete(spanId);
|
|
1219
|
+
strongSpans.delete(spanId);
|
|
1220
|
+
}
|
|
1221
|
+
function startToolExecutionSpan() {
|
|
1222
|
+
if (!isAnyTracingEnabled()) {
|
|
1223
|
+
return import_api.trace.getActiveSpan() || getTracer().startSpan("dummy");
|
|
1224
|
+
}
|
|
1225
|
+
const tracer = getTracer();
|
|
1226
|
+
const parentSpanCtx = toolContext.getStore();
|
|
1227
|
+
const attributes = createSpanAttributes("tool.execution");
|
|
1228
|
+
const ctx = parentSpanCtx ? import_api.trace.setSpan(import_api.context.active(), parentSpanCtx.span) : import_api.context.active();
|
|
1229
|
+
const span = tracer.startSpan("claude_code.tool.execution", { attributes }, ctx);
|
|
1230
|
+
const spanId = getSpanId(span);
|
|
1231
|
+
const spanContextObj = {
|
|
1232
|
+
span,
|
|
1233
|
+
startTime: Date.now(),
|
|
1234
|
+
attributes
|
|
1235
|
+
};
|
|
1236
|
+
activeSpans.set(spanId, new WeakRef(spanContextObj));
|
|
1237
|
+
strongSpans.set(spanId, spanContextObj);
|
|
1238
|
+
return span;
|
|
1239
|
+
}
|
|
1240
|
+
function endToolExecutionSpan(metadata) {
|
|
1241
|
+
if (!isAnyTracingEnabled()) {
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
1244
|
+
const executionSpanContext = Array.from(activeSpans.values()).findLast((r) => r.deref()?.attributes["span.type"] === "tool.execution")?.deref();
|
|
1245
|
+
if (!executionSpanContext) {
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1248
|
+
const duration = Date.now() - executionSpanContext.startTime;
|
|
1249
|
+
const attributes = {
|
|
1250
|
+
duration_ms: duration
|
|
1251
|
+
};
|
|
1252
|
+
if (metadata) {
|
|
1253
|
+
if (metadata.success !== undefined)
|
|
1254
|
+
attributes["success"] = metadata.success;
|
|
1255
|
+
if (metadata.error !== undefined)
|
|
1256
|
+
attributes["error"] = metadata.error;
|
|
1257
|
+
}
|
|
1258
|
+
executionSpanContext.span.setAttributes(attributes);
|
|
1259
|
+
executionSpanContext.span.end();
|
|
1260
|
+
const spanId = getSpanId(executionSpanContext.span);
|
|
1261
|
+
activeSpans.delete(spanId);
|
|
1262
|
+
strongSpans.delete(spanId);
|
|
1263
|
+
}
|
|
1264
|
+
function endToolSpan(toolResult, resultTokens) {
|
|
1265
|
+
const toolSpanContext = toolContext.getStore();
|
|
1266
|
+
if (!toolSpanContext) {
|
|
1267
|
+
return;
|
|
1268
|
+
}
|
|
1269
|
+
if (toolSpanContext.perfettoSpanId) {
|
|
1270
|
+
endToolPerfettoSpan(toolSpanContext.perfettoSpanId, {
|
|
1271
|
+
success: true,
|
|
1272
|
+
resultTokens
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
if (!isAnyTracingEnabled()) {
|
|
1276
|
+
const spanId2 = getSpanId(toolSpanContext.span);
|
|
1277
|
+
activeSpans.delete(spanId2);
|
|
1278
|
+
toolContext.enterWith(undefined);
|
|
1279
|
+
return;
|
|
1280
|
+
}
|
|
1281
|
+
const duration = Date.now() - toolSpanContext.startTime;
|
|
1282
|
+
const endAttributes = {
|
|
1283
|
+
duration_ms: duration
|
|
1284
|
+
};
|
|
1285
|
+
if (toolResult) {
|
|
1286
|
+
const toolName = toolSpanContext.attributes["tool_name"] || "unknown";
|
|
1287
|
+
addBetaToolResultAttributes(endAttributes, toolName, toolResult);
|
|
1288
|
+
}
|
|
1289
|
+
if (resultTokens !== undefined) {
|
|
1290
|
+
endAttributes["result_tokens"] = resultTokens;
|
|
1291
|
+
}
|
|
1292
|
+
toolSpanContext.span.setAttributes(endAttributes);
|
|
1293
|
+
toolSpanContext.span.end();
|
|
1294
|
+
const spanId = getSpanId(toolSpanContext.span);
|
|
1295
|
+
activeSpans.delete(spanId);
|
|
1296
|
+
toolContext.enterWith(undefined);
|
|
1297
|
+
}
|
|
1298
|
+
function isToolContentLoggingEnabled() {
|
|
1299
|
+
return isEnvTruthy(process.env.OTEL_LOG_TOOL_CONTENT);
|
|
1300
|
+
}
|
|
1301
|
+
function addToolContentEvent(eventName, attributes) {
|
|
1302
|
+
if (!isAnyTracingEnabled() || !isToolContentLoggingEnabled()) {
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1305
|
+
const currentSpanCtx = toolContext.getStore();
|
|
1306
|
+
if (!currentSpanCtx) {
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1309
|
+
const processedAttributes = {};
|
|
1310
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
1311
|
+
if (typeof value === "string") {
|
|
1312
|
+
const { content, truncated } = truncateContent(value);
|
|
1313
|
+
processedAttributes[key] = content;
|
|
1314
|
+
if (truncated) {
|
|
1315
|
+
processedAttributes[`${key}_truncated`] = true;
|
|
1316
|
+
processedAttributes[`${key}_original_length`] = value.length;
|
|
1317
|
+
}
|
|
1318
|
+
} else {
|
|
1319
|
+
processedAttributes[key] = value;
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
currentSpanCtx.span.addEvent(eventName, processedAttributes);
|
|
1323
|
+
}
|
|
1324
|
+
function startHookSpan(hookEvent, hookName, numHooks, hookDefinitions) {
|
|
1325
|
+
if (!isBetaTracingEnabled()) {
|
|
1326
|
+
return import_api.trace.getActiveSpan() || getTracer().startSpan("dummy");
|
|
1327
|
+
}
|
|
1328
|
+
const tracer = getTracer();
|
|
1329
|
+
const parentSpanCtx = toolContext.getStore() ?? interactionContext.getStore();
|
|
1330
|
+
const attributes = createSpanAttributes("hook", {
|
|
1331
|
+
hook_event: hookEvent,
|
|
1332
|
+
hook_name: hookName,
|
|
1333
|
+
num_hooks: numHooks,
|
|
1334
|
+
hook_definitions: hookDefinitions
|
|
1335
|
+
});
|
|
1336
|
+
const ctx = parentSpanCtx ? import_api.trace.setSpan(import_api.context.active(), parentSpanCtx.span) : import_api.context.active();
|
|
1337
|
+
const span = tracer.startSpan("claude_code.hook", { attributes }, ctx);
|
|
1338
|
+
const spanId = getSpanId(span);
|
|
1339
|
+
const spanContextObj = {
|
|
1340
|
+
span,
|
|
1341
|
+
startTime: Date.now(),
|
|
1342
|
+
attributes
|
|
1343
|
+
};
|
|
1344
|
+
activeSpans.set(spanId, new WeakRef(spanContextObj));
|
|
1345
|
+
strongSpans.set(spanId, spanContextObj);
|
|
1346
|
+
return span;
|
|
1347
|
+
}
|
|
1348
|
+
function endHookSpan(span, metadata) {
|
|
1349
|
+
if (!isBetaTracingEnabled()) {
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1352
|
+
const spanId = getSpanId(span);
|
|
1353
|
+
const spanContext = activeSpans.get(spanId)?.deref();
|
|
1354
|
+
if (!spanContext) {
|
|
1355
|
+
return;
|
|
1356
|
+
}
|
|
1357
|
+
const duration = Date.now() - spanContext.startTime;
|
|
1358
|
+
const endAttributes = {
|
|
1359
|
+
duration_ms: duration
|
|
1360
|
+
};
|
|
1361
|
+
if (metadata) {
|
|
1362
|
+
if (metadata.numSuccess !== undefined)
|
|
1363
|
+
endAttributes["num_success"] = metadata.numSuccess;
|
|
1364
|
+
if (metadata.numBlocking !== undefined)
|
|
1365
|
+
endAttributes["num_blocking"] = metadata.numBlocking;
|
|
1366
|
+
if (metadata.numNonBlockingError !== undefined)
|
|
1367
|
+
endAttributes["num_non_blocking_error"] = metadata.numNonBlockingError;
|
|
1368
|
+
if (metadata.numCancelled !== undefined)
|
|
1369
|
+
endAttributes["num_cancelled"] = metadata.numCancelled;
|
|
1370
|
+
}
|
|
1371
|
+
spanContext.span.setAttributes(endAttributes);
|
|
1372
|
+
spanContext.span.end();
|
|
1373
|
+
activeSpans.delete(spanId);
|
|
1374
|
+
strongSpans.delete(spanId);
|
|
1375
|
+
}
|
|
1376
|
+
var import_api, interactionContext, toolContext, activeSpans, strongSpans, interactionSequence = 0, _cleanupIntervalStarted = false, SPAN_TTL_MS;
|
|
1377
|
+
var init_sessionTracing = __esm(() => {
|
|
1378
|
+
init_growthbook();
|
|
1379
|
+
init_envUtils();
|
|
1380
|
+
init_telemetryAttributes();
|
|
1381
|
+
init_betaSessionTracing();
|
|
1382
|
+
init_perfettoTracing();
|
|
1383
|
+
import_api = __toESM(require_src(), 1);
|
|
1384
|
+
interactionContext = new AsyncLocalStorage;
|
|
1385
|
+
toolContext = new AsyncLocalStorage;
|
|
1386
|
+
activeSpans = new Map;
|
|
1387
|
+
strongSpans = new Map;
|
|
1388
|
+
SPAN_TTL_MS = 30 * 60 * 1000;
|
|
1389
|
+
});
|
|
1390
|
+
|
|
1391
|
+
export { getTelemetryAttributes, init_telemetryAttributes, redactIfDisabled, logOTelEvent, init_events, initializePerfettoTracing, isPerfettoTracingEnabled, registerAgent, unregisterAgent, init_perfettoTracing, clearBetaTracingState, isBetaTracingEnabled, init_betaSessionTracing, isEnhancedTelemetryEnabled, startInteractionSpan, endInteractionSpan, startLLMRequestSpan, endLLMRequestSpan, startToolSpan, startToolBlockedOnUserSpan, endToolBlockedOnUserSpan, startToolExecutionSpan, endToolExecutionSpan, endToolSpan, addToolContentEvent, startHookSpan, endHookSpan, init_sessionTracing };
|