langgraph-ui-components 0.0.4 → 0.0.6
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/dist/index.es10.js +31 -16
- package/dist/index.es10.js.map +1 -1
- package/dist/index.es100.js +36 -3156
- package/dist/index.es100.js.map +1 -1
- package/dist/index.es101.js +162 -33
- package/dist/index.es101.js.map +1 -1
- package/dist/index.es102.js +203 -5
- package/dist/index.es102.js.map +1 -1
- package/dist/index.es103.js +13 -72
- package/dist/index.es103.js.map +1 -1
- package/dist/index.es104.js +27 -34
- package/dist/index.es104.js.map +1 -1
- package/dist/index.es105.js +34 -5
- package/dist/index.es105.js.map +1 -1
- package/dist/index.es106.js +3159 -2
- package/dist/index.es106.js.map +1 -1
- package/dist/index.es107.js +5 -11
- package/dist/index.es107.js.map +1 -1
- package/dist/index.es108.js +2 -503
- package/dist/index.es108.js.map +1 -1
- package/dist/index.es109.js +16 -5
- package/dist/index.es109.js.map +1 -1
- package/dist/index.es11.js +146 -120
- package/dist/index.es11.js.map +1 -1
- package/dist/index.es110.js +13 -2
- package/dist/index.es110.js.map +1 -1
- package/dist/index.es111.js +484 -129
- package/dist/index.es111.js.map +1 -1
- package/dist/index.es112.js +5 -906
- package/dist/index.es112.js.map +1 -1
- package/dist/index.es113.js +2 -282
- package/dist/index.es113.js.map +1 -1
- package/dist/index.es114.js +148 -4
- package/dist/index.es114.js.map +1 -1
- package/dist/index.es115.js +869 -407
- package/dist/index.es115.js.map +1 -1
- package/dist/index.es116.js +274 -40
- package/dist/index.es116.js.map +1 -1
- package/dist/index.es117.js +4 -24
- package/dist/index.es117.js.map +1 -1
- package/dist/index.es118.js +437 -72
- package/dist/index.es118.js.map +1 -1
- package/dist/index.es119.js +42 -125
- package/dist/index.es119.js.map +1 -1
- package/dist/index.es12.js +13 -103
- package/dist/index.es12.js.map +1 -1
- package/dist/index.es120.js +21 -48
- package/dist/index.es120.js.map +1 -1
- package/dist/index.es121.js +77 -8
- package/dist/index.es121.js.map +1 -1
- package/dist/index.es122.js +127 -43
- package/dist/index.es122.js.map +1 -1
- package/dist/index.es123.js +41 -91
- package/dist/index.es123.js.map +1 -1
- package/dist/index.es124.js +9 -52
- package/dist/index.es124.js.map +1 -1
- package/dist/index.es125.js +44 -15
- package/dist/index.es125.js.map +1 -1
- package/dist/index.es126.js +97 -13
- package/dist/index.es126.js.map +1 -1
- package/dist/index.es127.js +52 -88
- package/dist/index.es127.js.map +1 -1
- package/dist/index.es128.js +15 -2
- package/dist/index.es128.js.map +1 -1
- package/dist/index.es129.js +87 -54
- package/dist/index.es129.js.map +1 -1
- package/dist/index.es13.js +126 -32
- package/dist/index.es13.js.map +1 -1
- package/dist/index.es130.js +2 -100
- package/dist/index.es130.js.map +1 -1
- package/dist/index.es131.js +163 -190
- package/dist/index.es131.js.map +1 -1
- package/dist/index.es132.js +2 -110
- package/dist/index.es132.js.map +1 -1
- package/dist/index.es133.js +53 -32
- package/dist/index.es133.js.map +1 -1
- package/dist/index.es134.js +99 -9
- package/dist/index.es134.js.map +1 -1
- package/dist/index.es135.js +190 -10
- package/dist/index.es135.js.map +1 -1
- package/dist/index.es136.js +108 -10
- package/dist/index.es136.js.map +1 -1
- package/dist/index.es137.js +30 -86
- package/dist/index.es137.js.map +1 -1
- package/dist/index.es138.js +10 -275
- package/dist/index.es138.js.map +1 -1
- package/dist/index.es139.js +11 -2
- package/dist/index.es139.js.map +1 -1
- package/dist/index.es140.js +11 -163
- package/dist/index.es140.js.map +1 -1
- package/dist/index.es141.js +87 -47
- package/dist/index.es141.js.map +1 -1
- package/dist/index.es142.js +266 -31
- package/dist/index.es142.js.map +1 -1
- package/dist/index.es143.js +2 -35
- package/dist/index.es143.js.map +1 -1
- package/dist/index.es144.js +155 -31
- package/dist/index.es144.js.map +1 -1
- package/dist/index.es145.js +48 -21
- package/dist/index.es145.js.map +1 -1
- package/dist/index.es146.js +33 -584
- package/dist/index.es146.js.map +1 -1
- package/dist/index.es147.js +34 -124
- package/dist/index.es147.js.map +1 -1
- package/dist/index.es148.js +31 -155
- package/dist/index.es148.js.map +1 -1
- package/dist/index.es149.js +24 -2
- package/dist/index.es149.js.map +1 -1
- package/dist/index.es15.js +15 -15
- package/dist/index.es150.js +591 -2
- package/dist/index.es150.js.map +1 -1
- package/dist/index.es151.js +125 -2
- package/dist/index.es151.js.map +1 -1
- package/dist/index.es152.js +3 -21
- package/dist/index.es152.js.map +1 -1
- package/dist/index.es153.js +2 -2
- package/dist/index.es154.js +2 -25
- package/dist/index.es154.js.map +1 -1
- package/dist/index.es155.js +22 -8
- package/dist/index.es155.js.map +1 -1
- package/dist/index.es156.js +2 -5
- package/dist/index.es156.js.map +1 -1
- package/dist/index.es157.js +24 -12
- package/dist/index.es157.js.map +1 -1
- package/dist/index.es158.js +5 -6
- package/dist/index.es158.js.map +1 -1
- package/dist/index.es159.js +12 -63
- package/dist/index.es159.js.map +1 -1
- package/dist/index.es160.js +5 -21
- package/dist/index.es160.js.map +1 -1
- package/dist/index.es161.js +8 -6
- package/dist/index.es161.js.map +1 -1
- package/dist/index.es162.js +22 -346
- package/dist/index.es162.js.map +1 -1
- package/dist/index.es163.js +12 -25
- package/dist/index.es163.js.map +1 -1
- package/dist/index.es164.js +53 -11
- package/dist/index.es164.js.map +1 -1
- package/dist/index.es165.js +59 -49
- package/dist/index.es165.js.map +1 -1
- package/dist/index.es166.js +22 -7
- package/dist/index.es166.js.map +1 -1
- package/dist/index.es167.js +5 -102
- package/dist/index.es167.js.map +1 -1
- package/dist/index.es168.js +339 -109
- package/dist/index.es168.js.map +1 -1
- package/dist/index.es169.js +7 -136
- package/dist/index.es169.js.map +1 -1
- package/dist/index.es17.js +2 -2
- package/dist/index.es170.js +97 -109
- package/dist/index.es170.js.map +1 -1
- package/dist/index.es171.js +119 -6
- package/dist/index.es171.js.map +1 -1
- package/dist/index.es172.js +136 -4
- package/dist/index.es172.js.map +1 -1
- package/dist/index.es173.js +115 -2
- package/dist/index.es173.js.map +1 -1
- package/dist/index.es174.js +6 -3737
- package/dist/index.es174.js.map +1 -1
- package/dist/index.es175.js +2 -342
- package/dist/index.es175.js.map +1 -1
- package/dist/index.es176.js +138 -105
- package/dist/index.es176.js.map +1 -1
- package/dist/index.es177.js +2 -133
- package/dist/index.es177.js.map +1 -1
- package/dist/index.es178.js +3734 -12
- package/dist/index.es178.js.map +1 -1
- package/dist/index.es179.js +326 -136
- package/dist/index.es179.js.map +1 -1
- package/dist/index.es180.js +107 -13
- package/dist/index.es180.js.map +1 -1
- package/dist/index.es181.js +131 -6
- package/dist/index.es181.js.map +1 -1
- package/dist/index.es182.js +13 -19
- package/dist/index.es182.js.map +1 -1
- package/dist/index.es183.js +139 -77
- package/dist/index.es183.js.map +1 -1
- package/dist/index.es184.js +13 -241
- package/dist/index.es184.js.map +1 -1
- package/dist/index.es185.js +8 -24
- package/dist/index.es185.js.map +1 -1
- package/dist/index.es186.js +21 -6
- package/dist/index.es186.js.map +1 -1
- package/dist/index.es187.js +90 -4
- package/dist/index.es187.js.map +1 -1
- package/dist/index.es188.js +240 -15
- package/dist/index.es188.js.map +1 -1
- package/dist/index.es189.js +24 -8
- package/dist/index.es189.js.map +1 -1
- package/dist/index.es190.js +6 -142
- package/dist/index.es190.js.map +1 -1
- package/dist/index.es191.js +4 -2
- package/dist/index.es191.js.map +1 -1
- package/dist/index.es192.js +18 -32
- package/dist/index.es192.js.map +1 -1
- package/dist/index.es193.js +8 -6
- package/dist/index.es193.js.map +1 -1
- package/dist/index.es194.js +31 -105
- package/dist/index.es194.js.map +1 -1
- package/dist/index.es195.js +6 -13
- package/dist/index.es195.js.map +1 -1
- package/dist/index.es196.js +105 -17
- package/dist/index.es196.js.map +1 -1
- package/dist/index.es197.js +11 -29
- package/dist/index.es197.js.map +1 -1
- package/dist/index.es198.js +17 -3
- package/dist/index.es198.js.map +1 -1
- package/dist/index.es199.js +30 -4
- package/dist/index.es199.js.map +1 -1
- package/dist/index.es2.js +24 -15
- package/dist/index.es2.js.map +1 -1
- package/dist/index.es20.js +35 -66
- package/dist/index.es20.js.map +1 -1
- package/dist/index.es200.js +4 -5
- package/dist/index.es200.js.map +1 -1
- package/dist/index.es201.js +4 -36
- package/dist/index.es201.js.map +1 -1
- package/dist/index.es202.js +5 -8
- package/dist/index.es202.js.map +1 -1
- package/dist/index.es203.js +36 -5
- package/dist/index.es203.js.map +1 -1
- package/dist/index.es204.js +5 -4
- package/dist/index.es204.js.map +1 -1
- package/dist/index.es205.js +5 -41
- package/dist/index.es205.js.map +1 -1
- package/dist/index.es206.js +4 -10
- package/dist/index.es206.js.map +1 -1
- package/dist/index.es207.js +39 -239
- package/dist/index.es207.js.map +1 -1
- package/dist/index.es208.js +10 -48
- package/dist/index.es208.js.map +1 -1
- package/dist/index.es209.js +239 -32
- package/dist/index.es209.js.map +1 -1
- package/dist/index.es21.js +25 -34
- package/dist/index.es21.js.map +1 -1
- package/dist/index.es210.js +49 -11
- package/dist/index.es210.js.map +1 -1
- package/dist/index.es211.js +33 -6
- package/dist/index.es211.js.map +1 -1
- package/dist/index.es212.js +12 -6
- package/dist/index.es212.js.map +1 -1
- package/dist/index.es213.js +7 -64
- package/dist/index.es213.js.map +1 -1
- package/dist/index.es214.js +6 -40
- package/dist/index.es214.js.map +1 -1
- package/dist/index.es215.js +63 -30
- package/dist/index.es215.js.map +1 -1
- package/dist/index.es216.js +35 -56
- package/dist/index.es216.js.map +1 -1
- package/dist/index.es217.js +32 -15
- package/dist/index.es217.js.map +1 -1
- package/dist/index.es218.js +60 -21
- package/dist/index.es218.js.map +1 -1
- package/dist/index.es219.js +15 -5
- package/dist/index.es219.js.map +1 -1
- package/dist/index.es22.js +146 -27
- package/dist/index.es22.js.map +1 -1
- package/dist/index.es220.js +21 -15
- package/dist/index.es220.js.map +1 -1
- package/dist/index.es221.js +4 -32
- package/dist/index.es221.js.map +1 -1
- package/dist/index.es222.js +16 -4
- package/dist/index.es222.js.map +1 -1
- package/dist/index.es223.js +32 -4
- package/dist/index.es223.js.map +1 -1
- package/dist/index.es224.js +5 -5
- package/dist/index.es224.js.map +1 -1
- package/dist/index.es225.js +4 -7
- package/dist/index.es225.js.map +1 -1
- package/dist/index.es226.js +4 -91
- package/dist/index.es226.js.map +1 -1
- package/dist/index.es227.js +7 -17
- package/dist/index.es227.js.map +1 -1
- package/dist/index.es228.js +90 -760
- package/dist/index.es228.js.map +1 -1
- package/dist/index.es229.js +18 -66
- package/dist/index.es229.js.map +1 -1
- package/dist/index.es23.js +16 -146
- package/dist/index.es23.js.map +1 -1
- package/dist/index.es230.js +749 -161
- package/dist/index.es230.js.map +1 -1
- package/dist/index.es231.js +66 -38
- package/dist/index.es231.js.map +1 -1
- package/dist/index.es232.js +172 -135
- package/dist/index.es232.js.map +1 -1
- package/dist/index.es233.js +136 -92
- package/dist/index.es233.js.map +1 -1
- package/dist/index.es234.js +92 -32
- package/dist/index.es234.js.map +1 -1
- package/dist/index.es235.js +32 -284
- package/dist/index.es235.js.map +1 -1
- package/dist/index.es236.js +284 -25
- package/dist/index.es236.js.map +1 -1
- package/dist/index.es237.js +22 -20
- package/dist/index.es237.js.map +1 -1
- package/dist/index.es238.js +22 -13
- package/dist/index.es238.js.map +1 -1
- package/dist/index.es239.js +12 -12
- package/dist/index.es239.js.map +1 -1
- package/dist/index.es24.js +58 -295
- package/dist/index.es24.js.map +1 -1
- package/dist/index.es240.js +13 -24
- package/dist/index.es240.js.map +1 -1
- package/dist/index.es241.js +22 -42
- package/dist/index.es241.js.map +1 -1
- package/dist/index.es242.js +45 -11
- package/dist/index.es242.js.map +1 -1
- package/dist/index.es243.js +10 -10
- package/dist/index.es243.js.map +1 -1
- package/dist/index.es244.js +10 -10
- package/dist/index.es244.js.map +1 -1
- package/dist/index.es245.js +11 -14
- package/dist/index.es245.js.map +1 -1
- package/dist/index.es246.js +14 -11
- package/dist/index.es246.js.map +1 -1
- package/dist/index.es247.js +11 -11
- package/dist/index.es247.js.map +1 -1
- package/dist/index.es248.js +10 -10
- package/dist/index.es248.js.map +1 -1
- package/dist/index.es249.js +11 -15
- package/dist/index.es249.js.map +1 -1
- package/dist/index.es25.js +298 -114
- package/dist/index.es25.js.map +1 -1
- package/dist/index.es250.js +15 -11
- package/dist/index.es250.js.map +1 -1
- package/dist/index.es251.js +10 -10
- package/dist/index.es251.js.map +1 -1
- package/dist/index.es252.js +11 -11
- package/dist/index.es252.js.map +1 -1
- package/dist/index.es253.js +10 -10
- package/dist/index.es253.js.map +1 -1
- package/dist/index.es254.js +10 -10
- package/dist/index.es254.js.map +1 -1
- package/dist/index.es255.js +10 -10
- package/dist/index.es255.js.map +1 -1
- package/dist/index.es256.js +10 -10
- package/dist/index.es256.js.map +1 -1
- package/dist/index.es257.js +10 -10
- package/dist/index.es257.js.map +1 -1
- package/dist/index.es258.js +11 -56
- package/dist/index.es258.js.map +1 -1
- package/dist/index.es259.js +53 -46
- package/dist/index.es259.js.map +1 -1
- package/dist/index.es26.js +121 -5
- package/dist/index.es26.js.map +1 -1
- package/dist/index.es260.js +42 -112
- package/dist/index.es260.js.map +1 -1
- package/dist/index.es261.js +87 -352
- package/dist/index.es261.js.map +1 -1
- package/dist/index.es262.js +381 -15
- package/dist/index.es262.js.map +1 -1
- package/dist/index.es263.js +17 -10
- package/dist/index.es263.js.map +1 -1
- package/dist/index.es264.js +10 -30
- package/dist/index.es264.js.map +1 -1
- package/dist/index.es265.js +17 -17
- package/dist/index.es265.js.map +1 -1
- package/dist/index.es266.js +25 -56
- package/dist/index.es266.js.map +1 -1
- package/dist/index.es267.js +59 -14
- package/dist/index.es267.js.map +1 -1
- package/dist/index.es268.js +14 -74
- package/dist/index.es268.js.map +1 -1
- package/dist/index.es269.js +77 -11
- package/dist/index.es269.js.map +1 -1
- package/dist/index.es270.js +10 -10
- package/dist/index.es270.js.map +1 -1
- package/dist/index.es271.js +11 -15
- package/dist/index.es271.js.map +1 -1
- package/dist/index.es272.js +14 -51
- package/dist/index.es272.js.map +1 -1
- package/dist/index.es273.js +44 -158
- package/dist/index.es273.js.map +1 -1
- package/dist/index.es274.js +167 -2
- package/dist/index.es274.js.map +1 -1
- package/dist/index.es275.js +37 -10
- package/dist/index.es275.js.map +1 -1
- package/dist/index.es276.js +2 -20
- package/dist/index.es276.js.map +1 -1
- package/dist/index.es277.js +10 -38
- package/dist/index.es277.js.map +1 -1
- package/dist/index.es278.js +23 -0
- package/dist/index.es278.js.map +1 -0
- package/dist/index.es279.js +42 -0
- package/dist/index.es279.js.map +1 -0
- package/dist/index.es28.js +7 -7
- package/dist/index.es29.js +1 -1
- package/dist/index.es32.js +4 -4
- package/dist/index.es33.js +117 -13
- package/dist/index.es33.js.map +1 -1
- package/dist/index.es34.js +65 -112
- package/dist/index.es34.js.map +1 -1
- package/dist/index.es35.js +18 -71
- package/dist/index.es35.js.map +1 -1
- package/dist/index.es36.js +260 -17
- package/dist/index.es36.js.map +1 -1
- package/dist/index.es37.js +31 -249
- package/dist/index.es37.js.map +1 -1
- package/dist/index.es38.js +199 -27
- package/dist/index.es38.js.map +1 -1
- package/dist/index.es39.js +50 -198
- package/dist/index.es39.js.map +1 -1
- package/dist/index.es40.js +120 -45
- package/dist/index.es40.js.map +1 -1
- package/dist/index.es41.js +14 -132
- package/dist/index.es41.js.map +1 -1
- package/dist/index.es42.js +225 -19
- package/dist/index.es42.js.map +1 -1
- package/dist/index.es43.js +8 -229
- package/dist/index.es43.js.map +1 -1
- package/dist/index.es44.js +1190 -7
- package/dist/index.es44.js.map +1 -1
- package/dist/index.es45.js +6 -1191
- package/dist/index.es45.js.map +1 -1
- package/dist/index.es46.js +146 -6
- package/dist/index.es46.js.map +1 -1
- package/dist/index.es47.js +15 -146
- package/dist/index.es47.js.map +1 -1
- package/dist/index.es49.js +5 -93
- package/dist/index.es49.js.map +1 -1
- package/dist/index.es50.js +8 -4
- package/dist/index.es50.js.map +1 -1
- package/dist/index.es51.js +91 -33
- package/dist/index.es51.js.map +1 -1
- package/dist/index.es52.js +3 -71
- package/dist/index.es52.js.map +1 -1
- package/dist/index.es53.js +34 -36
- package/dist/index.es53.js.map +1 -1
- package/dist/index.es54.js +61 -295
- package/dist/index.es54.js.map +1 -1
- package/dist/index.es55.js +38 -9
- package/dist/index.es55.js.map +1 -1
- package/dist/index.es56.js +296 -81
- package/dist/index.es56.js.map +1 -1
- package/dist/index.es57.js +9 -8
- package/dist/index.es57.js.map +1 -1
- package/dist/index.es58.js +89 -13
- package/dist/index.es58.js.map +1 -1
- package/dist/index.es59.js +6 -141
- package/dist/index.es59.js.map +1 -1
- package/dist/index.es60.js +12 -297
- package/dist/index.es60.js.map +1 -1
- package/dist/index.es61.js +137 -60
- package/dist/index.es61.js.map +1 -1
- package/dist/index.es62.js +247 -160
- package/dist/index.es62.js.map +1 -1
- package/dist/index.es63.js +63 -31
- package/dist/index.es63.js.map +1 -1
- package/dist/index.es64.js +212 -8
- package/dist/index.es64.js.map +1 -1
- package/dist/index.es65.js +32 -10
- package/dist/index.es65.js.map +1 -1
- package/dist/index.es66.js +8 -186
- package/dist/index.es66.js.map +1 -1
- package/dist/index.es67.js +11 -23
- package/dist/index.es67.js.map +1 -1
- package/dist/index.es68.js +183 -1396
- package/dist/index.es68.js.map +1 -1
- package/dist/index.es69.js +24 -9
- package/dist/index.es69.js.map +1 -1
- package/dist/index.es70.js +1400 -8
- package/dist/index.es70.js.map +1 -1
- package/dist/index.es71.js +9 -6
- package/dist/index.es71.js.map +1 -1
- package/dist/index.es72.js +8 -163
- package/dist/index.es72.js.map +1 -1
- package/dist/index.es73.js +6 -672
- package/dist/index.es73.js.map +1 -1
- package/dist/index.es74.js +161 -10
- package/dist/index.es74.js.map +1 -1
- package/dist/index.es75.js +671 -39
- package/dist/index.es75.js.map +1 -1
- package/dist/index.es76.js +10 -32
- package/dist/index.es76.js.map +1 -1
- package/dist/index.es77.js +31 -223
- package/dist/index.es77.js.map +1 -1
- package/dist/index.es78.js +33 -29
- package/dist/index.es78.js.map +1 -1
- package/dist/index.es79.js +193 -36
- package/dist/index.es79.js.map +1 -1
- package/dist/index.es80.js +26 -72
- package/dist/index.es80.js.map +1 -1
- package/dist/index.es81.js +70 -47
- package/dist/index.es81.js.map +1 -1
- package/dist/index.es82.js +72 -26
- package/dist/index.es82.js.map +1 -1
- package/dist/index.es83.js +37 -28
- package/dist/index.es83.js.map +1 -1
- package/dist/index.es84.js +28 -55
- package/dist/index.es84.js.map +1 -1
- package/dist/index.es85.js +43 -13
- package/dist/index.es85.js.map +1 -1
- package/dist/index.es86.js +32 -132
- package/dist/index.es86.js.map +1 -1
- package/dist/index.es87.js +5 -21
- package/dist/index.es87.js.map +1 -1
- package/dist/index.es88.js +61 -170
- package/dist/index.es88.js.map +1 -1
- package/dist/index.es89.js +31 -235
- package/dist/index.es89.js.map +1 -1
- package/dist/index.es90.js +50 -348
- package/dist/index.es90.js.map +1 -1
- package/dist/index.es91.js +13 -137
- package/dist/index.es91.js.map +1 -1
- package/dist/index.es92.js +132 -65
- package/dist/index.es92.js.map +1 -1
- package/dist/index.es93.js +21 -37
- package/dist/index.es93.js.map +1 -1
- package/dist/index.es94.js +179 -34
- package/dist/index.es94.js.map +1 -1
- package/dist/index.es95.js +230 -155
- package/dist/index.es95.js.map +1 -1
- package/dist/index.es96.js +341 -189
- package/dist/index.es96.js.map +1 -1
- package/dist/index.es97.js +136 -13
- package/dist/index.es97.js.map +1 -1
- package/dist/index.es98.js +68 -28
- package/dist/index.es98.js.map +1 -1
- package/dist/index.es99.js +33 -30
- package/dist/index.es99.js.map +1 -1
- package/dist/langgraph-ui-components.css +107 -0
- package/dist/styles.css +1 -1
- package/package.json +8 -11
- package/dist/index.es48.js +0 -11
- package/dist/index.es48.js.map +0 -1
package/dist/index.es89.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es89.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/tracers/log_stream.js"],"sourcesContent":["import { __export } from \"../_virtual/rolldown_runtime.js\";\nimport { AIMessageChunk } from \"../messages/ai.js\";\nimport { applyPatch } from \"../utils/fast-json-patch/src/core.js\";\nimport \"../utils/fast-json-patch/index.js\";\nimport { BaseTracer } from \"./base.js\";\nimport { IterableReadableStream } from \"../utils/stream.js\";\n\n//#region src/tracers/log_stream.ts\nvar log_stream_exports = {};\n__export(log_stream_exports, {\n\tLogStreamCallbackHandler: () => LogStreamCallbackHandler,\n\tRunLog: () => RunLog,\n\tRunLogPatch: () => RunLogPatch,\n\tisLogStreamHandler: () => isLogStreamHandler\n});\n/**\n* List of jsonpatch JSONPatchOperations, which describe how to create the run state\n* from an empty dict. This is the minimal representation of the log, designed to\n* be serialized as JSON and sent over the wire to reconstruct the log on the other\n* side. Reconstruction of the state can be done with any jsonpatch-compliant library,\n* see https://jsonpatch.com for more information.\n*/\nvar RunLogPatch = class {\n\tops;\n\tconstructor(fields) {\n\t\tthis.ops = fields.ops ?? [];\n\t}\n\tconcat(other) {\n\t\tconst ops = this.ops.concat(other.ops);\n\t\tconst states = applyPatch({}, ops);\n\t\treturn new RunLog({\n\t\t\tops,\n\t\t\tstate: states[states.length - 1].newDocument\n\t\t});\n\t}\n};\nvar RunLog = class RunLog extends RunLogPatch {\n\tstate;\n\tconstructor(fields) {\n\t\tsuper(fields);\n\t\tthis.state = fields.state;\n\t}\n\tconcat(other) {\n\t\tconst ops = this.ops.concat(other.ops);\n\t\tconst states = applyPatch(this.state, other.ops);\n\t\treturn new RunLog({\n\t\t\tops,\n\t\t\tstate: states[states.length - 1].newDocument\n\t\t});\n\t}\n\tstatic fromRunLogPatch(patch) {\n\t\tconst states = applyPatch({}, patch.ops);\n\t\treturn new RunLog({\n\t\t\tops: patch.ops,\n\t\t\tstate: states[states.length - 1].newDocument\n\t\t});\n\t}\n};\nconst isLogStreamHandler = (handler) => handler.name === \"log_stream_tracer\";\n/**\n* Extract standardized inputs from a run.\n*\n* Standardizes the inputs based on the type of the runnable used.\n*\n* @param run - Run object\n* @param schemaFormat - The schema format to use.\n*\n* @returns Valid inputs are only dict. By conventions, inputs always represented\n* invocation using named arguments.\n* A null means that the input is not yet known!\n*/\nasync function _getStandardizedInputs(run, schemaFormat) {\n\tif (schemaFormat === \"original\") throw new Error(\"Do not assign inputs with original schema drop the key for now. When inputs are added to streamLog they should be added with standardized schema for streaming events.\");\n\tconst { inputs } = run;\n\tif ([\n\t\t\"retriever\",\n\t\t\"llm\",\n\t\t\"prompt\"\n\t].includes(run.run_type)) return inputs;\n\tif (Object.keys(inputs).length === 1 && inputs?.input === \"\") return void 0;\n\treturn inputs.input;\n}\nasync function _getStandardizedOutputs(run, schemaFormat) {\n\tconst { outputs } = run;\n\tif (schemaFormat === \"original\") return outputs;\n\tif ([\n\t\t\"retriever\",\n\t\t\"llm\",\n\t\t\"prompt\"\n\t].includes(run.run_type)) return outputs;\n\tif (outputs !== void 0 && Object.keys(outputs).length === 1 && outputs?.output !== void 0) return outputs.output;\n\treturn outputs;\n}\nfunction isChatGenerationChunk(x) {\n\treturn x !== void 0 && x.message !== void 0;\n}\n/**\n* Class that extends the `BaseTracer` class from the\n* `langchain.callbacks.tracers.base` module. It represents a callback\n* handler that logs the execution of runs and emits `RunLog` instances to a\n* `RunLogStream`.\n*/\nvar LogStreamCallbackHandler = class extends BaseTracer {\n\tautoClose = true;\n\tincludeNames;\n\tincludeTypes;\n\tincludeTags;\n\texcludeNames;\n\texcludeTypes;\n\texcludeTags;\n\t_schemaFormat = \"original\";\n\trootId;\n\tkeyMapByRunId = {};\n\tcounterMapByRunName = {};\n\ttransformStream;\n\twriter;\n\treceiveStream;\n\tname = \"log_stream_tracer\";\n\tlc_prefer_streaming = true;\n\tconstructor(fields) {\n\t\tsuper({\n\t\t\t_awaitHandler: true,\n\t\t\t...fields\n\t\t});\n\t\tthis.autoClose = fields?.autoClose ?? true;\n\t\tthis.includeNames = fields?.includeNames;\n\t\tthis.includeTypes = fields?.includeTypes;\n\t\tthis.includeTags = fields?.includeTags;\n\t\tthis.excludeNames = fields?.excludeNames;\n\t\tthis.excludeTypes = fields?.excludeTypes;\n\t\tthis.excludeTags = fields?.excludeTags;\n\t\tthis._schemaFormat = fields?._schemaFormat ?? this._schemaFormat;\n\t\tthis.transformStream = new TransformStream();\n\t\tthis.writer = this.transformStream.writable.getWriter();\n\t\tthis.receiveStream = IterableReadableStream.fromReadableStream(this.transformStream.readable);\n\t}\n\t[Symbol.asyncIterator]() {\n\t\treturn this.receiveStream;\n\t}\n\tasync persistRun(_run) {}\n\t_includeRun(run) {\n\t\tif (run.id === this.rootId) return false;\n\t\tconst runTags = run.tags ?? [];\n\t\tlet include = this.includeNames === void 0 && this.includeTags === void 0 && this.includeTypes === void 0;\n\t\tif (this.includeNames !== void 0) include = include || this.includeNames.includes(run.name);\n\t\tif (this.includeTypes !== void 0) include = include || this.includeTypes.includes(run.run_type);\n\t\tif (this.includeTags !== void 0) include = include || runTags.find((tag) => this.includeTags?.includes(tag)) !== void 0;\n\t\tif (this.excludeNames !== void 0) include = include && !this.excludeNames.includes(run.name);\n\t\tif (this.excludeTypes !== void 0) include = include && !this.excludeTypes.includes(run.run_type);\n\t\tif (this.excludeTags !== void 0) include = include && runTags.every((tag) => !this.excludeTags?.includes(tag));\n\t\treturn include;\n\t}\n\tasync *tapOutputIterable(runId, output) {\n\t\tfor await (const chunk of output) {\n\t\t\tif (runId !== this.rootId) {\n\t\t\t\tconst key = this.keyMapByRunId[runId];\n\t\t\t\tif (key) await this.writer.write(new RunLogPatch({ ops: [{\n\t\t\t\t\top: \"add\",\n\t\t\t\t\tpath: `/logs/${key}/streamed_output/-`,\n\t\t\t\t\tvalue: chunk\n\t\t\t\t}] }));\n\t\t\t}\n\t\t\tyield chunk;\n\t\t}\n\t}\n\tasync onRunCreate(run) {\n\t\tif (this.rootId === void 0) {\n\t\t\tthis.rootId = run.id;\n\t\t\tawait this.writer.write(new RunLogPatch({ ops: [{\n\t\t\t\top: \"replace\",\n\t\t\t\tpath: \"\",\n\t\t\t\tvalue: {\n\t\t\t\t\tid: run.id,\n\t\t\t\t\tname: run.name,\n\t\t\t\t\ttype: run.run_type,\n\t\t\t\t\tstreamed_output: [],\n\t\t\t\t\tfinal_output: void 0,\n\t\t\t\t\tlogs: {}\n\t\t\t\t}\n\t\t\t}] }));\n\t\t}\n\t\tif (!this._includeRun(run)) return;\n\t\tif (this.counterMapByRunName[run.name] === void 0) this.counterMapByRunName[run.name] = 0;\n\t\tthis.counterMapByRunName[run.name] += 1;\n\t\tconst count = this.counterMapByRunName[run.name];\n\t\tthis.keyMapByRunId[run.id] = count === 1 ? run.name : `${run.name}:${count}`;\n\t\tconst logEntry = {\n\t\t\tid: run.id,\n\t\t\tname: run.name,\n\t\t\ttype: run.run_type,\n\t\t\ttags: run.tags ?? [],\n\t\t\tmetadata: run.extra?.metadata ?? {},\n\t\t\tstart_time: new Date(run.start_time).toISOString(),\n\t\t\tstreamed_output: [],\n\t\t\tstreamed_output_str: [],\n\t\t\tfinal_output: void 0,\n\t\t\tend_time: void 0\n\t\t};\n\t\tif (this._schemaFormat === \"streaming_events\") logEntry.inputs = await _getStandardizedInputs(run, this._schemaFormat);\n\t\tawait this.writer.write(new RunLogPatch({ ops: [{\n\t\t\top: \"add\",\n\t\t\tpath: `/logs/${this.keyMapByRunId[run.id]}`,\n\t\t\tvalue: logEntry\n\t\t}] }));\n\t}\n\tasync onRunUpdate(run) {\n\t\ttry {\n\t\t\tconst runName = this.keyMapByRunId[run.id];\n\t\t\tif (runName === void 0) return;\n\t\t\tconst ops = [];\n\t\t\tif (this._schemaFormat === \"streaming_events\") ops.push({\n\t\t\t\top: \"replace\",\n\t\t\t\tpath: `/logs/${runName}/inputs`,\n\t\t\t\tvalue: await _getStandardizedInputs(run, this._schemaFormat)\n\t\t\t});\n\t\t\tops.push({\n\t\t\t\top: \"add\",\n\t\t\t\tpath: `/logs/${runName}/final_output`,\n\t\t\t\tvalue: await _getStandardizedOutputs(run, this._schemaFormat)\n\t\t\t});\n\t\t\tif (run.end_time !== void 0) ops.push({\n\t\t\t\top: \"add\",\n\t\t\t\tpath: `/logs/${runName}/end_time`,\n\t\t\t\tvalue: new Date(run.end_time).toISOString()\n\t\t\t});\n\t\t\tconst patch = new RunLogPatch({ ops });\n\t\t\tawait this.writer.write(patch);\n\t\t} finally {\n\t\t\tif (run.id === this.rootId) {\n\t\t\t\tconst patch = new RunLogPatch({ ops: [{\n\t\t\t\t\top: \"replace\",\n\t\t\t\t\tpath: \"/final_output\",\n\t\t\t\t\tvalue: await _getStandardizedOutputs(run, this._schemaFormat)\n\t\t\t\t}] });\n\t\t\t\tawait this.writer.write(patch);\n\t\t\t\tif (this.autoClose) await this.writer.close();\n\t\t\t}\n\t\t}\n\t}\n\tasync onLLMNewToken(run, token, kwargs) {\n\t\tconst runName = this.keyMapByRunId[run.id];\n\t\tif (runName === void 0) return;\n\t\tconst isChatModel = run.inputs.messages !== void 0;\n\t\tlet streamedOutputValue;\n\t\tif (isChatModel) if (isChatGenerationChunk(kwargs?.chunk)) streamedOutputValue = kwargs?.chunk;\n\t\telse streamedOutputValue = new AIMessageChunk({\n\t\t\tid: `run-${run.id}`,\n\t\t\tcontent: token\n\t\t});\n\t\telse streamedOutputValue = token;\n\t\tconst patch = new RunLogPatch({ ops: [{\n\t\t\top: \"add\",\n\t\t\tpath: `/logs/${runName}/streamed_output_str/-`,\n\t\t\tvalue: token\n\t\t}, {\n\t\t\top: \"add\",\n\t\t\tpath: `/logs/${runName}/streamed_output/-`,\n\t\t\tvalue: streamedOutputValue\n\t\t}] });\n\t\tawait this.writer.write(patch);\n\t}\n};\n\n//#endregion\nexport { LogStreamCallbackHandler, RunLog, RunLogPatch, isLogStreamHandler, log_stream_exports };\n//# sourceMappingURL=log_stream.js.map"],"names":["RunLog"],"mappings":";;;;;;AAQG,IAAC,qBAAqB,CAAA;AACzB,SAAS,oBAAoB;AAAA,EAC5B,0BAA0B,MAAM;AAAA,EAChC,QAAQ,MAAM;AAAA,EACd,aAAa,MAAM;AAAA,EACnB,oBAAoB,MAAM;AAC3B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E;AAAA,MACjB,SAAS;AAAA,IACZ,CAAG;AAAA,QACI,uBAAsB;AAC3B,UAAM,QAAQ,IAAI,YAAY,EAAE,KAAK,CAAC;AAAA,MACrC,IAAI;AAAA,MACJ,MAAM,SAAS,OAAO;AAAA,MACtB,OAAO;AAAA,IACV,GAAK;AAAA,MACF,IAAI;AAAA,MACJ,MAAM,SAAS,OAAO;AAAA,MACtB,OAAO;AAAA,IACV,CAAG,GAAG;AACJ,UAAM,KAAK,OAAO,MAAM,KAAK;AAAA,EAC9B;AACD;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index.es89.js","sources":["../node_modules/.pnpm/p-queue@9.1.0/node_modules/p-queue/dist/priority-queue.js"],"sourcesContent":["import lowerBound from './lower-bound.js';\nexport default class PriorityQueue {\n #queue = [];\n enqueue(run, options) {\n const { priority = 0, id, } = options ?? {};\n const element = {\n priority,\n id,\n run,\n };\n if (this.size === 0 || this.#queue[this.size - 1].priority >= priority) {\n this.#queue.push(element);\n return;\n }\n const index = lowerBound(this.#queue, element, (a, b) => b.priority - a.priority);\n this.#queue.splice(index, 0, element);\n }\n setPriority(id, priority) {\n const index = this.#queue.findIndex((element) => element.id === id);\n if (index === -1) {\n throw new ReferenceError(`No promise function with the id \"${id}\" exists in the queue.`);\n }\n const [item] = this.#queue.splice(index, 1);\n this.enqueue(item.run, { priority, id });\n }\n dequeue() {\n const item = this.#queue.shift();\n return item?.run;\n }\n filter(options) {\n return this.#queue.filter((element) => element.priority === options.priority).map((element) => element.run);\n }\n get size() {\n return this.#queue.length;\n }\n}\n"],"names":[],"mappings":";AACe,MAAM,cAAc;AAAA,EAC/B,SAAS,CAAA;AAAA,EACT,QAAQ,KAAK,SAAS;AAClB,UAAM,EAAE,WAAW,GAAG,GAAE,IAAM,WAAW,CAAA;AACzC,UAAM,UAAU;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,IACZ;AACQ,QAAI,KAAK,SAAS,KAAK,KAAK,OAAO,KAAK,OAAO,CAAC,EAAE,YAAY,UAAU;AACpE,WAAK,OAAO,KAAK,OAAO;AACxB;AAAA,IACJ;AACA,UAAM,QAAQ,WAAW,KAAK,QAAQ,SAAS,CAAC,GAAG,MAAM,EAAE,WAAW,EAAE,QAAQ;AAChF,SAAK,OAAO,OAAO,OAAO,GAAG,OAAO;AAAA,EACxC;AAAA,EACA,YAAY,IAAI,UAAU;AACtB,UAAM,QAAQ,KAAK,OAAO,UAAU,CAAC,YAAY,QAAQ,OAAO,EAAE;AAClE,QAAI,UAAU,IAAI;AACd,YAAM,IAAI,eAAe,oCAAoC,EAAE,wBAAwB;AAAA,IAC3F;AACA,UAAM,CAAC,IAAI,IAAI,KAAK,OAAO,OAAO,OAAO,CAAC;AAC1C,SAAK,QAAQ,KAAK,KAAK,EAAE,UAAU,IAAI;AAAA,EAC3C;AAAA,EACA,UAAU;AACN,UAAM,OAAO,KAAK,OAAO,MAAK;AAC9B,WAAO,MAAM;AAAA,EACjB;AAAA,EACA,OAAO,SAAS;AACZ,WAAO,KAAK,OAAO,OAAO,CAAC,YAAY,QAAQ,aAAa,QAAQ,QAAQ,EAAE,IAAI,CAAC,YAAY,QAAQ,GAAG;AAAA,EAC9G;AAAA,EACA,IAAI,OAAO;AACP,WAAO,KAAK,OAAO;AAAA,EACvB;AACJ;","x_google_ignoreList":[0]}
|
package/dist/index.es90.js
CHANGED
|
@@ -1,358 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
excludeNames;
|
|
18
|
-
excludeTypes;
|
|
19
|
-
excludeTags;
|
|
20
|
-
runInfoMap = /* @__PURE__ */ new Map();
|
|
21
|
-
tappedPromises = /* @__PURE__ */ new Map();
|
|
22
|
-
transformStream;
|
|
23
|
-
writer;
|
|
24
|
-
receiveStream;
|
|
25
|
-
readableStreamClosed = false;
|
|
26
|
-
name = "event_stream_tracer";
|
|
27
|
-
lc_prefer_streaming = true;
|
|
28
|
-
constructor(fields) {
|
|
29
|
-
super({
|
|
30
|
-
_awaitHandler: true,
|
|
31
|
-
...fields
|
|
32
|
-
});
|
|
33
|
-
this.autoClose = fields?.autoClose ?? true;
|
|
34
|
-
this.includeNames = fields?.includeNames;
|
|
35
|
-
this.includeTypes = fields?.includeTypes;
|
|
36
|
-
this.includeTags = fields?.includeTags;
|
|
37
|
-
this.excludeNames = fields?.excludeNames;
|
|
38
|
-
this.excludeTypes = fields?.excludeTypes;
|
|
39
|
-
this.excludeTags = fields?.excludeTags;
|
|
40
|
-
this.transformStream = new TransformStream({ flush: () => {
|
|
41
|
-
this.readableStreamClosed = true;
|
|
42
|
-
} });
|
|
43
|
-
this.writer = this.transformStream.writable.getWriter();
|
|
44
|
-
this.receiveStream = IterableReadableStream.fromReadableStream(this.transformStream.readable);
|
|
45
|
-
}
|
|
46
|
-
[Symbol.asyncIterator]() {
|
|
47
|
-
return this.receiveStream;
|
|
48
|
-
}
|
|
49
|
-
async persistRun(_run) {
|
|
50
|
-
}
|
|
51
|
-
_includeRun(run) {
|
|
52
|
-
const runTags = run.tags ?? [];
|
|
53
|
-
let include = this.includeNames === void 0 && this.includeTags === void 0 && this.includeTypes === void 0;
|
|
54
|
-
if (this.includeNames !== void 0) include = include || this.includeNames.includes(run.name);
|
|
55
|
-
if (this.includeTypes !== void 0) include = include || this.includeTypes.includes(run.runType);
|
|
56
|
-
if (this.includeTags !== void 0) include = include || runTags.find((tag) => this.includeTags?.includes(tag)) !== void 0;
|
|
57
|
-
if (this.excludeNames !== void 0) include = include && !this.excludeNames.includes(run.name);
|
|
58
|
-
if (this.excludeTypes !== void 0) include = include && !this.excludeTypes.includes(run.runType);
|
|
59
|
-
if (this.excludeTags !== void 0) include = include && runTags.every((tag) => !this.excludeTags?.includes(tag));
|
|
60
|
-
return include;
|
|
1
|
+
import { getGlobalAsyncLocalStorageInstance, _CONTEXT_VARIABLES_KEY, setGlobalAsyncLocalStorageInstance } from "./index.es110.js";
|
|
2
|
+
import { CallbackManager } from "./index.es111.js";
|
|
3
|
+
import "uuid";
|
|
4
|
+
import "./index.es112.js";
|
|
5
|
+
import "./index.es113.js";
|
|
6
|
+
import "./index.es114.js";
|
|
7
|
+
import { RunTree } from "./index.es115.js";
|
|
8
|
+
var MockAsyncLocalStorage = class {
|
|
9
|
+
getStore() {
|
|
10
|
+
return void 0;
|
|
11
|
+
}
|
|
12
|
+
run(_store, callback) {
|
|
13
|
+
return callback();
|
|
14
|
+
}
|
|
15
|
+
enterWith(_store) {
|
|
16
|
+
return void 0;
|
|
61
17
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
run_id: runId,
|
|
85
|
-
name: runInfo.name,
|
|
86
|
-
tags: runInfo.tags,
|
|
87
|
-
metadata: runInfo.metadata,
|
|
88
|
-
data: {}
|
|
89
|
-
};
|
|
90
|
-
await this.send({
|
|
91
|
-
...event,
|
|
92
|
-
data: { chunk: _formatOutputChunk(runInfo.runType, firstChunk.value) }
|
|
93
|
-
}, runInfo);
|
|
94
|
-
yield firstChunk.value;
|
|
95
|
-
for await (const chunk of outputStream) {
|
|
96
|
-
if (runInfo.runType !== "tool" && runInfo.runType !== "retriever") await this.send({
|
|
97
|
-
...event,
|
|
98
|
-
data: { chunk: _formatOutputChunk(runInfo.runType, chunk) }
|
|
99
|
-
}, runInfo);
|
|
100
|
-
yield chunk;
|
|
101
|
-
}
|
|
102
|
-
} finally {
|
|
103
|
-
tappedPromiseResolver?.();
|
|
104
|
-
}
|
|
105
|
-
} else {
|
|
106
|
-
yield firstChunk.value;
|
|
107
|
-
for await (const chunk of outputStream) yield chunk;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
async send(payload, run) {
|
|
111
|
-
if (this.readableStreamClosed) return;
|
|
112
|
-
if (this._includeRun(run)) await this.writer.write(payload);
|
|
113
|
-
}
|
|
114
|
-
async sendEndEvent(payload, run) {
|
|
115
|
-
const tappedPromise = this.tappedPromises.get(payload.run_id);
|
|
116
|
-
if (tappedPromise !== void 0) tappedPromise.then(() => {
|
|
117
|
-
this.send(payload, run);
|
|
18
|
+
};
|
|
19
|
+
const mockAsyncLocalStorage = new MockAsyncLocalStorage();
|
|
20
|
+
const LC_CHILD_KEY = /* @__PURE__ */ Symbol.for("lc:child_config");
|
|
21
|
+
var AsyncLocalStorageProvider = class {
|
|
22
|
+
getInstance() {
|
|
23
|
+
return getGlobalAsyncLocalStorageInstance() ?? mockAsyncLocalStorage;
|
|
24
|
+
}
|
|
25
|
+
getRunnableConfig() {
|
|
26
|
+
const storage = this.getInstance();
|
|
27
|
+
return storage.getStore()?.extra?.[LC_CHILD_KEY];
|
|
28
|
+
}
|
|
29
|
+
runWithConfig(config, callback, avoidCreatingRootRunTree) {
|
|
30
|
+
const callbackManager = CallbackManager._configureSync(config?.callbacks, void 0, config?.tags, void 0, config?.metadata);
|
|
31
|
+
const storage = this.getInstance();
|
|
32
|
+
const previousValue = storage.getStore();
|
|
33
|
+
const parentRunId = callbackManager?.getParentRunId();
|
|
34
|
+
const langChainTracer = callbackManager?.handlers?.find((handler) => handler?.name === "langchain_tracer");
|
|
35
|
+
let runTree;
|
|
36
|
+
if (langChainTracer && parentRunId) runTree = langChainTracer.getRunTreeWithTracingConfig(parentRunId);
|
|
37
|
+
else if (!avoidCreatingRootRunTree) runTree = new RunTree({
|
|
38
|
+
name: "<runnable_lambda>",
|
|
39
|
+
tracingEnabled: false
|
|
118
40
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const runName = assignName(run);
|
|
123
|
-
const runType = run.inputs.messages !== void 0 ? "chat_model" : "llm";
|
|
124
|
-
const runInfo = {
|
|
125
|
-
tags: run.tags ?? [],
|
|
126
|
-
metadata: run.extra?.metadata ?? {},
|
|
127
|
-
name: runName,
|
|
128
|
-
runType,
|
|
129
|
-
inputs: run.inputs
|
|
130
|
-
};
|
|
131
|
-
this.runInfoMap.set(run.id, runInfo);
|
|
132
|
-
const eventName = `on_${runType}_start`;
|
|
133
|
-
await this.send({
|
|
134
|
-
event: eventName,
|
|
135
|
-
data: { input: run.inputs },
|
|
136
|
-
name: runName,
|
|
137
|
-
tags: run.tags ?? [],
|
|
138
|
-
run_id: run.id,
|
|
139
|
-
metadata: run.extra?.metadata ?? {}
|
|
140
|
-
}, runInfo);
|
|
141
|
-
}
|
|
142
|
-
async onLLMNewToken(run, token, kwargs) {
|
|
143
|
-
const runInfo = this.runInfoMap.get(run.id);
|
|
144
|
-
let chunk;
|
|
145
|
-
let eventName;
|
|
146
|
-
if (runInfo === void 0) throw new Error(`onLLMNewToken: Run ID ${run.id} not found in run map.`);
|
|
147
|
-
if (this.runInfoMap.size === 1) return;
|
|
148
|
-
if (runInfo.runType === "chat_model") {
|
|
149
|
-
eventName = "on_chat_model_stream";
|
|
150
|
-
if (kwargs?.chunk === void 0) chunk = new AIMessageChunk({
|
|
151
|
-
content: token,
|
|
152
|
-
id: `run-${run.id}`
|
|
153
|
-
});
|
|
154
|
-
else chunk = kwargs.chunk.message;
|
|
155
|
-
} else if (runInfo.runType === "llm") {
|
|
156
|
-
eventName = "on_llm_stream";
|
|
157
|
-
if (kwargs?.chunk === void 0) chunk = new GenerationChunk({ text: token });
|
|
158
|
-
else chunk = kwargs.chunk;
|
|
159
|
-
} else throw new Error(`Unexpected run type ${runInfo.runType}`);
|
|
160
|
-
await this.send({
|
|
161
|
-
event: eventName,
|
|
162
|
-
data: { chunk },
|
|
163
|
-
run_id: run.id,
|
|
164
|
-
name: runInfo.name,
|
|
165
|
-
tags: runInfo.tags,
|
|
166
|
-
metadata: runInfo.metadata
|
|
167
|
-
}, runInfo);
|
|
168
|
-
}
|
|
169
|
-
async onLLMEnd(run) {
|
|
170
|
-
const runInfo = this.runInfoMap.get(run.id);
|
|
171
|
-
this.runInfoMap.delete(run.id);
|
|
172
|
-
let eventName;
|
|
173
|
-
if (runInfo === void 0) throw new Error(`onLLMEnd: Run ID ${run.id} not found in run map.`);
|
|
174
|
-
const generations = run.outputs?.generations;
|
|
175
|
-
let output;
|
|
176
|
-
if (runInfo.runType === "chat_model") {
|
|
177
|
-
for (const generation of generations ?? []) {
|
|
178
|
-
if (output !== void 0) break;
|
|
179
|
-
output = generation[0]?.message;
|
|
180
|
-
}
|
|
181
|
-
eventName = "on_chat_model_end";
|
|
182
|
-
} else if (runInfo.runType === "llm") {
|
|
183
|
-
output = {
|
|
184
|
-
generations: generations?.map((generation) => {
|
|
185
|
-
return generation.map((chunk) => {
|
|
186
|
-
return {
|
|
187
|
-
text: chunk.text,
|
|
188
|
-
generationInfo: chunk.generationInfo
|
|
189
|
-
};
|
|
190
|
-
});
|
|
191
|
-
}),
|
|
192
|
-
llmOutput: run.outputs?.llmOutput ?? {}
|
|
193
|
-
};
|
|
194
|
-
eventName = "on_llm_end";
|
|
195
|
-
} else throw new Error(`onLLMEnd: Unexpected run type: ${runInfo.runType}`);
|
|
196
|
-
await this.sendEndEvent({
|
|
197
|
-
event: eventName,
|
|
198
|
-
data: {
|
|
199
|
-
output,
|
|
200
|
-
input: runInfo.inputs
|
|
201
|
-
},
|
|
202
|
-
run_id: run.id,
|
|
203
|
-
name: runInfo.name,
|
|
204
|
-
tags: runInfo.tags,
|
|
205
|
-
metadata: runInfo.metadata
|
|
206
|
-
}, runInfo);
|
|
207
|
-
}
|
|
208
|
-
async onChainStart(run) {
|
|
209
|
-
const runName = assignName(run);
|
|
210
|
-
const runType = run.run_type ?? "chain";
|
|
211
|
-
const runInfo = {
|
|
212
|
-
tags: run.tags ?? [],
|
|
213
|
-
metadata: run.extra?.metadata ?? {},
|
|
214
|
-
name: runName,
|
|
215
|
-
runType: run.run_type
|
|
41
|
+
if (runTree) runTree.extra = {
|
|
42
|
+
...runTree.extra,
|
|
43
|
+
[LC_CHILD_KEY]: config
|
|
216
44
|
};
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
runInfo.inputs = {};
|
|
221
|
-
} else if (run.inputs.input !== void 0) {
|
|
222
|
-
eventData.input = run.inputs.input;
|
|
223
|
-
runInfo.inputs = run.inputs.input;
|
|
224
|
-
} else {
|
|
225
|
-
eventData.input = run.inputs;
|
|
226
|
-
runInfo.inputs = run.inputs;
|
|
45
|
+
if (previousValue !== void 0 && previousValue[_CONTEXT_VARIABLES_KEY] !== void 0) {
|
|
46
|
+
if (runTree === void 0) runTree = {};
|
|
47
|
+
runTree[_CONTEXT_VARIABLES_KEY] = previousValue[_CONTEXT_VARIABLES_KEY];
|
|
227
48
|
}
|
|
228
|
-
|
|
229
|
-
await this.send({
|
|
230
|
-
event: `on_${runType}_start`,
|
|
231
|
-
data: eventData,
|
|
232
|
-
name: runName,
|
|
233
|
-
tags: run.tags ?? [],
|
|
234
|
-
run_id: run.id,
|
|
235
|
-
metadata: run.extra?.metadata ?? {}
|
|
236
|
-
}, runInfo);
|
|
237
|
-
}
|
|
238
|
-
async onChainEnd(run) {
|
|
239
|
-
const runInfo = this.runInfoMap.get(run.id);
|
|
240
|
-
this.runInfoMap.delete(run.id);
|
|
241
|
-
if (runInfo === void 0) throw new Error(`onChainEnd: Run ID ${run.id} not found in run map.`);
|
|
242
|
-
const eventName = `on_${run.run_type}_end`;
|
|
243
|
-
const inputs = run.inputs ?? runInfo.inputs ?? {};
|
|
244
|
-
const outputs = run.outputs?.output ?? run.outputs;
|
|
245
|
-
const data = {
|
|
246
|
-
output: outputs,
|
|
247
|
-
input: inputs
|
|
248
|
-
};
|
|
249
|
-
if (inputs.input && Object.keys(inputs).length === 1) {
|
|
250
|
-
data.input = inputs.input;
|
|
251
|
-
runInfo.inputs = inputs.input;
|
|
252
|
-
}
|
|
253
|
-
await this.sendEndEvent({
|
|
254
|
-
event: eventName,
|
|
255
|
-
data,
|
|
256
|
-
run_id: run.id,
|
|
257
|
-
name: runInfo.name,
|
|
258
|
-
tags: runInfo.tags,
|
|
259
|
-
metadata: runInfo.metadata ?? {}
|
|
260
|
-
}, runInfo);
|
|
261
|
-
}
|
|
262
|
-
async onToolStart(run) {
|
|
263
|
-
const runName = assignName(run);
|
|
264
|
-
const runInfo = {
|
|
265
|
-
tags: run.tags ?? [],
|
|
266
|
-
metadata: run.extra?.metadata ?? {},
|
|
267
|
-
name: runName,
|
|
268
|
-
runType: "tool",
|
|
269
|
-
inputs: run.inputs ?? {}
|
|
270
|
-
};
|
|
271
|
-
this.runInfoMap.set(run.id, runInfo);
|
|
272
|
-
await this.send({
|
|
273
|
-
event: "on_tool_start",
|
|
274
|
-
data: { input: run.inputs ?? {} },
|
|
275
|
-
name: runName,
|
|
276
|
-
run_id: run.id,
|
|
277
|
-
tags: run.tags ?? [],
|
|
278
|
-
metadata: run.extra?.metadata ?? {}
|
|
279
|
-
}, runInfo);
|
|
49
|
+
return storage.run(runTree, callback);
|
|
280
50
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
this.runInfoMap.delete(run.id);
|
|
284
|
-
if (runInfo === void 0) throw new Error(`onToolEnd: Run ID ${run.id} not found in run map.`);
|
|
285
|
-
if (runInfo.inputs === void 0) throw new Error(`onToolEnd: Run ID ${run.id} is a tool call, and is expected to have traced inputs.`);
|
|
286
|
-
const output = run.outputs?.output === void 0 ? run.outputs : run.outputs.output;
|
|
287
|
-
await this.sendEndEvent({
|
|
288
|
-
event: "on_tool_end",
|
|
289
|
-
data: {
|
|
290
|
-
output,
|
|
291
|
-
input: runInfo.inputs
|
|
292
|
-
},
|
|
293
|
-
run_id: run.id,
|
|
294
|
-
name: runInfo.name,
|
|
295
|
-
tags: runInfo.tags,
|
|
296
|
-
metadata: runInfo.metadata
|
|
297
|
-
}, runInfo);
|
|
298
|
-
}
|
|
299
|
-
async onRetrieverStart(run) {
|
|
300
|
-
const runName = assignName(run);
|
|
301
|
-
const runType = "retriever";
|
|
302
|
-
const runInfo = {
|
|
303
|
-
tags: run.tags ?? [],
|
|
304
|
-
metadata: run.extra?.metadata ?? {},
|
|
305
|
-
name: runName,
|
|
306
|
-
runType,
|
|
307
|
-
inputs: { query: run.inputs.query }
|
|
308
|
-
};
|
|
309
|
-
this.runInfoMap.set(run.id, runInfo);
|
|
310
|
-
await this.send({
|
|
311
|
-
event: "on_retriever_start",
|
|
312
|
-
data: { input: { query: run.inputs.query } },
|
|
313
|
-
name: runName,
|
|
314
|
-
tags: run.tags ?? [],
|
|
315
|
-
run_id: run.id,
|
|
316
|
-
metadata: run.extra?.metadata ?? {}
|
|
317
|
-
}, runInfo);
|
|
318
|
-
}
|
|
319
|
-
async onRetrieverEnd(run) {
|
|
320
|
-
const runInfo = this.runInfoMap.get(run.id);
|
|
321
|
-
this.runInfoMap.delete(run.id);
|
|
322
|
-
if (runInfo === void 0) throw new Error(`onRetrieverEnd: Run ID ${run.id} not found in run map.`);
|
|
323
|
-
await this.sendEndEvent({
|
|
324
|
-
event: "on_retriever_end",
|
|
325
|
-
data: {
|
|
326
|
-
output: run.outputs?.documents ?? run.outputs,
|
|
327
|
-
input: runInfo.inputs
|
|
328
|
-
},
|
|
329
|
-
run_id: run.id,
|
|
330
|
-
name: runInfo.name,
|
|
331
|
-
tags: runInfo.tags,
|
|
332
|
-
metadata: runInfo.metadata
|
|
333
|
-
}, runInfo);
|
|
334
|
-
}
|
|
335
|
-
async handleCustomEvent(eventName, data, runId) {
|
|
336
|
-
const runInfo = this.runInfoMap.get(runId);
|
|
337
|
-
if (runInfo === void 0) throw new Error(`handleCustomEvent: Run ID ${runId} not found in run map.`);
|
|
338
|
-
await this.send({
|
|
339
|
-
event: "on_custom_event",
|
|
340
|
-
run_id: runId,
|
|
341
|
-
name: eventName,
|
|
342
|
-
tags: runInfo.tags,
|
|
343
|
-
metadata: runInfo.metadata,
|
|
344
|
-
data
|
|
345
|
-
}, runInfo);
|
|
346
|
-
}
|
|
347
|
-
async finish() {
|
|
348
|
-
const pendingPromises = [...this.tappedPromises.values()];
|
|
349
|
-
Promise.all(pendingPromises).finally(() => {
|
|
350
|
-
this.writer.close();
|
|
351
|
-
});
|
|
51
|
+
initializeGlobalInstance(instance) {
|
|
52
|
+
if (getGlobalAsyncLocalStorageInstance() === void 0) setGlobalAsyncLocalStorageInstance(instance);
|
|
352
53
|
}
|
|
353
54
|
};
|
|
55
|
+
const AsyncLocalStorageProviderSingleton = new AsyncLocalStorageProvider();
|
|
354
56
|
export {
|
|
355
|
-
|
|
356
|
-
|
|
57
|
+
AsyncLocalStorageProviderSingleton,
|
|
58
|
+
MockAsyncLocalStorage
|
|
357
59
|
};
|
|
358
60
|
//# sourceMappingURL=index.es90.js.map
|
package/dist/index.es90.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es90.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/tracers/event_stream.js"],"sourcesContent":["import { AIMessageChunk } from \"../messages/ai.js\";\nimport { BaseTracer } from \"./base.js\";\nimport { IterableReadableStream } from \"../utils/stream.js\";\nimport { GenerationChunk } from \"../outputs.js\";\n\n//#region src/tracers/event_stream.ts\nfunction assignName({ name, serialized }) {\n\tif (name !== void 0) return name;\n\tif (serialized?.name !== void 0) return serialized.name;\n\telse if (serialized?.id !== void 0 && Array.isArray(serialized?.id)) return serialized.id[serialized.id.length - 1];\n\treturn \"Unnamed\";\n}\nconst isStreamEventsHandler = (handler) => handler.name === \"event_stream_tracer\";\n/**\n* Class that extends the `BaseTracer` class from the\n* `langchain.callbacks.tracers.base` module. It represents a callback\n* handler that logs the execution of runs and emits `RunLog` instances to a\n* `RunLogStream`.\n*/\nvar EventStreamCallbackHandler = class extends BaseTracer {\n\tautoClose = true;\n\tincludeNames;\n\tincludeTypes;\n\tincludeTags;\n\texcludeNames;\n\texcludeTypes;\n\texcludeTags;\n\trunInfoMap = /* @__PURE__ */ new Map();\n\ttappedPromises = /* @__PURE__ */ new Map();\n\ttransformStream;\n\twriter;\n\treceiveStream;\n\treadableStreamClosed = false;\n\tname = \"event_stream_tracer\";\n\tlc_prefer_streaming = true;\n\tconstructor(fields) {\n\t\tsuper({\n\t\t\t_awaitHandler: true,\n\t\t\t...fields\n\t\t});\n\t\tthis.autoClose = fields?.autoClose ?? true;\n\t\tthis.includeNames = fields?.includeNames;\n\t\tthis.includeTypes = fields?.includeTypes;\n\t\tthis.includeTags = fields?.includeTags;\n\t\tthis.excludeNames = fields?.excludeNames;\n\t\tthis.excludeTypes = fields?.excludeTypes;\n\t\tthis.excludeTags = fields?.excludeTags;\n\t\tthis.transformStream = new TransformStream({ flush: () => {\n\t\t\tthis.readableStreamClosed = true;\n\t\t} });\n\t\tthis.writer = this.transformStream.writable.getWriter();\n\t\tthis.receiveStream = IterableReadableStream.fromReadableStream(this.transformStream.readable);\n\t}\n\t[Symbol.asyncIterator]() {\n\t\treturn this.receiveStream;\n\t}\n\tasync persistRun(_run) {}\n\t_includeRun(run) {\n\t\tconst runTags = run.tags ?? [];\n\t\tlet include = this.includeNames === void 0 && this.includeTags === void 0 && this.includeTypes === void 0;\n\t\tif (this.includeNames !== void 0) include = include || this.includeNames.includes(run.name);\n\t\tif (this.includeTypes !== void 0) include = include || this.includeTypes.includes(run.runType);\n\t\tif (this.includeTags !== void 0) include = include || runTags.find((tag) => this.includeTags?.includes(tag)) !== void 0;\n\t\tif (this.excludeNames !== void 0) include = include && !this.excludeNames.includes(run.name);\n\t\tif (this.excludeTypes !== void 0) include = include && !this.excludeTypes.includes(run.runType);\n\t\tif (this.excludeTags !== void 0) include = include && runTags.every((tag) => !this.excludeTags?.includes(tag));\n\t\treturn include;\n\t}\n\tasync *tapOutputIterable(runId, outputStream) {\n\t\tconst firstChunk = await outputStream.next();\n\t\tif (firstChunk.done) return;\n\t\tconst runInfo = this.runInfoMap.get(runId);\n\t\tif (runInfo === void 0) {\n\t\t\tyield firstChunk.value;\n\t\t\treturn;\n\t\t}\n\t\tfunction _formatOutputChunk(eventType, data) {\n\t\t\tif (eventType === \"llm\" && typeof data === \"string\") return new GenerationChunk({ text: data });\n\t\t\treturn data;\n\t\t}\n\t\tlet tappedPromise = this.tappedPromises.get(runId);\n\t\tif (tappedPromise === void 0) {\n\t\t\tlet tappedPromiseResolver;\n\t\t\ttappedPromise = new Promise((resolve) => {\n\t\t\t\ttappedPromiseResolver = resolve;\n\t\t\t});\n\t\t\tthis.tappedPromises.set(runId, tappedPromise);\n\t\t\ttry {\n\t\t\t\tconst event = {\n\t\t\t\t\tevent: `on_${runInfo.runType}_stream`,\n\t\t\t\t\trun_id: runId,\n\t\t\t\t\tname: runInfo.name,\n\t\t\t\t\ttags: runInfo.tags,\n\t\t\t\t\tmetadata: runInfo.metadata,\n\t\t\t\t\tdata: {}\n\t\t\t\t};\n\t\t\t\tawait this.send({\n\t\t\t\t\t...event,\n\t\t\t\t\tdata: { chunk: _formatOutputChunk(runInfo.runType, firstChunk.value) }\n\t\t\t\t}, runInfo);\n\t\t\t\tyield firstChunk.value;\n\t\t\t\tfor await (const chunk of outputStream) {\n\t\t\t\t\tif (runInfo.runType !== \"tool\" && runInfo.runType !== \"retriever\") await this.send({\n\t\t\t\t\t\t...event,\n\t\t\t\t\t\tdata: { chunk: _formatOutputChunk(runInfo.runType, chunk) }\n\t\t\t\t\t}, runInfo);\n\t\t\t\t\tyield chunk;\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\ttappedPromiseResolver?.();\n\t\t\t}\n\t\t} else {\n\t\t\tyield firstChunk.value;\n\t\t\tfor await (const chunk of outputStream) yield chunk;\n\t\t}\n\t}\n\tasync send(payload, run) {\n\t\tif (this.readableStreamClosed) return;\n\t\tif (this._includeRun(run)) await this.writer.write(payload);\n\t}\n\tasync sendEndEvent(payload, run) {\n\t\tconst tappedPromise = this.tappedPromises.get(payload.run_id);\n\t\tif (tappedPromise !== void 0) tappedPromise.then(() => {\n\t\t\tthis.send(payload, run);\n\t\t});\n\t\telse await this.send(payload, run);\n\t}\n\tasync onLLMStart(run) {\n\t\tconst runName = assignName(run);\n\t\tconst runType = run.inputs.messages !== void 0 ? \"chat_model\" : \"llm\";\n\t\tconst runInfo = {\n\t\t\ttags: run.tags ?? [],\n\t\t\tmetadata: run.extra?.metadata ?? {},\n\t\t\tname: runName,\n\t\t\trunType,\n\t\t\tinputs: run.inputs\n\t\t};\n\t\tthis.runInfoMap.set(run.id, runInfo);\n\t\tconst eventName = `on_${runType}_start`;\n\t\tawait this.send({\n\t\t\tevent: eventName,\n\t\t\tdata: { input: run.inputs },\n\t\t\tname: runName,\n\t\t\ttags: run.tags ?? [],\n\t\t\trun_id: run.id,\n\t\t\tmetadata: run.extra?.metadata ?? {}\n\t\t}, runInfo);\n\t}\n\tasync onLLMNewToken(run, token, kwargs) {\n\t\tconst runInfo = this.runInfoMap.get(run.id);\n\t\tlet chunk;\n\t\tlet eventName;\n\t\tif (runInfo === void 0) throw new Error(`onLLMNewToken: Run ID ${run.id} not found in run map.`);\n\t\tif (this.runInfoMap.size === 1) return;\n\t\tif (runInfo.runType === \"chat_model\") {\n\t\t\teventName = \"on_chat_model_stream\";\n\t\t\tif (kwargs?.chunk === void 0) chunk = new AIMessageChunk({\n\t\t\t\tcontent: token,\n\t\t\t\tid: `run-${run.id}`\n\t\t\t});\n\t\t\telse chunk = kwargs.chunk.message;\n\t\t} else if (runInfo.runType === \"llm\") {\n\t\t\teventName = \"on_llm_stream\";\n\t\t\tif (kwargs?.chunk === void 0) chunk = new GenerationChunk({ text: token });\n\t\t\telse chunk = kwargs.chunk;\n\t\t} else throw new Error(`Unexpected run type ${runInfo.runType}`);\n\t\tawait this.send({\n\t\t\tevent: eventName,\n\t\t\tdata: { chunk },\n\t\t\trun_id: run.id,\n\t\t\tname: runInfo.name,\n\t\t\ttags: runInfo.tags,\n\t\t\tmetadata: runInfo.metadata\n\t\t}, runInfo);\n\t}\n\tasync onLLMEnd(run) {\n\t\tconst runInfo = this.runInfoMap.get(run.id);\n\t\tthis.runInfoMap.delete(run.id);\n\t\tlet eventName;\n\t\tif (runInfo === void 0) throw new Error(`onLLMEnd: Run ID ${run.id} not found in run map.`);\n\t\tconst generations = run.outputs?.generations;\n\t\tlet output;\n\t\tif (runInfo.runType === \"chat_model\") {\n\t\t\tfor (const generation of generations ?? []) {\n\t\t\t\tif (output !== void 0) break;\n\t\t\t\toutput = generation[0]?.message;\n\t\t\t}\n\t\t\teventName = \"on_chat_model_end\";\n\t\t} else if (runInfo.runType === \"llm\") {\n\t\t\toutput = {\n\t\t\t\tgenerations: generations?.map((generation) => {\n\t\t\t\t\treturn generation.map((chunk) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttext: chunk.text,\n\t\t\t\t\t\t\tgenerationInfo: chunk.generationInfo\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t\t\tllmOutput: run.outputs?.llmOutput ?? {}\n\t\t\t};\n\t\t\teventName = \"on_llm_end\";\n\t\t} else throw new Error(`onLLMEnd: Unexpected run type: ${runInfo.runType}`);\n\t\tawait this.sendEndEvent({\n\t\t\tevent: eventName,\n\t\t\tdata: {\n\t\t\t\toutput,\n\t\t\t\tinput: runInfo.inputs\n\t\t\t},\n\t\t\trun_id: run.id,\n\t\t\tname: runInfo.name,\n\t\t\ttags: runInfo.tags,\n\t\t\tmetadata: runInfo.metadata\n\t\t}, runInfo);\n\t}\n\tasync onChainStart(run) {\n\t\tconst runName = assignName(run);\n\t\tconst runType = run.run_type ?? \"chain\";\n\t\tconst runInfo = {\n\t\t\ttags: run.tags ?? [],\n\t\t\tmetadata: run.extra?.metadata ?? {},\n\t\t\tname: runName,\n\t\t\trunType: run.run_type\n\t\t};\n\t\tlet eventData = {};\n\t\tif (run.inputs.input === \"\" && Object.keys(run.inputs).length === 1) {\n\t\t\teventData = {};\n\t\t\trunInfo.inputs = {};\n\t\t} else if (run.inputs.input !== void 0) {\n\t\t\teventData.input = run.inputs.input;\n\t\t\trunInfo.inputs = run.inputs.input;\n\t\t} else {\n\t\t\teventData.input = run.inputs;\n\t\t\trunInfo.inputs = run.inputs;\n\t\t}\n\t\tthis.runInfoMap.set(run.id, runInfo);\n\t\tawait this.send({\n\t\t\tevent: `on_${runType}_start`,\n\t\t\tdata: eventData,\n\t\t\tname: runName,\n\t\t\ttags: run.tags ?? [],\n\t\t\trun_id: run.id,\n\t\t\tmetadata: run.extra?.metadata ?? {}\n\t\t}, runInfo);\n\t}\n\tasync onChainEnd(run) {\n\t\tconst runInfo = this.runInfoMap.get(run.id);\n\t\tthis.runInfoMap.delete(run.id);\n\t\tif (runInfo === void 0) throw new Error(`onChainEnd: Run ID ${run.id} not found in run map.`);\n\t\tconst eventName = `on_${run.run_type}_end`;\n\t\tconst inputs = run.inputs ?? runInfo.inputs ?? {};\n\t\tconst outputs = run.outputs?.output ?? run.outputs;\n\t\tconst data = {\n\t\t\toutput: outputs,\n\t\t\tinput: inputs\n\t\t};\n\t\tif (inputs.input && Object.keys(inputs).length === 1) {\n\t\t\tdata.input = inputs.input;\n\t\t\trunInfo.inputs = inputs.input;\n\t\t}\n\t\tawait this.sendEndEvent({\n\t\t\tevent: eventName,\n\t\t\tdata,\n\t\t\trun_id: run.id,\n\t\t\tname: runInfo.name,\n\t\t\ttags: runInfo.tags,\n\t\t\tmetadata: runInfo.metadata ?? {}\n\t\t}, runInfo);\n\t}\n\tasync onToolStart(run) {\n\t\tconst runName = assignName(run);\n\t\tconst runInfo = {\n\t\t\ttags: run.tags ?? [],\n\t\t\tmetadata: run.extra?.metadata ?? {},\n\t\t\tname: runName,\n\t\t\trunType: \"tool\",\n\t\t\tinputs: run.inputs ?? {}\n\t\t};\n\t\tthis.runInfoMap.set(run.id, runInfo);\n\t\tawait this.send({\n\t\t\tevent: \"on_tool_start\",\n\t\t\tdata: { input: run.inputs ?? {} },\n\t\t\tname: runName,\n\t\t\trun_id: run.id,\n\t\t\ttags: run.tags ?? [],\n\t\t\tmetadata: run.extra?.metadata ?? {}\n\t\t}, runInfo);\n\t}\n\tasync onToolEnd(run) {\n\t\tconst runInfo = this.runInfoMap.get(run.id);\n\t\tthis.runInfoMap.delete(run.id);\n\t\tif (runInfo === void 0) throw new Error(`onToolEnd: Run ID ${run.id} not found in run map.`);\n\t\tif (runInfo.inputs === void 0) throw new Error(`onToolEnd: Run ID ${run.id} is a tool call, and is expected to have traced inputs.`);\n\t\tconst output = run.outputs?.output === void 0 ? run.outputs : run.outputs.output;\n\t\tawait this.sendEndEvent({\n\t\t\tevent: \"on_tool_end\",\n\t\t\tdata: {\n\t\t\t\toutput,\n\t\t\t\tinput: runInfo.inputs\n\t\t\t},\n\t\t\trun_id: run.id,\n\t\t\tname: runInfo.name,\n\t\t\ttags: runInfo.tags,\n\t\t\tmetadata: runInfo.metadata\n\t\t}, runInfo);\n\t}\n\tasync onRetrieverStart(run) {\n\t\tconst runName = assignName(run);\n\t\tconst runType = \"retriever\";\n\t\tconst runInfo = {\n\t\t\ttags: run.tags ?? [],\n\t\t\tmetadata: run.extra?.metadata ?? {},\n\t\t\tname: runName,\n\t\t\trunType,\n\t\t\tinputs: { query: run.inputs.query }\n\t\t};\n\t\tthis.runInfoMap.set(run.id, runInfo);\n\t\tawait this.send({\n\t\t\tevent: \"on_retriever_start\",\n\t\t\tdata: { input: { query: run.inputs.query } },\n\t\t\tname: runName,\n\t\t\ttags: run.tags ?? [],\n\t\t\trun_id: run.id,\n\t\t\tmetadata: run.extra?.metadata ?? {}\n\t\t}, runInfo);\n\t}\n\tasync onRetrieverEnd(run) {\n\t\tconst runInfo = this.runInfoMap.get(run.id);\n\t\tthis.runInfoMap.delete(run.id);\n\t\tif (runInfo === void 0) throw new Error(`onRetrieverEnd: Run ID ${run.id} not found in run map.`);\n\t\tawait this.sendEndEvent({\n\t\t\tevent: \"on_retriever_end\",\n\t\t\tdata: {\n\t\t\t\toutput: run.outputs?.documents ?? run.outputs,\n\t\t\t\tinput: runInfo.inputs\n\t\t\t},\n\t\t\trun_id: run.id,\n\t\t\tname: runInfo.name,\n\t\t\ttags: runInfo.tags,\n\t\t\tmetadata: runInfo.metadata\n\t\t}, runInfo);\n\t}\n\tasync handleCustomEvent(eventName, data, runId) {\n\t\tconst runInfo = this.runInfoMap.get(runId);\n\t\tif (runInfo === void 0) throw new Error(`handleCustomEvent: Run ID ${runId} not found in run map.`);\n\t\tawait this.send({\n\t\t\tevent: \"on_custom_event\",\n\t\t\trun_id: runId,\n\t\t\tname: eventName,\n\t\t\ttags: runInfo.tags,\n\t\t\tmetadata: runInfo.metadata,\n\t\t\tdata\n\t\t}, runInfo);\n\t}\n\tasync finish() {\n\t\tconst pendingPromises = [...this.tappedPromises.values()];\n\t\tPromise.all(pendingPromises).finally(() => {\n\t\t\tthis.writer.close();\n\t\t});\n\t}\n};\n\n//#endregion\nexport { EventStreamCallbackHandler, isStreamEventsHandler };\n//# sourceMappingURL=event_stream.js.map"],"names":[],"mappings":";;;;AAMA,SAAS,WAAW,EAAE,MAAM,cAAc;AACzC,MAAI,SAAS,OAAQ,QAAO;AAC5B,MAAI,YAAY,SAAS,OAAQ,QAAO,WAAW;AAAA,WAC1C,YAAY,OAAO,UAAU,MAAM,QAAQ,YAAY,EAAE,EAAG,QAAO,WAAW,GAAG,WAAW,GAAG,SAAS,CAAC;AAClH,SAAO;AACR;AACK,MAAC,wBAAwB,CAAC,YAAY,QAAQ,SAAS;AAOzD,IAAC,6BAA6B,cAAc,WAAW;AAAA,EACzD,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAA6B,oBAAI,IAAG;AAAA,EACpC,iBAAiC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;AAAA,EACA,MAAM,eAAe,KAAK;AACzB,UAAM,UAAU,KAAK,WAAW,IAAI,IAAI,EAAE;AAC1C,SAAK,WAAW,OAAO,IAAI,EAAE;AAC7B,QAAI,YAAY,OAAQ,OAAM,IAAI,MAAM,0BAA0B,IAAI,EAAE,wBAAwB;AAChG,UAAM,KAAK,aAAa;AAAA,MACvB,OAAO;AAAA,MACP,MAAM;AAAA,QACL,QAAQ,IAAI,SAAS,aAAa,IAAI;AAAA,QACtC,OAAO,QAAQ;AAAA,MACnB;AAAA,MACG,QAAQ,IAAI;AAAA,MACZ,MAAM,QAAQ;AAAA,MACd,MAAM,QAAQ;AAAA,MACd,UAAU,QAAQ;AAAA,IACrB,GAAK,OAAO;AAAA,EACX;AAAA,EACA,MAAM,kBAAkB,WAAW,MAAM,OAAO;AAC/C,UAAM,UAAU,KAAK,WAAW,IAAI,KAAK;AACzC,QAAI,YAAY,OAAQ,OAAM,IAAI,MAAM,6BAA6B,KAAK,wBAAwB;AAClG,UAAM,KAAK,KAAK;AAAA,MACf,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,MAAM,QAAQ;AAAA,MACd,UAAU,QAAQ;AAAA,MAClB;AAAA,IACH,GAAK,OAAO;AAAA,EACX;AAAA,EACA,MAAM,SAAS;AACd,UAAM,kBAAkB,CAAC,GAAG,KAAK,eAAe,OAAM,CAAE;AACxD,YAAQ,IAAI,eAAe,EAAE,QAAQ,MAAM;AAC1C,WAAK,OAAO,MAAK;AAAA,IAClB,CAAC;AAAA,EACF;AACD;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index.es90.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/singletons/async_local_storage/index.js"],"sourcesContent":["import { _CONTEXT_VARIABLES_KEY, getGlobalAsyncLocalStorageInstance, setGlobalAsyncLocalStorageInstance } from \"./globals.js\";\nimport { CallbackManager } from \"../../callbacks/manager.js\";\nimport { RunTree } from \"langsmith\";\n\n//#region src/singletons/async_local_storage/index.ts\nvar MockAsyncLocalStorage = class {\n\tgetStore() {\n\t\treturn void 0;\n\t}\n\trun(_store, callback) {\n\t\treturn callback();\n\t}\n\tenterWith(_store) {\n\t\treturn void 0;\n\t}\n};\nconst mockAsyncLocalStorage = new MockAsyncLocalStorage();\nconst LC_CHILD_KEY = Symbol.for(\"lc:child_config\");\nvar AsyncLocalStorageProvider = class {\n\tgetInstance() {\n\t\treturn getGlobalAsyncLocalStorageInstance() ?? mockAsyncLocalStorage;\n\t}\n\tgetRunnableConfig() {\n\t\tconst storage = this.getInstance();\n\t\treturn storage.getStore()?.extra?.[LC_CHILD_KEY];\n\t}\n\trunWithConfig(config, callback, avoidCreatingRootRunTree) {\n\t\tconst callbackManager = CallbackManager._configureSync(config?.callbacks, void 0, config?.tags, void 0, config?.metadata);\n\t\tconst storage = this.getInstance();\n\t\tconst previousValue = storage.getStore();\n\t\tconst parentRunId = callbackManager?.getParentRunId();\n\t\tconst langChainTracer = callbackManager?.handlers?.find((handler) => handler?.name === \"langchain_tracer\");\n\t\tlet runTree;\n\t\tif (langChainTracer && parentRunId) runTree = langChainTracer.getRunTreeWithTracingConfig(parentRunId);\n\t\telse if (!avoidCreatingRootRunTree) runTree = new RunTree({\n\t\t\tname: \"<runnable_lambda>\",\n\t\t\ttracingEnabled: false\n\t\t});\n\t\tif (runTree) runTree.extra = {\n\t\t\t...runTree.extra,\n\t\t\t[LC_CHILD_KEY]: config\n\t\t};\n\t\tif (previousValue !== void 0 && previousValue[_CONTEXT_VARIABLES_KEY] !== void 0) {\n\t\t\tif (runTree === void 0) runTree = {};\n\t\t\trunTree[_CONTEXT_VARIABLES_KEY] = previousValue[_CONTEXT_VARIABLES_KEY];\n\t\t}\n\t\treturn storage.run(runTree, callback);\n\t}\n\tinitializeGlobalInstance(instance) {\n\t\tif (getGlobalAsyncLocalStorageInstance() === void 0) setGlobalAsyncLocalStorageInstance(instance);\n\t}\n};\nconst AsyncLocalStorageProviderSingleton = new AsyncLocalStorageProvider();\n\n//#endregion\nexport { AsyncLocalStorageProviderSingleton, MockAsyncLocalStorage };\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;;;AAKG,IAAC,wBAAwB,MAAM;AAAA,EACjC,WAAW;AACV,WAAO;AAAA,EACR;AAAA,EACA,IAAI,QAAQ,UAAU;AACrB,WAAO,SAAQ;AAAA,EAChB;AAAA,EACA,UAAU,QAAQ;AACjB,WAAO;AAAA,EACR;AACD;AACA,MAAM,wBAAwB,IAAI,sBAAqB;AACvD,MAAM,eAAe,uBAAO,IAAI,iBAAiB;AACjD,IAAI,4BAA4B,MAAM;AAAA,EACrC,cAAc;AACb,WAAO,mCAAkC,KAAM;AAAA,EAChD;AAAA,EACA,oBAAoB;AACnB,UAAM,UAAU,KAAK,YAAW;AAChC,WAAO,QAAQ,YAAY,QAAQ,YAAY;AAAA,EAChD;AAAA,EACA,cAAc,QAAQ,UAAU,0BAA0B;AACzD,UAAM,kBAAkB,gBAAgB,eAAe,QAAQ,WAAW,QAAQ,QAAQ,MAAM,QAAQ,QAAQ,QAAQ;AACxH,UAAM,UAAU,KAAK,YAAW;AAChC,UAAM,gBAAgB,QAAQ,SAAQ;AACtC,UAAM,cAAc,iBAAiB,eAAc;AACnD,UAAM,kBAAkB,iBAAiB,UAAU,KAAK,CAAC,YAAY,SAAS,SAAS,kBAAkB;AACzG,QAAI;AACJ,QAAI,mBAAmB,YAAa,WAAU,gBAAgB,4BAA4B,WAAW;AAAA,aAC5F,CAAC,yBAA0B,WAAU,IAAI,QAAQ;AAAA,MACzD,MAAM;AAAA,MACN,gBAAgB;AAAA,IACnB,CAAG;AACD,QAAI,QAAS,SAAQ,QAAQ;AAAA,MAC5B,GAAG,QAAQ;AAAA,MACX,CAAC,YAAY,GAAG;AAAA,IACnB;AACE,QAAI,kBAAkB,UAAU,cAAc,sBAAsB,MAAM,QAAQ;AACjF,UAAI,YAAY,OAAQ,WAAU,CAAA;AAClC,cAAQ,sBAAsB,IAAI,cAAc,sBAAsB;AAAA,IACvE;AACA,WAAO,QAAQ,IAAI,SAAS,QAAQ;AAAA,EACrC;AAAA,EACA,yBAAyB,UAAU;AAClC,QAAI,mCAAkC,MAAO,OAAQ,oCAAmC,QAAQ;AAAA,EACjG;AACD;AACK,MAAC,qCAAqC,IAAI,0BAAyB;","x_google_ignoreList":[0]}
|
package/dist/index.es91.js
CHANGED
|
@@ -1,140 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (typeof value !== "number" || Number.isNaN(value)) throw new TypeError(`Expected \`${name}\` to be a number${allowInfinity ? " or Infinity" : ""}.`);
|
|
11
|
-
if (!allowInfinity && !Number.isFinite(value)) throw new TypeError(`Expected \`${name}\` to be a finite number.`);
|
|
12
|
-
if (value < min) throw new TypeError(`Expected \`${name}\` to be ≥ ${min}.`);
|
|
13
|
-
}
|
|
14
|
-
var AbortError = class extends Error {
|
|
15
|
-
constructor(message) {
|
|
16
|
-
super();
|
|
17
|
-
if (message instanceof Error) {
|
|
18
|
-
this.originalError = message;
|
|
19
|
-
({ message } = message);
|
|
20
|
-
} else {
|
|
21
|
-
this.originalError = new Error(message);
|
|
22
|
-
this.originalError.stack = this.stack;
|
|
23
|
-
}
|
|
24
|
-
this.name = "AbortError";
|
|
25
|
-
this.message = message;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
function calculateDelay(retriesConsumed, options) {
|
|
29
|
-
const attempt = Math.max(1, retriesConsumed + 1);
|
|
30
|
-
const random = options.randomize ? Math.random() + 1 : 1;
|
|
31
|
-
let timeout = Math.round(random * options.minTimeout * options.factor ** (attempt - 1));
|
|
32
|
-
timeout = Math.min(timeout, options.maxTimeout);
|
|
33
|
-
return timeout;
|
|
34
|
-
}
|
|
35
|
-
function calculateRemainingTime(start, max) {
|
|
36
|
-
if (!Number.isFinite(max)) return max;
|
|
37
|
-
return max - (performance.now() - start);
|
|
38
|
-
}
|
|
39
|
-
async function onAttemptFailure({ error, attemptNumber, retriesConsumed, startTime, options }) {
|
|
40
|
-
const normalizedError = error instanceof Error ? error : /* @__PURE__ */ new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
|
|
41
|
-
if (normalizedError instanceof AbortError) throw normalizedError.originalError;
|
|
42
|
-
const retriesLeft = Number.isFinite(options.retries) ? Math.max(0, options.retries - retriesConsumed) : options.retries;
|
|
43
|
-
const maxRetryTime = options.maxRetryTime ?? Number.POSITIVE_INFINITY;
|
|
44
|
-
const context = Object.freeze({
|
|
45
|
-
error: normalizedError,
|
|
46
|
-
attemptNumber,
|
|
47
|
-
retriesLeft,
|
|
48
|
-
retriesConsumed
|
|
49
|
-
});
|
|
50
|
-
await options.onFailedAttempt(context);
|
|
51
|
-
if (calculateRemainingTime(startTime, maxRetryTime) <= 0) throw normalizedError;
|
|
52
|
-
const consumeRetry = await options.shouldConsumeRetry(context);
|
|
53
|
-
const remainingTime = calculateRemainingTime(startTime, maxRetryTime);
|
|
54
|
-
if (remainingTime <= 0 || retriesLeft <= 0) throw normalizedError;
|
|
55
|
-
if (normalizedError instanceof TypeError && !isNetworkError(normalizedError)) {
|
|
56
|
-
if (consumeRetry) throw normalizedError;
|
|
57
|
-
options.signal?.throwIfAborted();
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
if (!await options.shouldRetry(context)) throw normalizedError;
|
|
61
|
-
if (!consumeRetry) {
|
|
62
|
-
options.signal?.throwIfAborted();
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
const delayTime = calculateDelay(retriesConsumed, options);
|
|
66
|
-
const finalDelay = Math.min(delayTime, remainingTime);
|
|
67
|
-
if (finalDelay > 0) await new Promise((resolve, reject) => {
|
|
68
|
-
const onAbort = () => {
|
|
69
|
-
clearTimeout(timeoutToken);
|
|
70
|
-
options.signal?.removeEventListener("abort", onAbort);
|
|
71
|
-
reject(options.signal.reason);
|
|
72
|
-
};
|
|
73
|
-
const timeoutToken = setTimeout(() => {
|
|
74
|
-
options.signal?.removeEventListener("abort", onAbort);
|
|
75
|
-
resolve();
|
|
76
|
-
}, finalDelay);
|
|
77
|
-
if (options.unref) timeoutToken.unref?.();
|
|
78
|
-
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
79
|
-
});
|
|
80
|
-
options.signal?.throwIfAborted();
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
async function pRetry(input, options = {}) {
|
|
84
|
-
options = { ...options };
|
|
85
|
-
validateRetries(options.retries);
|
|
86
|
-
if (Object.hasOwn(options, "forever")) throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");
|
|
87
|
-
options.retries ??= 10;
|
|
88
|
-
options.factor ??= 2;
|
|
89
|
-
options.minTimeout ??= 1e3;
|
|
90
|
-
options.maxTimeout ??= Number.POSITIVE_INFINITY;
|
|
91
|
-
options.maxRetryTime ??= Number.POSITIVE_INFINITY;
|
|
92
|
-
options.randomize ??= false;
|
|
93
|
-
options.onFailedAttempt ??= () => {
|
|
94
|
-
};
|
|
95
|
-
options.shouldRetry ??= () => true;
|
|
96
|
-
options.shouldConsumeRetry ??= () => true;
|
|
97
|
-
validateNumberOption("factor", options.factor, {
|
|
98
|
-
min: 0,
|
|
99
|
-
allowInfinity: false
|
|
100
|
-
});
|
|
101
|
-
validateNumberOption("minTimeout", options.minTimeout, {
|
|
102
|
-
min: 0,
|
|
103
|
-
allowInfinity: false
|
|
104
|
-
});
|
|
105
|
-
validateNumberOption("maxTimeout", options.maxTimeout, {
|
|
106
|
-
min: 0,
|
|
107
|
-
allowInfinity: true
|
|
108
|
-
});
|
|
109
|
-
validateNumberOption("maxRetryTime", options.maxRetryTime, {
|
|
110
|
-
min: 0,
|
|
111
|
-
allowInfinity: true
|
|
112
|
-
});
|
|
113
|
-
if (!(options.factor > 0)) options.factor = 1;
|
|
114
|
-
options.signal?.throwIfAborted();
|
|
115
|
-
let attemptNumber = 0;
|
|
116
|
-
let retriesConsumed = 0;
|
|
117
|
-
const startTime = performance.now();
|
|
118
|
-
while (Number.isFinite(options.retries) ? retriesConsumed <= options.retries : true) {
|
|
119
|
-
attemptNumber++;
|
|
120
|
-
try {
|
|
121
|
-
options.signal?.throwIfAborted();
|
|
122
|
-
const result = await input(attemptNumber);
|
|
123
|
-
options.signal?.throwIfAborted();
|
|
124
|
-
return result;
|
|
125
|
-
} catch (error) {
|
|
126
|
-
if (await onAttemptFailure({
|
|
127
|
-
error,
|
|
128
|
-
attemptNumber,
|
|
129
|
-
retriesConsumed,
|
|
130
|
-
startTime,
|
|
131
|
-
options
|
|
132
|
-
})) retriesConsumed++;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
throw new Error("Retry attempts exhausted without throwing an error.");
|
|
136
|
-
}
|
|
1
|
+
import { __export } from "./index.es50.js";
|
|
2
|
+
import { _CONTEXT_VARIABLES_KEY } from "./index.es110.js";
|
|
3
|
+
import { MockAsyncLocalStorage, AsyncLocalStorageProviderSingleton } from "./index.es90.js";
|
|
4
|
+
var singletons_exports = {};
|
|
5
|
+
__export(singletons_exports, {
|
|
6
|
+
AsyncLocalStorageProviderSingleton: () => AsyncLocalStorageProviderSingleton,
|
|
7
|
+
MockAsyncLocalStorage: () => MockAsyncLocalStorage,
|
|
8
|
+
_CONTEXT_VARIABLES_KEY: () => _CONTEXT_VARIABLES_KEY
|
|
9
|
+
});
|
|
137
10
|
export {
|
|
138
|
-
|
|
11
|
+
AsyncLocalStorageProviderSingleton,
|
|
12
|
+
MockAsyncLocalStorage,
|
|
13
|
+
_CONTEXT_VARIABLES_KEY,
|
|
14
|
+
singletons_exports
|
|
139
15
|
};
|
|
140
16
|
//# sourceMappingURL=index.es91.js.map
|