jialing-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 +97 -0
- package/dist/chunk-065m026w.js +97 -0
- package/dist/chunk-06saje2v.js +39 -0
- package/dist/chunk-0731m51q.js +8 -0
- package/dist/chunk-0975ccyw.js +265 -0
- package/dist/chunk-09n3fjx5.js +67 -0
- package/dist/chunk-0bdjdzew.js +41 -0
- package/dist/chunk-0ce6kd7y.js +212 -0
- package/dist/chunk-0e1xsncc.js +969 -0
- package/dist/chunk-0m2861gw.js +154 -0
- package/dist/chunk-0paqc2yw.js +15 -0
- package/dist/chunk-0rg6yrhy.js +99 -0
- package/dist/chunk-0sakxrcf.js +643 -0
- package/dist/chunk-0v9hwxvz.js +105 -0
- package/dist/chunk-0vkfrmqm.js +690 -0
- package/dist/chunk-0vvfnhhv.js +248 -0
- package/dist/chunk-0w4rsycj.js +145 -0
- package/dist/chunk-0x9b2nmd.js +63 -0
- package/dist/chunk-0xjaqda8.js +1124 -0
- package/dist/chunk-1141xmr4.js +8 -0
- package/dist/chunk-13d1842d.js +154 -0
- package/dist/chunk-1921a6yb.js +32 -0
- package/dist/chunk-1ad8mk9g.js +527 -0
- package/dist/chunk-1ax41pws.js +28 -0
- package/dist/chunk-1c8z1b5v.js +16 -0
- package/dist/chunk-1cbn5kxf.js +7 -0
- package/dist/chunk-1eapde8a.js +726 -0
- package/dist/chunk-1h2famwb.js +49 -0
- package/dist/chunk-1jggnf7z.js +85 -0
- package/dist/chunk-1k92pn9c.js +32 -0
- package/dist/chunk-1qakq4sn.js +802 -0
- package/dist/chunk-1rvz0433.js +722 -0
- package/dist/chunk-1xkekb9y.js +19 -0
- package/dist/chunk-238g70xa.js +36 -0
- package/dist/chunk-24ge0eqa.js +106 -0
- package/dist/chunk-278vghwm.js +5395 -0
- package/dist/chunk-27xc1csx.js +104 -0
- package/dist/chunk-2a42s11t.js +412 -0
- package/dist/chunk-2aa02aw6.js +438 -0
- package/dist/chunk-2eykm0j0.js +20 -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-2sd2w2h4.js +44 -0
- package/dist/chunk-2tw2ve8h.js +145 -0
- package/dist/chunk-30rst83v.js +168 -0
- package/dist/chunk-3aavh06g.js +1581 -0
- package/dist/chunk-3b0yvt2h.js +469 -0
- package/dist/chunk-3be7ka25.js +56 -0
- package/dist/chunk-3c25bcsw.js +17 -0
- package/dist/chunk-3dyxka97.js +584 -0
- package/dist/chunk-3f7rypmf.js +16544 -0
- package/dist/chunk-3fsd7f51.js +93 -0
- package/dist/chunk-3gqdqmzb.js +75 -0
- package/dist/chunk-3h8a89gy.js +46 -0
- package/dist/chunk-3m84sret.js +71 -0
- package/dist/chunk-3nb7j3js.js +96 -0
- package/dist/chunk-3p08nvn2.js +98 -0
- package/dist/chunk-3r09htpc.js +318 -0
- package/dist/chunk-3r24h7t6.js +113 -0
- package/dist/chunk-3rkfxjtq.js +80 -0
- package/dist/chunk-3tmk7dc2.js +604 -0
- package/dist/chunk-3w6s9m5w.js +16 -0
- package/dist/chunk-43qjymy5.js +92 -0
- package/dist/chunk-44fpr6jq.js +434 -0
- package/dist/chunk-45kxdsp8.js +444 -0
- package/dist/chunk-495d85x1.js +8066 -0
- package/dist/chunk-4ba796se.js +1095 -0
- package/dist/chunk-4g3v8y12.js +23 -0
- package/dist/chunk-4h53xj8n.js +3445 -0
- package/dist/chunk-4jm600zv.js +13 -0
- package/dist/chunk-4jy9dtwk.js +116 -0
- package/dist/chunk-4p60dd45.js +55 -0
- package/dist/chunk-4z0jsrqg.js +81 -0
- package/dist/chunk-4zfkzkt6.js +37 -0
- package/dist/chunk-55wgxwa9.js +13877 -0
- package/dist/chunk-5dbk24zg.js +890 -0
- package/dist/chunk-5hzvp4va.js +115 -0
- package/dist/chunk-5kbt1mbt.js +500 -0
- package/dist/chunk-5pen7vr8.js +176 -0
- package/dist/chunk-5r280eng.js +198 -0
- package/dist/chunk-5srym52s.js +88 -0
- package/dist/chunk-600kg7k6.js +41 -0
- package/dist/chunk-616w0qj3.js +160 -0
- package/dist/chunk-62jw1t8c.js +94 -0
- package/dist/chunk-62xmt9mk.js +372 -0
- package/dist/chunk-64bvg7c3.js +229 -0
- package/dist/chunk-65yhe4s0.js +281 -0
- package/dist/chunk-6aewh27m.js +102 -0
- package/dist/chunk-6bd8brc4.js +48 -0
- package/dist/chunk-6dj5t602.js +341 -0
- package/dist/chunk-6exxdk1p.js +6956 -0
- package/dist/chunk-6f5j8fs0.js +752 -0
- package/dist/chunk-6g62sjpf.js +328 -0
- package/dist/chunk-6gecq2ta.js +1493 -0
- package/dist/chunk-6gr3c3w9.js +378 -0
- package/dist/chunk-6kpbgc5w.js +23 -0
- package/dist/chunk-6kseqw79.js +154 -0
- package/dist/chunk-6mxm1qd0.js +40764 -0
- package/dist/chunk-6n2qgm9v.js +8 -0
- package/dist/chunk-6tq2v3rk.js +186 -0
- package/dist/chunk-6wsdhj3v.js +93 -0
- package/dist/chunk-6zw9fhgb.js +4389 -0
- package/dist/chunk-71grc1mw.js +111 -0
- package/dist/chunk-73rpbt04.js +1947 -0
- package/dist/chunk-748feghg.js +604 -0
- package/dist/chunk-75e8gtg9.js +84 -0
- package/dist/chunk-75th4717.js +780 -0
- package/dist/chunk-760252na.js +101 -0
- package/dist/chunk-7739pg2c.js +4261 -0
- package/dist/chunk-778fnx46.js +472 -0
- package/dist/chunk-77g09znh.js +391 -0
- package/dist/chunk-7aw745vx.js +40175 -0
- package/dist/chunk-7m2nd8da.js +110 -0
- package/dist/chunk-7n35vjtw.js +444 -0
- package/dist/chunk-7n5ss4sh.js +144 -0
- package/dist/chunk-7rjnxcfe.js +107 -0
- package/dist/chunk-7sb5axvf.js +122 -0
- package/dist/chunk-7wm5s02e.js +216 -0
- package/dist/chunk-7ymfj7m3.js +151 -0
- package/dist/chunk-7z8j9qfn.js +121 -0
- package/dist/chunk-7zsapntc.js +216 -0
- package/dist/chunk-805fhkfh.js +908 -0
- package/dist/chunk-80k1nj24.js +253 -0
- package/dist/chunk-83hfzbx3.js +10 -0
- package/dist/chunk-85cypsdd.js +92 -0
- package/dist/chunk-8760caxf.js +2644 -0
- package/dist/chunk-88f6egg6.js +387 -0
- package/dist/chunk-88r7kwgj.js +22 -0
- package/dist/chunk-89e1v45e.js +463 -0
- package/dist/chunk-8bedvdm1.js +32 -0
- package/dist/chunk-8c4x4vdz.js +177 -0
- package/dist/chunk-8hq5kk3y.js +44 -0
- package/dist/chunk-8ngxagxq.js +18 -0
- package/dist/chunk-8tnsngw2.js +31 -0
- package/dist/chunk-8wjnca8h.js +307 -0
- package/dist/chunk-8y12jxg8.js +10 -0
- package/dist/chunk-8ymf4e6z.js +48 -0
- package/dist/chunk-90wp6wez.js +10510 -0
- package/dist/chunk-92bp5bnf.js +650 -0
- package/dist/chunk-92q8sx5z.js +90 -0
- package/dist/chunk-958rtmtx.js +10476 -0
- package/dist/chunk-9e2kqv5g.js +125 -0
- package/dist/chunk-9f4f1hy5.js +281 -0
- package/dist/chunk-9gbamk79.js +93 -0
- package/dist/chunk-9k5s3ryh.js +167 -0
- package/dist/chunk-9xzfqm15.js +97 -0
- package/dist/chunk-9zgdvbm6.js +110 -0
- package/dist/chunk-a0p3q8jw.js +24 -0
- package/dist/chunk-a22sayzp.js +220 -0
- package/dist/chunk-a8ejc632.js +3094 -0
- package/dist/chunk-a8gj9d9z.js +120 -0
- package/dist/chunk-a9vdeb6y.js +258 -0
- package/dist/chunk-a9yev47v.js +674 -0
- package/dist/chunk-a9zh40sj.js +48 -0
- package/dist/chunk-ack5mfba.js +105 -0
- package/dist/chunk-ae76ded0.js +30 -0
- package/dist/chunk-akjw4dh6.js +538 -0
- package/dist/chunk-asc6wz4q.js +1188 -0
- package/dist/chunk-atqejh3p.js +273 -0
- package/dist/chunk-atv2e6b7.js +61 -0
- package/dist/chunk-axvvkwz8.js +1551 -0
- package/dist/chunk-azgz7kj9.js +38 -0
- package/dist/chunk-b3zave8q.js +275 -0
- package/dist/chunk-b4wg70y1.js +54 -0
- package/dist/chunk-b8b13qn2.js +100 -0
- package/dist/chunk-bg3mt9bm.js +28 -0
- package/dist/chunk-bh4jvcjn.js +91 -0
- package/dist/chunk-bhdt6k7w.js +15 -0
- package/dist/chunk-bm1qb16p.js +17 -0
- package/dist/chunk-bpvsd1j1.js +266 -0
- package/dist/chunk-bqfnp99q.js +477 -0
- package/dist/chunk-bsbmmfyt.js +17 -0
- package/dist/chunk-bsbt34jm.js +42 -0
- package/dist/chunk-c78akdhr.js +458 -0
- package/dist/chunk-cdz5yb0r.js +57 -0
- package/dist/chunk-cfv996bs.js +22 -0
- package/dist/chunk-cgfdkzhb.js +12 -0
- package/dist/chunk-ckh4r5er.js +257 -0
- package/dist/chunk-cmgjnvn9.js +89 -0
- package/dist/chunk-cpjgvay8.js +687 -0
- package/dist/chunk-crfryjx9.js +276 -0
- package/dist/chunk-ctw5jwcd.js +213 -0
- package/dist/chunk-cvy3vntc.js +65 -0
- package/dist/chunk-cwbzz504.js +94 -0
- package/dist/chunk-cy2hswr1.js +15 -0
- package/dist/chunk-cyejkay3.js +222 -0
- package/dist/chunk-d18z9pna.js +106 -0
- package/dist/chunk-d5cq0n0v.js +162 -0
- package/dist/chunk-db45aryp.js +50 -0
- package/dist/chunk-de8nqh0z.js +790 -0
- package/dist/chunk-dfw6h350.js +2336 -0
- package/dist/chunk-dgqrcy74.js +48 -0
- package/dist/chunk-dn75ptgd.js +184 -0
- package/dist/chunk-dnh7jtpb.js +37 -0
- package/dist/chunk-dpshyv9m.js +90 -0
- package/dist/chunk-dt8cdvnm.js +642 -0
- package/dist/chunk-dtxby6fr.js +306 -0
- package/dist/chunk-dv1wfr85.js +6373 -0
- package/dist/chunk-dw363edx.js +1154 -0
- package/dist/chunk-dwrdacck.js +62 -0
- package/dist/chunk-dxnnv5e3.js +276 -0
- package/dist/chunk-e3g8q4cn.js +1646 -0
- package/dist/chunk-e3m9k9s2.js +542 -0
- package/dist/chunk-e4q49asn.js +155 -0
- package/dist/chunk-e5pntxye.js +37 -0
- package/dist/chunk-e7393td6.js +42 -0
- package/dist/chunk-ead42yrh.js +87 -0
- package/dist/chunk-eb90vwvr.js +152 -0
- package/dist/chunk-ecvwk9hg.js +250 -0
- package/dist/chunk-edjd6aay.js +173 -0
- package/dist/chunk-eg0h8mtm.js +130 -0
- package/dist/chunk-ehtwnxpg.js +1591 -0
- package/dist/chunk-ek686gx1.js +94 -0
- package/dist/chunk-eqp1rfft.js +17 -0
- package/dist/chunk-evhwt0ar.js +1015 -0
- package/dist/chunk-ewadzrm8.js +103 -0
- package/dist/chunk-ewsgsw9h.js +172291 -0
- package/dist/chunk-f0pa0r7e.js +3198 -0
- package/dist/chunk-f2mhrmww.js +62 -0
- package/dist/chunk-f39zxvwn.js +401 -0
- package/dist/chunk-f46z54tq.js +374 -0
- package/dist/chunk-f5ma3nh5.js +3436 -0
- package/dist/chunk-f60q23az.js +3038 -0
- package/dist/chunk-f6v2nz57.js +107 -0
- package/dist/chunk-f6yjan38.js +38 -0
- package/dist/chunk-fbv4apne.js +51 -0
- package/dist/chunk-fem4s778.js +70 -0
- package/dist/chunk-fezm1kn8.js +376 -0
- package/dist/chunk-fm1n3ysp.js +6108 -0
- package/dist/chunk-frg83bfw.js +225 -0
- package/dist/chunk-fscm8db0.js +692 -0
- package/dist/chunk-fyc5fepv.js +10 -0
- package/dist/chunk-g0j0t6qk.js +26 -0
- package/dist/chunk-g0nc1ftf.js +849 -0
- package/dist/chunk-g338npwr.js +1061 -0
- package/dist/chunk-g3t0act8.js +8 -0
- package/dist/chunk-g75w4hw3.js +26 -0
- package/dist/chunk-g8vp82en.js +1866 -0
- package/dist/chunk-gax0fcbx.js +182 -0
- package/dist/chunk-gsz4dh3y.js +606 -0
- package/dist/chunk-gtfffm7h.js +440 -0
- package/dist/chunk-gver9zb9.js +420 -0
- package/dist/chunk-gyj242zr.js +20 -0
- package/dist/chunk-h0qngp9w.js +157 -0
- package/dist/chunk-h14kemnk.js +123 -0
- package/dist/chunk-h8wj1a74.js +8960 -0
- package/dist/chunk-h9mcb2eg.js +87 -0
- package/dist/chunk-h9nh2980.js +91 -0
- package/dist/chunk-hakdhagh.js +16606 -0
- package/dist/chunk-hbc6ymdv.js +55 -0
- package/dist/chunk-hh7cmy4k.js +20 -0
- package/dist/chunk-hjhc4cpt.js +69 -0
- package/dist/chunk-hjwez8qc.js +5018 -0
- package/dist/chunk-hk9xz7gk.js +118 -0
- package/dist/chunk-hqmz36b3.js +552 -0
- package/dist/chunk-hrzerbfw.js +1299 -0
- package/dist/chunk-hs8ph4p8.js +8 -0
- package/dist/chunk-ht1xwrnd.js +716 -0
- package/dist/chunk-hvmfg2dc.js +338 -0
- package/dist/chunk-hx2tr4ep.js +7189 -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-j49g6g3s.js +57 -0
- package/dist/chunk-j5d5hp9h.js +71 -0
- package/dist/chunk-j64ga6ta.js +8035 -0
- package/dist/chunk-j7tyxan1.js +116 -0
- package/dist/chunk-j8v4774z.js +424 -0
- package/dist/chunk-jafes477.js +29 -0
- package/dist/chunk-jd32zbps.js +15 -0
- package/dist/chunk-jdgeec04.js +4249 -0
- package/dist/chunk-jftd4jq5.js +4521 -0
- package/dist/chunk-jkxqhv6y.js +812 -0
- package/dist/chunk-jmfr6h0n.js +120 -0
- package/dist/chunk-jn4aabmx.js +40 -0
- package/dist/chunk-jnhkref0.js +30 -0
- package/dist/chunk-jsbpm1gz.js +27 -0
- package/dist/chunk-jtcyjc3k.js +5802 -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-k3dcdnck.js +89 -0
- package/dist/chunk-k3wadzcd.js +88 -0
- package/dist/chunk-kaeshsk1.js +713 -0
- package/dist/chunk-kbkey9ed.js +522 -0
- package/dist/chunk-kcwfhqbb.js +196 -0
- package/dist/chunk-key6jr7p.js +224 -0
- package/dist/chunk-knay8cy9.js +173 -0
- package/dist/chunk-kr3rg2y1.js +95 -0
- package/dist/chunk-kwekc97v.js +18 -0
- package/dist/chunk-m06q12hg.js +61 -0
- package/dist/chunk-m2mcpbhk.js +43 -0
- package/dist/chunk-m8v220gz.js +71 -0
- package/dist/chunk-mgpqy78h.js +208 -0
- package/dist/chunk-mkejwh4t.js +16 -0
- package/dist/chunk-mptyw5n1.js +107 -0
- package/dist/chunk-mqajm0dp.js +66 -0
- package/dist/chunk-mrksbgxj.js +490 -0
- package/dist/chunk-msjfc5ba.js +246 -0
- package/dist/chunk-mt25echc.js +6157 -0
- package/dist/chunk-mt3jfnr8.js +277 -0
- package/dist/chunk-mtn242d4.js +9300 -0
- package/dist/chunk-mzfkvave.js +169 -0
- package/dist/chunk-n0qaeaa5.js +256 -0
- package/dist/chunk-n1erf6kh.js +22820 -0
- package/dist/chunk-n2avk1r2.js +61 -0
- package/dist/chunk-n6atnpcq.js +765 -0
- package/dist/chunk-n7ttdtk0.js +641 -0
- package/dist/chunk-ncnfzby5.js +822 -0
- package/dist/chunk-ncnr1jtf.js +2058 -0
- package/dist/chunk-nerv0jvx.js +74 -0
- package/dist/chunk-ngd2abep.js +90 -0
- package/dist/chunk-nka1g8f4.js +773 -0
- package/dist/chunk-nnaxkc2z.js +128 -0
- package/dist/chunk-npyrtj8j.js +691 -0
- package/dist/chunk-nq0fxyxh.js +752 -0
- package/dist/chunk-nrmffak7.js +114 -0
- package/dist/chunk-nsz546wq.js +1170 -0
- package/dist/chunk-nt837qt9.js +21 -0
- package/dist/chunk-nv64x1z5.js +86 -0
- package/dist/chunk-nxsh6de2.js +1711 -0
- package/dist/chunk-nz4getcr.js +40 -0
- package/dist/chunk-p1f607pa.js +83 -0
- package/dist/chunk-p2816w9z.js +1486 -0
- package/dist/chunk-p2d5nh3g.js +342 -0
- package/dist/chunk-p4r5y02t.js +90 -0
- package/dist/chunk-p7g7pf3f.js +336 -0
- package/dist/chunk-pb4ad8r2.js +110 -0
- package/dist/chunk-pbrhz0zr.js +716 -0
- package/dist/chunk-ps49ymvj.js +43 -0
- package/dist/chunk-pwnt3veb.js +103 -0
- package/dist/chunk-pwwa7s62.js +11 -0
- package/dist/chunk-px3w0kde.js +299 -0
- package/dist/chunk-pzn777jb.js +756 -0
- package/dist/chunk-q25bjaev.js +15 -0
- package/dist/chunk-q5by3da6.js +8 -0
- package/dist/chunk-q6av622g.js +38 -0
- package/dist/chunk-q6xkvtf2.js +1318 -0
- package/dist/chunk-q81jx1tq.js +476 -0
- package/dist/chunk-qehb6fk5.js +339 -0
- package/dist/chunk-qj1avx1q.js +87 -0
- package/dist/chunk-qn2dxr66.js +105 -0
- package/dist/chunk-qnfx3qtx.js +617 -0
- package/dist/chunk-qp18kd4h.js +48 -0
- package/dist/chunk-qp2qdcda.js +100 -0
- package/dist/chunk-qpjy9tcf.js +133 -0
- package/dist/chunk-qqfa0dqg.js +2343 -0
- package/dist/chunk-qwh3htcz.js +202 -0
- package/dist/chunk-qz2x630m.js +49145 -0
- package/dist/chunk-r3vakcs1.js +496 -0
- package/dist/chunk-r66hz8j6.js +34 -0
- package/dist/chunk-r6b58y3x.js +17 -0
- package/dist/chunk-rekp48rk.js +62 -0
- package/dist/chunk-rn0v1hk8.js +34 -0
- package/dist/chunk-rs1xrs6m.js +534 -0
- package/dist/chunk-rs45skes.js +123 -0
- package/dist/chunk-rzszqp82.js +524 -0
- package/dist/chunk-s274nv8k.js +8 -0
- package/dist/chunk-s3pzvdss.js +50 -0
- package/dist/chunk-s9mesaw0.js +26840 -0
- package/dist/chunk-sd36yzx8.js +954 -0
- package/dist/chunk-sdj9b9wh.js +782 -0
- package/dist/chunk-sdw2q69p.js +227 -0
- package/dist/chunk-sfgp9cc0.js +130 -0
- package/dist/chunk-spqaamnc.js +63 -0
- package/dist/chunk-spzrs4df.js +73 -0
- package/dist/chunk-sxkr7k43.js +55 -0
- package/dist/chunk-szj5wvdy.js +28 -0
- package/dist/chunk-t0rgmccj.js +39 -0
- package/dist/chunk-t1nnzjgg.js +17 -0
- package/dist/chunk-t94fcnt8.js +566 -0
- package/dist/chunk-tjaqa99q.js +125 -0
- package/dist/chunk-tjq2evtw.js +328 -0
- package/dist/chunk-ts2p6bv1.js +224 -0
- package/dist/chunk-ttk5dzz8.js +25 -0
- package/dist/chunk-tw0q7ynt.js +59 -0
- package/dist/chunk-v02jkvgy.js +131 -0
- package/dist/chunk-v084bqt3.js +1529 -0
- package/dist/chunk-v0amythm.js +164 -0
- package/dist/chunk-v1kzp02e.js +785 -0
- package/dist/chunk-v1mgv1et.js +15 -0
- package/dist/chunk-v399mzxk.js +58 -0
- package/dist/chunk-v3gm2day.js +8 -0
- package/dist/chunk-v43hrrxp.js +71 -0
- package/dist/chunk-v6aqb2aj.js +102 -0
- package/dist/chunk-v78fj8by.js +145 -0
- package/dist/chunk-v7qmhjdn.js +1921 -0
- package/dist/chunk-v9smspw2.js +4301 -0
- package/dist/chunk-vdw93s4h.js +2431 -0
- package/dist/chunk-vest0y6x.js +3830 -0
- package/dist/chunk-vf5sd1nq.js +12 -0
- package/dist/chunk-vratq94g.js +349 -0
- package/dist/chunk-vrz7t3m3.js +20 -0
- package/dist/chunk-vtb185z9.js +70 -0
- package/dist/chunk-vx01rvg8.js +654 -0
- package/dist/chunk-vyc0rjyx.js +31 -0
- package/dist/chunk-vyjeh50y.js +2149 -0
- package/dist/chunk-vzpffsza.js +269 -0
- package/dist/chunk-w2ef3kxk.js +3353 -0
- package/dist/chunk-w2z5pqd3.js +336 -0
- package/dist/chunk-w3whm4mn.js +432 -0
- package/dist/chunk-w7wgpqcp.js +157 -0
- package/dist/chunk-waa00cvb.js +301 -0
- package/dist/chunk-wb0qm4es.js +155 -0
- package/dist/chunk-wbkahkdc.js +27 -0
- package/dist/chunk-wfz0qffj.js +3939 -0
- package/dist/chunk-wn0cx0pt.js +283 -0
- package/dist/chunk-wv6gzt9c.js +726 -0
- package/dist/chunk-wx42ycm4.js +998 -0
- package/dist/chunk-wxkpgy05.js +268 -0
- package/dist/chunk-wzpdet3m.js +843 -0
- package/dist/chunk-x0mwzt38.js +714 -0
- package/dist/chunk-x592wbfh.js +244 -0
- package/dist/chunk-x5pqsp9r.js +100 -0
- package/dist/chunk-x679thag.js +825 -0
- package/dist/chunk-x8b7vft8.js +132 -0
- package/dist/chunk-x8cftch7.js +119 -0
- package/dist/chunk-x9q7r885.js +348 -0
- package/dist/chunk-xawkt0vb.js +1585 -0
- package/dist/chunk-xdw5dv00.js +8 -0
- package/dist/chunk-xe9cc860.js +287 -0
- package/dist/chunk-xjr9c3vt.js +101 -0
- package/dist/chunk-xk7zaqta.js +21933 -0
- package/dist/chunk-xktbmawc.js +678 -0
- package/dist/chunk-xn6yw46v.js +140 -0
- package/dist/chunk-xsq9ae7x.js +90 -0
- package/dist/chunk-xszk7n10.js +14358 -0
- package/dist/chunk-xt8a5r1t.js +84 -0
- package/dist/chunk-xydyndkv.js +195 -0
- package/dist/chunk-xzt10yc5.js +60 -0
- package/dist/chunk-y04y95dr.js +91 -0
- package/dist/chunk-y1784krc.js +19 -0
- package/dist/chunk-y1x32h3x.js +128 -0
- package/dist/chunk-y3s7aww5.js +99 -0
- package/dist/chunk-y47cg3kz.js +42 -0
- package/dist/chunk-y7kzvepn.js +469 -0
- package/dist/chunk-y89kbsyc.js +287 -0
- package/dist/chunk-yd87p1c3.js +159 -0
- package/dist/chunk-yf3yw8fw.js +105 -0
- package/dist/chunk-ygbf0ezx.js +1391 -0
- package/dist/chunk-yjbxnshv.js +208 -0
- package/dist/chunk-ynednmqd.js +192 -0
- package/dist/chunk-yvhez44y.js +259 -0
- package/dist/chunk-ywxd4qw4.js +22 -0
- package/dist/chunk-yzrmgpy4.js +117 -0
- package/dist/chunk-z0b2vb24.js +862 -0
- package/dist/chunk-z1zj044v.js +655 -0
- package/dist/chunk-z2dp53wn.js +17 -0
- package/dist/chunk-z3w0xasa.js +165 -0
- package/dist/chunk-z7ycmrb3.js +644 -0
- package/dist/chunk-zh11tdkb.js +347 -0
- package/dist/chunk-zk2wsm7d.js +15 -0
- package/dist/chunk-zqfqcf22.js +229 -0
- package/dist/chunk-zqk2j8px.js +699 -0
- package/dist/chunk-zqvsc10j.js +2833 -0
- package/dist/chunk-zsfxha74.js +17655 -0
- package/dist/chunk-zvc4snyb.js +117 -0
- package/dist/cli.js +194 -0
- package/package.json +173 -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-3f7rypmf.js";
|
|
14
|
+
import {
|
|
15
|
+
getAgentId,
|
|
16
|
+
getAgentName,
|
|
17
|
+
getParentSessionId,
|
|
18
|
+
init_teammate
|
|
19
|
+
} from "./chunk-0e1xsncc.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-nxsh6de2.js";
|
|
36
|
+
import {
|
|
37
|
+
init_envUtils,
|
|
38
|
+
isEnvTruthy
|
|
39
|
+
} from "./chunk-3r24h7t6.js";
|
|
40
|
+
import {
|
|
41
|
+
getEventLogger,
|
|
42
|
+
getIsNonInteractiveSession,
|
|
43
|
+
getPromptId,
|
|
44
|
+
getSessionId,
|
|
45
|
+
init_state
|
|
46
|
+
} from "./chunk-qqfa0dqg.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"] = 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 };
|