@stevenzxs/ccharness 1.0.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/LICENSE +21 -0
- package/README.md +406 -0
- package/dist/chunk-01jednzd.js +120 -0
- package/dist/chunk-03cv5q8d.js +10 -0
- package/dist/chunk-03eejbgx.js +32 -0
- package/dist/chunk-042vrke6.js +4261 -0
- package/dist/chunk-0fnzcgq4.js +1299 -0
- package/dist/chunk-0mhg1dcb.js +84 -0
- package/dist/chunk-0ngh0jb0.js +2336 -0
- package/dist/chunk-0npp1cpj.js +908 -0
- package/dist/chunk-0p7xnx81.js +534 -0
- package/dist/chunk-0qj905nt.js +18 -0
- package/dist/chunk-0r9kq1re.js +566 -0
- package/dist/chunk-0s832ncn.js +713 -0
- package/dist/chunk-0wb0snn7.js +17 -0
- package/dist/chunk-0xm6pgm7.js +376 -0
- package/dist/chunk-11q9h2zt.js +2343 -0
- package/dist/chunk-13qesvnw.js +17 -0
- package/dist/chunk-194x9yzh.js +8960 -0
- package/dist/chunk-1aa9c3d5.js +862 -0
- package/dist/chunk-1c1ddsyx.js +6108 -0
- package/dist/chunk-1cjgpxgb.js +39 -0
- package/dist/chunk-1cn5msrh.js +20 -0
- package/dist/chunk-1enn4hgk.js +257 -0
- package/dist/chunk-1j7ycg2n.js +195 -0
- package/dist/chunk-1jmyrzma.js +299 -0
- package/dist/chunk-1mx08tbr.js +40 -0
- package/dist/chunk-1q66qfgx.js +202 -0
- package/dist/chunk-1syefx6d.js +20 -0
- package/dist/chunk-1wwv77m7.js +849 -0
- package/dist/chunk-1z29we12.js +122 -0
- package/dist/chunk-1zbwhcbt.js +1124 -0
- package/dist/chunk-1zktckzd.js +85 -0
- package/dist/chunk-209sxdcw.js +822 -0
- package/dist/chunk-234ed7mp.js +56 -0
- package/dist/chunk-26rd7jy7.js +48 -0
- package/dist/chunk-282tvg56.js +140 -0
- package/dist/chunk-2cbewcew.js +61 -0
- package/dist/chunk-2fyw5sbr.js +48 -0
- package/dist/chunk-2jxsyb98.js +70 -0
- package/dist/chunk-2mknyk0c.js +27 -0
- package/dist/chunk-2mwnwp0n.js +17 -0
- package/dist/chunk-2whhcyfm.js +10510 -0
- package/dist/chunk-2xgpm00c.js +4521 -0
- package/dist/chunk-2z444jcw.js +15 -0
- package/dist/chunk-2zvkzqg5.js +128 -0
- package/dist/chunk-306bhqkx.js +145 -0
- package/dist/chunk-32thc3se.js +10 -0
- package/dist/chunk-347yx4gw.js +113 -0
- package/dist/chunk-34q7gfz5.js +192 -0
- package/dist/chunk-374tvt0h.js +338 -0
- package/dist/chunk-375qesdp.js +8 -0
- package/dist/chunk-39se7s7y.js +220 -0
- package/dist/chunk-3abaq08g.js +34 -0
- package/dist/chunk-3e1qyt7r.js +19 -0
- package/dist/chunk-3j4m1cvv.js +105 -0
- package/dist/chunk-3kxndhf2.js +157 -0
- package/dist/chunk-3njc6nav.js +186 -0
- package/dist/chunk-3pvn6ah4.js +1170 -0
- package/dist/chunk-3sk5rm8d.js +95 -0
- package/dist/chunk-3t6vgvxc.js +48 -0
- package/dist/chunk-3vfxjn7g.js +19 -0
- package/dist/chunk-3vsvh26y.js +6373 -0
- package/dist/chunk-3yx3n6jw.js +58 -0
- package/dist/chunk-48dm35w8.js +83 -0
- package/dist/chunk-4a189mn2.js +103 -0
- package/dist/chunk-4a1qse8t.js +227 -0
- package/dist/chunk-4a4fx0xe.js +44 -0
- package/dist/chunk-4av0ctrw.js +802 -0
- package/dist/chunk-4dv3xe3v.js +374 -0
- package/dist/chunk-4em69zqw.js +111 -0
- package/dist/chunk-4gqqcvtg.js +216 -0
- package/dist/chunk-4jzrntm7.js +49145 -0
- package/dist/chunk-4qvwjbrw.js +80 -0
- package/dist/chunk-4sp6y0dv.js +253 -0
- package/dist/chunk-4spgkgr3.js +43 -0
- package/dist/chunk-4zp30qkp.js +117 -0
- package/dist/chunk-51ys6evg.js +165 -0
- package/dist/chunk-55qmd5p0.js +438 -0
- package/dist/chunk-573t7mpp.js +107 -0
- package/dist/chunk-57ed32yz.js +8066 -0
- package/dist/chunk-5g5bryqc.js +38 -0
- package/dist/chunk-5k0tng2r.js +10 -0
- package/dist/chunk-5kxbf62g.js +3094 -0
- package/dist/chunk-5wz280hj.js +266 -0
- package/dist/chunk-5x8hzf5m.js +268 -0
- package/dist/chunk-5xhv7689.js +722 -0
- package/dist/chunk-5yc6h8kt.js +110 -0
- package/dist/chunk-5ygzvfm4.js +3038 -0
- package/dist/chunk-63tc1z9e.js +336 -0
- package/dist/chunk-66e8xb1w.js +164 -0
- package/dist/chunk-67c4kyv7.js +90 -0
- package/dist/chunk-69ps473h.js +44 -0
- package/dist/chunk-6d97n5jn.js +107 -0
- package/dist/chunk-6dm2bx09.js +155 -0
- package/dist/chunk-6fzm4ea8.js +5018 -0
- package/dist/chunk-6jbf0ekc.js +265 -0
- package/dist/chunk-6kyxcqx3.js +229 -0
- package/dist/chunk-6q4fnetz.js +62 -0
- package/dist/chunk-6sehqbsm.js +726 -0
- package/dist/chunk-6x35ffpx.js +690 -0
- package/dist/chunk-6yfg5pfx.js +2644 -0
- package/dist/chunk-6zwjwn6w.js +87 -0
- package/dist/chunk-70hm8n53.js +17 -0
- package/dist/chunk-71sdcaq6.js +15 -0
- package/dist/chunk-74pb40hq.js +276 -0
- package/dist/chunk-7626fyn7.js +378 -0
- package/dist/chunk-777cd44d.js +8 -0
- package/dist/chunk-77pdadam.js +22 -0
- package/dist/chunk-78vwdsak.js +74 -0
- package/dist/chunk-7bjf740p.js +114 -0
- package/dist/chunk-7bz577cx.js +88 -0
- package/dist/chunk-7ch74x91.js +55 -0
- package/dist/chunk-7ffm3cf1.js +15 -0
- package/dist/chunk-7fxg2tat.js +1525 -0
- package/dist/chunk-7gqmtz5b.js +67 -0
- package/dist/chunk-7gyv4cj4.js +8 -0
- package/dist/chunk-7j06h9fj.js +469 -0
- package/dist/chunk-7jf6txsy.js +339 -0
- package/dist/chunk-7kvwe19b.js +301 -0
- package/dist/chunk-7kzd2ds8.js +23 -0
- package/dist/chunk-7sgrwcng.js +42 -0
- package/dist/chunk-7vvp1p25.js +27 -0
- package/dist/chunk-87dph3k3.js +28 -0
- package/dist/chunk-88espsab.js +6956 -0
- package/dist/chunk-8ex99hk1.js +48 -0
- package/dist/chunk-8j4s2p99.js +154 -0
- package/dist/chunk-8pfg3tcr.js +432 -0
- package/dist/chunk-8rxpkg7r.js +349 -0
- package/dist/chunk-8sdgr592.js +101 -0
- package/dist/chunk-8sw7n98r.js +25 -0
- package/dist/chunk-8z0at2dq.js +97 -0
- package/dist/chunk-8z3rehw2.js +496 -0
- package/dist/chunk-8zpesm58.js +90 -0
- package/dist/chunk-903585x0.js +604 -0
- package/dist/chunk-90b9rgkz.js +38 -0
- package/dist/chunk-91ttqm6v.js +213 -0
- package/dist/chunk-935nrvdb.js +13 -0
- package/dist/chunk-93a5my23.js +8 -0
- package/dist/chunk-95nc5pzz.js +7 -0
- package/dist/chunk-96p9781m.js +123 -0
- package/dist/chunk-9756beve.js +641 -0
- package/dist/chunk-98xvtxww.js +654 -0
- package/dist/chunk-9a9g5hbj.js +205 -0
- package/dist/chunk-9djtdqy5.js +90 -0
- package/dist/chunk-9evz90jf.js +327 -0
- package/dist/chunk-9exe1kte.js +40763 -0
- package/dist/chunk-9g236dqe.js +100 -0
- package/dist/chunk-9hn8e6h1.js +12 -0
- package/dist/chunk-9tct10v3.js +342 -0
- package/dist/chunk-9trmzwqe.js +41 -0
- package/dist/chunk-9w6ckyk4.js +49 -0
- package/dist/chunk-9z4fsn6r.js +69 -0
- package/dist/chunk-a07hgnvm.js +16357 -0
- package/dist/chunk-a194z3ja.js +71 -0
- package/dist/chunk-a2qdxwan.js +133 -0
- package/dist/chunk-a6vvs35f.js +2058 -0
- package/dist/chunk-a7ad1tv5.js +5395 -0
- package/dist/chunk-aafrwrz7.js +92 -0
- package/dist/chunk-acpsvrmw.js +347 -0
- package/dist/chunk-adbw7d8r.js +73 -0
- package/dist/chunk-ae76ded0.js +30 -0
- package/dist/chunk-aedvgdnm.js +678 -0
- package/dist/chunk-aeysytks.js +216 -0
- package/dist/chunk-af9fsv4c.js +1581 -0
- package/dist/chunk-aheacmqy.js +552 -0
- package/dist/chunk-ahwfkdn9.js +212 -0
- package/dist/chunk-aj2wnn6h.js +94 -0
- package/dist/chunk-akjwkykc.js +726 -0
- package/dist/chunk-atk19d20.js +92 -0
- package/dist/chunk-awd0z66z.js +42 -0
- package/dist/chunk-az8c3v5c.js +283 -0
- package/dist/chunk-b3xqe5a1.js +387 -0
- package/dist/chunk-b912ty5v.js +1154 -0
- package/dist/chunk-b95s01h5.js +1059 -0
- package/dist/chunk-b9tfy4p2.js +812 -0
- package/dist/chunk-bax3zk4f.js +173 -0
- package/dist/chunk-bb6c9wwg.js +26 -0
- package/dist/chunk-bbg5s7cx.js +16 -0
- package/dist/chunk-bf8qbbrt.js +50 -0
- package/dist/chunk-bg4wwahn.js +130 -0
- package/dist/chunk-bj37yvxb.js +159 -0
- package/dist/chunk-bjrpafj5.js +412 -0
- package/dist/chunk-bjs56wah.js +71 -0
- package/dist/chunk-bpw95je2.js +36 -0
- package/dist/chunk-bq1dmt8g.js +105 -0
- package/dist/chunk-bs5mxhj4.js +328 -0
- package/dist/chunk-bs65rf69.js +825 -0
- package/dist/chunk-bvzcxq58.js +176 -0
- package/dist/chunk-bw1n8g13.js +880 -0
- package/dist/chunk-c13w1efw.js +1636 -0
- package/dist/chunk-cajgkary.js +30 -0
- package/dist/chunk-cbaqat9y.js +28 -0
- package/dist/chunk-cca2tn5v.js +275 -0
- package/dist/chunk-cgqmdweq.js +104 -0
- package/dist/chunk-cnkn7z01.js +527 -0
- package/dist/chunk-ctaj9d7k.js +75 -0
- package/dist/chunk-cxnskapn.js +94 -0
- package/dist/chunk-d82xy2py.js +26 -0
- package/dist/chunk-d8n53hz3.js +269 -0
- package/dist/chunk-d975tm51.js +39 -0
- package/dist/chunk-de6jnc66.js +117 -0
- package/dist/chunk-dgfqf6b3.js +41 -0
- package/dist/chunk-dnrj70b6.js +773 -0
- package/dist/chunk-dvkm4w3r.js +21933 -0
- package/dist/chunk-dwgqen1c.js +71 -0
- package/dist/chunk-dyb75cc3.js +250 -0
- package/dist/chunk-e3abfxpy.js +1486 -0
- package/dist/chunk-e4hf72fj.js +106 -0
- package/dist/chunk-ebd8xb7s.js +14358 -0
- package/dist/chunk-ebethay6.js +843 -0
- package/dist/chunk-egjbbxef.js +208 -0
- package/dist/chunk-ekqd8w68.js +229 -0
- package/dist/chunk-epy4wgm3.js +40174 -0
- package/dist/chunk-eq8qc7yv.js +173 -0
- package/dist/chunk-ewsf9n03.js +8035 -0
- package/dist/chunk-f1h81jgx.js +522 -0
- package/dist/chunk-f2baxyqh.js +15 -0
- package/dist/chunk-f3w8qrje.js +65 -0
- package/dist/chunk-f5ycj085.js +1529 -0
- package/dist/chunk-f77gmxaj.js +59 -0
- package/dist/chunk-fagt9n9h.js +224 -0
- package/dist/chunk-fejeqe61.js +785 -0
- package/dist/chunk-fkjcetzx.js +5289 -0
- package/dist/chunk-fqc61q2v.js +8 -0
- package/dist/chunk-fr10aqsa.js +120 -0
- package/dist/chunk-frhq1hpt.js +10476 -0
- package/dist/chunk-fv4mncer.js +37 -0
- package/dist/chunk-fvm3y2aw.js +24 -0
- package/dist/chunk-fyrdmq8b.js +172276 -0
- package/dist/chunk-g5d5aes1.js +244 -0
- package/dist/chunk-g5mk5cv9.js +699 -0
- package/dist/chunk-g68eqwpv.js +105 -0
- package/dist/chunk-g6egfc9x.js +90 -0
- package/dist/chunk-g6z0dtk4.js +87 -0
- package/dist/chunk-gbyt0sqy.js +87 -0
- package/dist/chunk-gf6vfkbx.js +145 -0
- package/dist/chunk-gffdheq0.js +469 -0
- package/dist/chunk-gftcezc3.js +28 -0
- package/dist/chunk-gjrcmf0a.js +752 -0
- package/dist/chunk-gr42wyg2.js +55 -0
- package/dist/chunk-grkjqdgn.js +16 -0
- package/dist/chunk-gshmd2yw.js +168 -0
- package/dist/chunk-gxa68634.js +144 -0
- package/dist/chunk-h12a4f4x.js +11 -0
- package/dist/chunk-h2bk9s70.js +584 -0
- package/dist/chunk-h2w85tq6.js +40 -0
- package/dist/chunk-h3my9t3s.js +3939 -0
- package/dist/chunk-h4przbpd.js +8 -0
- package/dist/chunk-h54bdww0.js +89 -0
- package/dist/chunk-h6b3xpyx.js +116 -0
- package/dist/chunk-h6mv3z3q.js +440 -0
- package/dist/chunk-h6zpcn90.js +306 -0
- package/dist/chunk-h8srsydp.js +131 -0
- package/dist/chunk-h94w1azy.js +655 -0
- package/dist/chunk-hac6gy6c.js +222 -0
- package/dist/chunk-hea15j0r.js +780 -0
- package/dist/chunk-hesm4r1j.js +97 -0
- package/dist/chunk-hg3f9p2g.js +90 -0
- package/dist/chunk-hhsxm2yr.js +67 -0
- package/dist/chunk-hrva39w4.js +644 -0
- package/dist/chunk-hx9yevdz.js +160 -0
- package/dist/chunk-hzrhynf9.js +93 -0
- package/dist/chunk-j1mep9ck.js +62 -0
- package/dist/chunk-j5dz6w3t.js +1095 -0
- package/dist/chunk-j9prrfnt.js +15 -0
- package/dist/chunk-jadwrr96.js +43 -0
- package/dist/chunk-jb95wx8d.js +17655 -0
- package/dist/chunk-jfxtms0h.js +1188 -0
- package/dist/chunk-jvjwkb33.js +91 -0
- package/dist/chunk-jxnyhchc.js +63 -0
- package/dist/chunk-k0zp1g16.js +81 -0
- package/dist/chunk-k293me7m.js +15 -0
- package/dist/chunk-kat2kq08.js +22 -0
- package/dist/chunk-kb3758f7.js +51 -0
- package/dist/chunk-kcn5ht05.js +119 -0
- package/dist/chunk-kf8wprgm.js +66 -0
- package/dist/chunk-kjfayq0m.js +20 -0
- package/dist/chunk-kt44dr06.js +8 -0
- package/dist/chunk-kv4bdhp2.js +23 -0
- package/dist/chunk-m28vg9w4.js +31 -0
- package/dist/chunk-m4p5x59f.js +198 -0
- package/dist/chunk-m6p9zbd3.js +3353 -0
- package/dist/chunk-ma3964ww.js +34 -0
- package/dist/chunk-ma7acpng.js +13877 -0
- package/dist/chunk-mdgtpe1j.js +152 -0
- package/dist/chunk-mexn06rd.js +32 -0
- package/dist/chunk-mezfesfw.js +184 -0
- package/dist/chunk-mjma578h.js +691 -0
- package/dist/chunk-mp683873.js +3445 -0
- package/dist/chunk-mss2zjet.js +336 -0
- package/dist/chunk-n6e5bfdv.js +115 -0
- package/dist/chunk-n7mjxcc9.js +125 -0
- package/dist/chunk-nbrtjcbx.js +22 -0
- package/dist/chunk-ncah28ha.js +1493 -0
- package/dist/chunk-nex0wzgy.js +57 -0
- package/dist/chunk-nf6abwpa.js +259 -0
- package/dist/chunk-ngmaba1s.js +998 -0
- package/dist/chunk-njsqzxq6.js +476 -0
- package/dist/chunk-nmc7ccvf.js +472 -0
- package/dist/chunk-nmctj9fp.js +169 -0
- package/dist/chunk-nmfb6gta.js +93 -0
- package/dist/chunk-npybxacd.js +12 -0
- package/dist/chunk-nt837qt9.js +21 -0
- package/dist/chunk-nx2b166v.js +307 -0
- package/dist/chunk-nyenvnv5.js +61 -0
- package/dist/chunk-nyygtkaf.js +16 -0
- package/dist/chunk-p5qfkg1n.js +88 -0
- package/dist/chunk-p8pe44w0.js +162 -0
- package/dist/chunk-p9kmn90n.js +123 -0
- package/dist/chunk-p9x9xxk0.js +22820 -0
- package/dist/chunk-pfxrg89f.js +547 -0
- package/dist/chunk-pjbtdqvd.js +542 -0
- package/dist/chunk-pqn009h9.js +524 -0
- package/dist/chunk-psrphhk1.js +110 -0
- package/dist/chunk-ptg4pxq2.js +17 -0
- package/dist/chunk-ptxteaeh.js +1591 -0
- package/dist/chunk-pvjx56m7.js +7 -0
- package/dist/chunk-pwtwa4tb.js +1866 -0
- package/dist/chunk-pxea1859.js +20 -0
- package/dist/chunk-pzc7b1as.js +281 -0
- package/dist/chunk-q2th5rh1.js +102 -0
- package/dist/chunk-q44zc68f.js +4301 -0
- package/dist/chunk-qbg3frga.js +617 -0
- package/dist/chunk-qcfh5q3c.js +500 -0
- package/dist/chunk-qdfny957.js +71 -0
- package/dist/chunk-qf7ay5nh.js +167 -0
- package/dist/chunk-qkfm4tcm.js +969 -0
- package/dist/chunk-qpdqga6e.js +4389 -0
- package/dist/chunk-qt41ewab.js +11 -0
- package/dist/chunk-qxjs7qz1.js +765 -0
- package/dist/chunk-qxqe7keq.js +434 -0
- package/dist/chunk-qy8abnde.js +246 -0
- package/dist/chunk-r0sxnp5m.js +1921 -0
- package/dist/chunk-r6gf53pt.js +55 -0
- package/dist/chunk-r7g10qt9.js +50 -0
- package/dist/chunk-r8sct2ra.js +372 -0
- package/dist/chunk-rab2bvaj.js +94 -0
- package/dist/chunk-rdh1tg36.js +348 -0
- package/dist/chunk-rey3eqc4.js +125 -0
- package/dist/chunk-rgp8gbze.js +22 -0
- package/dist/chunk-rk7zgj8p.js +110 -0
- package/dist/chunk-rrgnm3c8.js +444 -0
- package/dist/chunk-rtz05esa.js +420 -0
- package/dist/chunk-rv6qkhq1.js +106 -0
- package/dist/chunk-rvd9z5a6.js +401 -0
- package/dist/chunk-rvq18zge.js +89 -0
- package/dist/chunk-rwnrwswe.js +157 -0
- package/dist/chunk-rx8t9d35.js +1947 -0
- package/dist/chunk-rxjk5rqh.js +9300 -0
- package/dist/chunk-s15dnbca.js +1391 -0
- package/dist/chunk-s6jphnxf.js +890 -0
- package/dist/chunk-s84xxjq6.js +477 -0
- package/dist/chunk-sbe835v8.js +7180 -0
- package/dist/chunk-scpenbb1.js +101 -0
- package/dist/chunk-sdg602z1.js +107 -0
- package/dist/chunk-shfd6pyj.js +105 -0
- package/dist/chunk-sjwwzx4w.js +196 -0
- package/dist/chunk-smc5y1fg.js +116 -0
- package/dist/chunk-snazkzxc.js +208 -0
- package/dist/chunk-sqgq3m1k.js +674 -0
- package/dist/chunk-sws43beh.js +604 -0
- package/dist/chunk-sz6s8vez.js +61 -0
- package/dist/chunk-t311zhe1.js +650 -0
- package/dist/chunk-t3t3m6ct.js +248 -0
- package/dist/chunk-t4sd1deb.js +2833 -0
- package/dist/chunk-t50j5994.js +151 -0
- package/dist/chunk-t5ddzq5y.js +103 -0
- package/dist/chunk-t7fp7m5t.js +102 -0
- package/dist/chunk-t8t3heze.js +121 -0
- package/dist/chunk-ta4rpce6.js +6157 -0
- package/dist/chunk-tb0e2hbp.js +65 -0
- package/dist/chunk-tcqq8ke5.js +1090 -0
- package/dist/chunk-te02vrjm.js +37 -0
- package/dist/chunk-tejyzthb.js +57 -0
- package/dist/chunk-tfhj2mgk.js +84 -0
- package/dist/chunk-tny4dm1h.js +490 -0
- package/dist/chunk-tpw8vdr3.js +258 -0
- package/dist/chunk-txcw19t4.js +224 -0
- package/dist/chunk-v06cz9jg.js +3436 -0
- package/dist/chunk-v14184xm.js +15 -0
- package/dist/chunk-v3az1vfa.js +91 -0
- package/dist/chunk-v5a9q6rx.js +60 -0
- package/dist/chunk-v6nc1t8w.js +716 -0
- package/dist/chunk-v751e540.js +91 -0
- package/dist/chunk-v7wbqcx9.js +63 -0
- package/dist/chunk-vcws3xay.js +538 -0
- package/dist/chunk-vcxsx08f.js +692 -0
- package/dist/chunk-vgjkarkg.js +273 -0
- package/dist/chunk-vmm6xa3g.js +98 -0
- package/dist/chunk-vsaf1n7a.js +118 -0
- package/dist/chunk-vtrs0tbg.js +155 -0
- package/dist/chunk-vwenx8ke.js +17 -0
- package/dist/chunk-vynvgtv9.js +99 -0
- package/dist/chunk-w130c7py.js +8 -0
- package/dist/chunk-wbbc168v.js +86 -0
- package/dist/chunk-wcrynjb3.js +1318 -0
- package/dist/chunk-wcykd9dz.js +606 -0
- package/dist/chunk-wg49dzzw.js +70 -0
- package/dist/chunk-wvnevrpz.js +756 -0
- package/dist/chunk-wyhayzse.js +37 -0
- package/dist/chunk-wzfrqg89.js +154 -0
- package/dist/chunk-x0rdr3hk.js +46 -0
- package/dist/chunk-x29x93ew.js +276 -0
- package/dist/chunk-x4sn8s76.js +16606 -0
- package/dist/chunk-x5c1thpp.js +55 -0
- package/dist/chunk-x5rvjm61.js +790 -0
- package/dist/chunk-x6nfqy22.js +287 -0
- package/dist/chunk-x74zz3vk.js +1015 -0
- package/dist/chunk-x7qhxrp7.js +225 -0
- package/dist/chunk-x8b7vft8.js +132 -0
- package/dist/chunk-x97w78sk.js +184 -0
- package/dist/chunk-xbawq95y.js +54 -0
- package/dist/chunk-xbsrmmgy.js +182 -0
- package/dist/chunk-xbt0fq2z.js +5802 -0
- package/dist/chunk-xdh96gk4.js +277 -0
- package/dist/chunk-xdxh3hfr.js +48 -0
- package/dist/chunk-xfqm4h2q.js +93 -0
- package/dist/chunk-xhj7g13b.js +2149 -0
- package/dist/chunk-xnrrczn1.js +128 -0
- package/dist/chunk-xqh2hx7b.js +63 -0
- package/dist/chunk-xr6j6937.js +62 -0
- package/dist/chunk-xrw80zgd.js +4249 -0
- package/dist/chunk-xt0q34wh.js +42 -0
- package/dist/chunk-xxtjc1kg.js +287 -0
- package/dist/chunk-xzc41mwf.js +642 -0
- package/dist/chunk-y0gs0crz.js +96 -0
- package/dist/chunk-y1qx0711.js +463 -0
- package/dist/chunk-y405893n.js +38 -0
- package/dist/chunk-y4hbgvjh.js +281 -0
- package/dist/chunk-y53pnr6r.js +687 -0
- package/dist/chunk-y5patg9p.js +26839 -0
- package/dist/chunk-y652k86h.js +110 -0
- package/dist/chunk-y76wecg0.js +256 -0
- package/dist/chunk-y7qhj88c.js +752 -0
- package/dist/chunk-y8jghf88.js +782 -0
- package/dist/chunk-yax37pn8.js +154 -0
- package/dist/chunk-yd5jyegd.js +458 -0
- package/dist/chunk-yh10eg1t.js +130 -0
- package/dist/chunk-yjcwkfkw.js +714 -0
- package/dist/chunk-yprqkkn0.js +1551 -0
- package/dist/chunk-yrrqkx5b.js +100 -0
- package/dist/chunk-ytzryynn.js +8 -0
- package/dist/chunk-yw6zrcf0.js +444 -0
- package/dist/chunk-yyk23d9b.js +17 -0
- package/dist/chunk-z2dp53wn.js +17 -0
- package/dist/chunk-z3ypmw55.js +99 -0
- package/dist/chunk-z76974hz.js +2431 -0
- package/dist/chunk-zh6k7qjn.js +643 -0
- package/dist/chunk-zmg3j7cj.js +3198 -0
- package/dist/chunk-znjb1drt.js +424 -0
- package/dist/chunk-zpja93tc.js +1585 -0
- package/dist/chunk-zqr80ypg.js +318 -0
- package/dist/chunk-ztyr7rbj.js +29 -0
- package/dist/chunk-zv1z2sdj.js +32 -0
- package/dist/chunk-zv8tag16.js +177 -0
- package/dist/chunk-zvsevk48.js +391 -0
- package/dist/cli.js +194 -0
- package/package.json +165 -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-a07hgnvm.js";
|
|
14
|
+
import {
|
|
15
|
+
getAgentId,
|
|
16
|
+
getAgentName,
|
|
17
|
+
getParentSessionId,
|
|
18
|
+
init_teammate
|
|
19
|
+
} from "./chunk-qkfm4tcm.js";
|
|
20
|
+
import {
|
|
21
|
+
require_src
|
|
22
|
+
} from "./chunk-e3abfxpy.js";
|
|
23
|
+
import {
|
|
24
|
+
djb2Hash,
|
|
25
|
+
init_hash
|
|
26
|
+
} from "./chunk-m28vg9w4.js";
|
|
27
|
+
import {
|
|
28
|
+
init_cleanupRegistry,
|
|
29
|
+
init_debug,
|
|
30
|
+
init_errors,
|
|
31
|
+
init_slowOperations,
|
|
32
|
+
jsonParse,
|
|
33
|
+
jsonStringify,
|
|
34
|
+
logForDebugging
|
|
35
|
+
} from "./chunk-7fxg2tat.js";
|
|
36
|
+
import {
|
|
37
|
+
init_envUtils,
|
|
38
|
+
isEnvTruthy
|
|
39
|
+
} from "./chunk-347yx4gw.js";
|
|
40
|
+
import {
|
|
41
|
+
getEventLogger,
|
|
42
|
+
getIsNonInteractiveSession,
|
|
43
|
+
getPromptId,
|
|
44
|
+
getSessionId,
|
|
45
|
+
init_state
|
|
46
|
+
} from "./chunk-11q9h2zt.js";
|
|
47
|
+
import {
|
|
48
|
+
__esm,
|
|
49
|
+
__toESM
|
|
50
|
+
} from "./chunk-hhsxm2yr.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"] = MACRO.VERSION;
|
|
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 };
|