@mcp-use/inspector 0.4.1 → 0.4.2
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/cli/inspect.js +494 -152
- package/dist/client/assets/1c-1LwXCeaM.js +1 -0
- package/dist/client/assets/abap-C_CBbMnB.js +1 -0
- package/dist/client/assets/abnf-CqunyC29.js +1 -0
- package/dist/client/assets/abnf-Dl0nB3FF.js +1 -0
- package/dist/client/assets/accesslog-Dyx4zD-U.js +1 -0
- package/dist/client/assets/actionscript-C26AcnTI.js +1 -0
- package/dist/client/assets/actionscript-j49rsMcf.js +1 -0
- package/dist/client/assets/ada-BX725jFl.js +1 -0
- package/dist/client/assets/ada-hbKcShTz.js +1 -0
- package/dist/client/assets/agda-DhZ1RJF_.js +1 -0
- package/dist/client/assets/al-DgP2kVCg.js +1 -0
- package/dist/client/assets/angelscript-kr0j6as3.js +1 -0
- package/dist/client/assets/antlr4-BS3OIu8p.js +1 -0
- package/dist/client/assets/apache-D2YLUenx.js +1 -0
- package/dist/client/assets/apacheconf-DxF2tf7X.js +1 -0
- package/dist/client/assets/apex-CB1rApcz.js +1 -0
- package/dist/client/assets/api_chain-3SKETdru.js +15 -0
- package/dist/client/assets/apl-BaRelSYQ.js +1 -0
- package/dist/client/assets/applescript-BV6r0vOg.js +1 -0
- package/dist/client/assets/applescript-CBXJGTwD.js +1 -0
- package/dist/client/assets/aql-CRa5w9sh.js +1 -0
- package/dist/client/assets/arcade-pblJoyUV.js +1 -0
- package/dist/client/assets/arduino-BJzx0aI4.js +1 -0
- package/dist/client/assets/arduino-C8Hvy8zI.js +1 -0
- package/dist/client/assets/arff-DKr6H6Gn.js +1 -0
- package/dist/client/assets/armasm-Cb0n7QyY.js +1 -0
- package/dist/client/assets/asciidoc-CaW32vdw.js +1 -0
- package/dist/client/assets/asciidoc-DEUbzgzD.js +1 -0
- package/dist/client/assets/asm6502-D-qvz9Nj.js +1 -0
- package/dist/client/assets/asmatmel--NnPZCww.js +1 -0
- package/dist/client/assets/aspectj-D2EcGUnV.js +1 -0
- package/dist/client/assets/aspnet-jExzHcT5.js +1 -0
- package/dist/client/assets/autohotkey-BNBZGzFC.js +1 -0
- package/dist/client/assets/autohotkey-BhTDcK3I.js +1 -0
- package/dist/client/assets/autoit-Cbom03rp.js +1 -0
- package/dist/client/assets/autoit-CuVWp-C-.js +1 -0
- package/dist/client/assets/avisynth-im3i7vGW.js +1 -0
- package/dist/client/assets/avrasm-WrKdYrqC.js +1 -0
- package/dist/client/assets/avro-idl-5N4Kkatt.js +1 -0
- package/dist/client/assets/awk-DTAvXRS6.js +1 -0
- package/dist/client/assets/axapta-D6iCXT0X.js +1 -0
- package/dist/client/assets/bash-DgpcKAEV.js +1 -0
- package/dist/client/assets/bash-Dp2p1czB.js +1 -0
- package/dist/client/assets/basic-BuNBl12J.js +1 -0
- package/dist/client/assets/basic-DoCiPuhP.js +1 -0
- package/dist/client/assets/batch-LD3Xps_N.js +1 -0
- package/dist/client/assets/bbcode-CEBIc7A0.js +1 -0
- package/dist/client/assets/bicep-DpTpz4-R.js +1 -0
- package/dist/client/assets/birb-D5rzgvgL.js +1 -0
- package/dist/client/assets/bison-DIOvX5by.js +1 -0
- package/dist/client/assets/bnf-Bq9MUbvb.js +1 -0
- package/dist/client/assets/bnf-DZhmYi8o.js +1 -0
- package/dist/client/assets/brainfuck-D9zJtTAf.js +1 -0
- package/dist/client/assets/brainfuck-DB8-U-Kr.js +1 -0
- package/dist/client/assets/brightscript-l-qwRCoE.js +1 -0
- package/dist/client/assets/bro-B6PmV0fl.js +1 -0
- package/dist/client/assets/bsl-CCbE99HJ.js +1 -0
- package/dist/client/assets/c-CKX-6wqR.js +1 -0
- package/dist/client/assets/c-jAZcOhb1.js +1 -0
- package/dist/client/assets/c-like-ezlGQVKl.js +1 -0
- package/dist/client/assets/cal-DI8ggXUw.js +1 -0
- package/dist/client/assets/capnproto-_AY5dSbQ.js +1 -0
- package/dist/client/assets/ceylon-DhXQNTW2.js +1 -0
- package/dist/client/assets/cfscript-D2vQsyGT.js +1 -0
- package/dist/client/assets/chaiscript-B6s8iVkN.js +1 -0
- package/dist/client/assets/cil-2wkoeycK.js +1 -0
- package/dist/client/assets/clean-CYq8bwen.js +1 -0
- package/dist/client/assets/clike-CcDxgrrV.js +1 -0
- package/dist/client/assets/clojure-B0QONKHe.js +1 -0
- package/dist/client/assets/clojure-DHbp9ZvJ.js +1 -0
- package/dist/client/assets/clojure-repl-DS4d0m_-.js +1 -0
- package/dist/client/assets/cmake-D9-goF-V.js +1 -0
- package/dist/client/assets/cmake-G7nBYrGQ.js +1 -0
- package/dist/client/assets/cobol-DoTFpdYR.js +1 -0
- package/dist/client/assets/coffeescript-CVaQbBah.js +1 -0
- package/dist/client/assets/coffeescript-fGblLc_b.js +1 -0
- package/dist/client/assets/combine_docs_chain-Bi09clmQ.js +3 -0
- package/dist/client/assets/concurnas-C71UuVo5.js +1 -0
- package/dist/client/assets/coq-CjQDaRNG.js +1 -0
- package/dist/client/assets/coq-DxyAJCwZ.js +1 -0
- package/dist/client/assets/cos-BPDGAug3.js +1 -0
- package/dist/client/assets/cpp-BGz3alx4.js +1 -0
- package/dist/client/assets/cpp-CYtgT1RC.js +1 -0
- package/dist/client/assets/crmsh-Cqz7J2uL.js +1 -0
- package/dist/client/assets/crystal-Xhn8eS_8.js +1 -0
- package/dist/client/assets/crystal-dqmDzSs_.js +1 -0
- package/dist/client/assets/csharp-DRUUa0y5.js +1 -0
- package/dist/client/assets/csharp-R4VDBdEl.js +1 -0
- package/dist/client/assets/cshtml-C1llnqB8.js +1 -0
- package/dist/client/assets/csp-CFVd7sCm.js +1 -0
- package/dist/client/assets/csp-Cb1BZoWZ.js +1 -0
- package/dist/client/assets/css-BBhlHsUT.js +1 -0
- package/dist/client/assets/css-DNJ_5GQ2.js +1 -0
- package/dist/client/assets/css-extras-kpJL186f.js +1 -0
- package/dist/client/assets/csv-CUFhfgT7.js +1 -0
- package/dist/client/assets/cypher-DbthTYax.js +1 -0
- package/dist/client/assets/d-BaAkXIHL.js +1 -0
- package/dist/client/assets/d-CrpxWz0Q.js +1 -0
- package/dist/client/assets/dart-pg9sg7zR.js +1 -0
- package/dist/client/assets/dart-pgknyWq_.js +1 -0
- package/dist/client/assets/dataweave-nm3b6RCA.js +1 -0
- package/dist/client/assets/dax-n_XJjCsK.js +1 -0
- package/dist/client/assets/deep-compare-strict-DtUHXpbW.js +1 -0
- package/dist/client/assets/delphi-DL162Fps.js +1 -0
- package/dist/client/assets/dhall-CFg1Wt18.js +1 -0
- package/dist/client/assets/diff-R2Ywj4m0.js +1 -0
- package/dist/client/assets/diff-VqmH3Tr4.js +1 -0
- package/dist/client/assets/django-B0_SGlZF.js +1 -0
- package/dist/client/assets/django-CKqf_LeY.js +1 -0
- package/dist/client/assets/dns-BJqUXkVQ.js +1 -0
- package/dist/client/assets/dns-zone-file-iMy4RKG0.js +1 -0
- package/dist/client/assets/docker-DibCy3fp.js +1 -0
- package/dist/client/assets/dockerfile-CxFEMtOd.js +1 -0
- package/dist/client/assets/dos-CXYqTuvU.js +1 -0
- package/dist/client/assets/dot-DMz2AwJG.js +1 -0
- package/dist/client/assets/dsconfig-BSafpNO4.js +1 -0
- package/dist/client/assets/dts-CQ4ddadK.js +1 -0
- package/dist/client/assets/dust-DHdg5dKL.js +1 -0
- package/dist/client/assets/ebnf-DFWNGUts.js +1 -0
- package/dist/client/assets/ebnf-n_HuLYlN.js +1 -0
- package/dist/client/assets/editorconfig-q1hr8mZn.js +1 -0
- package/dist/client/assets/eiffel-DeM5iKH1.js +1 -0
- package/dist/client/assets/ejs-DuY-wppU.js +1 -0
- package/dist/client/assets/elixir-CMqX3Vo7.js +1 -0
- package/dist/client/assets/elixir-DOyh2gCH.js +1 -0
- package/dist/client/assets/elm-CIB45FSl.js +1 -0
- package/dist/client/assets/elm-CKaXJe02.js +1 -0
- package/dist/client/assets/erb-BZihNRd4.js +1 -0
- package/dist/client/assets/erb-DJthf16s.js +1 -0
- package/dist/client/assets/erlang-5xmHrF5K.js +1 -0
- package/dist/client/assets/erlang-DqPZXzL1.js +1 -0
- package/dist/client/assets/erlang-repl-DNdGW8Zj.js +1 -0
- package/dist/client/assets/etlua-CUdYfjfk.js +1 -0
- package/dist/client/assets/excel-CSZ_Agvf.js +1 -0
- package/dist/client/assets/excel-formula-KhMpjq6w.js +1 -0
- package/dist/client/assets/factor-D1oDLHPM.js +1 -0
- package/dist/client/assets/false-Dj25Ots1.js +1 -0
- package/dist/client/assets/few_shot-ZsJ5YbeJ.js +3 -0
- package/dist/client/assets/firestore-security-rules-QPJCjY65.js +1 -0
- package/dist/client/assets/fix-CgPPbcZl.js +1 -0
- package/dist/client/assets/flix-KP63yuil.js +1 -0
- package/dist/client/assets/flow-CEsJlKGR.js +1 -0
- package/dist/client/assets/fortran-BdRBXTm6.js +1 -0
- package/dist/client/assets/fortran-XO3Rx-Jc.js +1 -0
- package/dist/client/assets/fsharp-9gv4Z2bM.js +1 -0
- package/dist/client/assets/fsharp-B2Hgpxf4.js +1 -0
- package/dist/client/assets/ftl-Ctn1WYqN.js +1 -0
- package/dist/client/assets/gams-BRP9WTr2.js +1 -0
- package/dist/client/assets/gap-BCLaOkB8.js +1 -0
- package/dist/client/assets/gauss-DHPLtN-0.js +1 -0
- package/dist/client/assets/gcode-Bs3WYoEH.js +1 -0
- package/dist/client/assets/gcode-BxW22EgL.js +1 -0
- package/dist/client/assets/gdscript-kh48HHIG.js +1 -0
- package/dist/client/assets/gedcom-DjXr2tK4.js +1 -0
- package/dist/client/assets/gherkin-Cs2i2WTH.js +1 -0
- package/dist/client/assets/gherkin-DEfHrW1U.js +1 -0
- package/dist/client/assets/git-BR1n084B.js +1 -0
- package/dist/client/assets/glsl-C-ccf05D.js +1 -0
- package/dist/client/assets/glsl-Q8QGHfqT.js +1 -0
- package/dist/client/assets/gml-Bxnjqd2J.js +1 -0
- package/dist/client/assets/gml-DHxWO88N.js +1 -0
- package/dist/client/assets/gn-HfbOFyhD.js +1 -0
- package/dist/client/assets/go-BRHVkY2d.js +1 -0
- package/dist/client/assets/go-DjF_fz-h.js +1 -0
- package/dist/client/assets/go-module-KY-i9rhL.js +1 -0
- package/dist/client/assets/golo-BajSy2sT.js +1 -0
- package/dist/client/assets/gradle-Ct1ckrhx.js +1 -0
- package/dist/client/assets/graphql-XMPh__BW.js +1 -0
- package/dist/client/assets/groovy-CLOoHbmE.js +1 -0
- package/dist/client/assets/groovy-SqYFnqzf.js +1 -0
- package/dist/client/assets/haml-B2XBKI9L.js +1 -0
- package/dist/client/assets/haml-BylNh74w.js +1 -0
- package/dist/client/assets/handlebars-BgXKFDaT.js +1 -0
- package/dist/client/assets/handlebars-Ck07Sc0o.js +1 -0
- package/dist/client/assets/haskell-CObxIh2K.js +1 -0
- package/dist/client/assets/haskell-DoLZrDsM.js +1 -0
- package/dist/client/assets/haxe-D0a6ys8O.js +1 -0
- package/dist/client/assets/haxe-rdGDQixh.js +1 -0
- package/dist/client/assets/hcl-C8wgyAy_.js +1 -0
- package/dist/client/assets/hlsl-Lrpx1Tc-.js +1 -0
- package/dist/client/assets/hoon-B4-f2eBX.js +1 -0
- package/dist/client/assets/hpkp-D3acZRbt.js +1 -0
- package/dist/client/assets/hsp-UZY8No82.js +1 -0
- package/dist/client/assets/hsts-DOghoEM6.js +1 -0
- package/dist/client/assets/htmlbars-Bq_yaVt9.js +1 -0
- package/dist/client/assets/http-BvqO3lye.js +1 -0
- package/dist/client/assets/http-CwSNWevT.js +1 -0
- package/dist/client/assets/hy-DXteTZ_v.js +1 -0
- package/dist/client/assets/ichigojam-p84mF3EG.js +1 -0
- package/dist/client/assets/icon-D_8mafNt.js +1 -0
- package/dist/client/assets/icu-message-format-jtRBhdPJ.js +1 -0
- package/dist/client/assets/idris-CgbppSal.js +1 -0
- package/dist/client/assets/iecst-BQaNgXgE.js +1 -0
- package/dist/client/assets/ignore-CCz-HdeY.js +1 -0
- package/dist/client/assets/index-BXxIkNj2.js +212 -0
- package/dist/client/assets/index-Boe6IUZP.js +4 -0
- package/dist/client/assets/index-BtU-sGqa.js +1 -0
- package/dist/client/assets/index-C2et5R9-.js +25 -0
- package/dist/client/assets/index-DPVUiW-t.js +48 -0
- package/dist/client/assets/index-DUE1m-ya.css +1 -0
- package/dist/client/assets/index-DvNb1_yp.js +1752 -0
- package/dist/client/assets/inform7-BNQuDEVU.js +1 -0
- package/dist/client/assets/inform7-BtFnzoSE.js +1 -0
- package/dist/client/assets/ini-AEjHJgjB.js +1 -0
- package/dist/client/assets/ini-qYTUOJdn.js +1 -0
- package/dist/client/assets/io-B4db0oLC.js +1 -0
- package/dist/client/assets/irpf90-BlhxaivT.js +1 -0
- package/dist/client/assets/isbl-nLNS4UMz.js +1 -0
- package/dist/client/assets/j-gDKXD_fI.js +1 -0
- package/dist/client/assets/java-CPua5RH2.js +1 -0
- package/dist/client/assets/java-D8C3oys1.js +1 -0
- package/dist/client/assets/javadoc-BmNqF9RP.js +1 -0
- package/dist/client/assets/javadoclike-DWlDvZlE.js +1 -0
- package/dist/client/assets/javascript-6_uNPAYO.js +1 -0
- package/dist/client/assets/javascript-CK9yxltA.js +1 -0
- package/dist/client/assets/javastacktrace-D9I7bJWr.js +1 -0
- package/dist/client/assets/jboss-cli-Bva6ngl4.js +1 -0
- package/dist/client/assets/jexl-CnppheXw.js +1 -0
- package/dist/client/assets/jolie-yqjJZ-bs.js +1 -0
- package/dist/client/assets/jq-Brf0g9jb.js +1 -0
- package/dist/client/assets/js-extras-Dp696qa_.js +1 -0
- package/dist/client/assets/js-templates-dCI_hGk0.js +1 -0
- package/dist/client/assets/jsdoc-Bpj4wBeZ.js +1 -0
- package/dist/client/assets/json-CCgVPibO.js +1 -0
- package/dist/client/assets/json-CV69Dri1.js +1 -0
- package/dist/client/assets/json-ZW4Ys-1H.js +5 -0
- package/dist/client/assets/json5-LM1zx7Zj.js +1 -0
- package/dist/client/assets/jsonp-B1x75JFy.js +1 -0
- package/dist/client/assets/jsstacktrace-DTAWKN9h.js +1 -0
- package/dist/client/assets/jsx-3rzZJUGT.js +1 -0
- package/dist/client/assets/julia-Bd4vWNB7.js +1 -0
- package/dist/client/assets/julia-Bt8Zd57o.js +1 -0
- package/dist/client/assets/julia-repl-B64Hrqt1.js +1 -0
- package/dist/client/assets/keepalived-CyHqRgry.js +1 -0
- package/dist/client/assets/keyman-Dh9P2AZO.js +1 -0
- package/dist/client/assets/kotlin-DZ27n0zO.js +1 -0
- package/dist/client/assets/kotlin-So3HH0i8.js +1 -0
- package/dist/client/assets/kumir-yFLgdLEG.js +1 -0
- package/dist/client/assets/kusto-jJgzwrC1.js +1 -0
- package/dist/client/assets/langfuse-YA2S23SM-CxwiV0VJ.js +239 -0
- package/dist/client/assets/lasso-z61_tmK5.js +1 -0
- package/dist/client/assets/latex-Cep2d1LJ.js +1 -0
- package/dist/client/assets/latex-DojLKwEv.js +1 -0
- package/dist/client/assets/latte-CGtpgHFd.js +1 -0
- package/dist/client/assets/ldif-BvrQzS5w.js +1 -0
- package/dist/client/assets/leaf-DQ83VGIa.js +1 -0
- package/dist/client/assets/less-CsTgLIyq.js +1 -0
- package/dist/client/assets/less-wBT9IhUl.js +1 -0
- package/dist/client/assets/lilypond-DRMyNbzU.js +1 -0
- package/dist/client/assets/liquid-DwRBX2Mk.js +1 -0
- package/dist/client/assets/lisp-CW7pIJr0.js +1 -0
- package/dist/client/assets/lisp-gGskDznl.js +1 -0
- package/dist/client/assets/livecodeserver-BOL8repk.js +1 -0
- package/dist/client/assets/livescript-DY_XGEQ6.js +1 -0
- package/dist/client/assets/livescript-zFDn6lCa.js +1 -0
- package/dist/client/assets/llm_chain-CYdmV1P-.js +1 -0
- package/dist/client/assets/llvm-Db1cms20.js +1 -0
- package/dist/client/assets/llvm-NarBPnao.js +1 -0
- package/dist/client/assets/log-CQ0x5Z45.js +1 -0
- package/dist/client/assets/lolcode-CVtFmVW0.js +1 -0
- package/dist/client/assets/lsl-B4IDwLY_.js +1 -0
- package/dist/client/assets/lua-Bj_30OMu.js +1 -0
- package/dist/client/assets/lua-zB_TCBSt.js +1 -0
- package/dist/client/assets/magma-BTrLPael.js +1 -0
- package/dist/client/assets/makefile-CJj95oiA.js +1 -0
- package/dist/client/assets/makefile-Dv5XcHEA.js +1 -0
- package/dist/client/assets/markdown-BVL8Mrbo.js +1 -0
- package/dist/client/assets/markdown-ZWbNf69g.js +1 -0
- package/dist/client/assets/markup-DwEbHSdk.js +1 -0
- package/dist/client/assets/markup-templating-BCY5Gqhe.js +1 -0
- package/dist/client/assets/mathematica-mn-kUPuq.js +1 -0
- package/dist/client/assets/matlab-B_JWjsmK.js +1 -0
- package/dist/client/assets/matlab-zaWm_7CP.js +1 -0
- package/dist/client/assets/maxima-DRu8jnbv.js +1 -0
- package/dist/client/assets/maxscript-CsLwRh8_.js +1 -0
- package/dist/client/assets/mel-CfLv1HgU.js +1 -0
- package/dist/client/assets/mel-CuEU7Fv9.js +1 -0
- package/dist/client/assets/mercury-DbgN2V6g.js +1 -0
- package/dist/client/assets/mermaid-SSP6q0TH.js +1 -0
- package/dist/client/assets/mipsasm-He_mKgrS.js +1 -0
- package/dist/client/assets/mizar-BcmslZ8H.js +1 -0
- package/dist/client/assets/mizar-C7ejUTMl.js +1 -0
- package/dist/client/assets/mojolicious-817c6Ky0.js +1 -0
- package/dist/client/assets/mongodb-C33CGdPe.js +1 -0
- package/dist/client/assets/monkey-DS14SkBw.js +1 -0
- package/dist/client/assets/monkey-vhvYckq9.js +1 -0
- package/dist/client/assets/moonscript-CAOuGEqf.js +1 -0
- package/dist/client/assets/moonscript-Dm6VHN52.js +1 -0
- package/dist/client/assets/n1ql-BgL97zgT.js +1 -0
- package/dist/client/assets/n1ql-CftkJovc.js +1 -0
- package/dist/client/assets/n4js-CZBi560e.js +1 -0
- package/dist/client/assets/nand2tetris-hdl-BmJJLFLW.js +1 -0
- package/dist/client/assets/naniscript-5Agj3pFK.js +1 -0
- package/dist/client/assets/nasm-ALVrFRFg.js +1 -0
- package/dist/client/assets/neon-CfoXjcng.js +1 -0
- package/dist/client/assets/nevod-BV3EPOzl.js +1 -0
- package/dist/client/assets/nginx-DKkh7pDW.js +1 -0
- package/dist/client/assets/nginx-DnnEyUL2.js +1 -0
- package/dist/client/assets/nim-B7OFIVrx.js +1 -0
- package/dist/client/assets/nim-Df338CwG.js +1 -0
- package/dist/client/assets/nix-CpFUtISK.js +1 -0
- package/dist/client/assets/nix-DwUHuKa8.js +1 -0
- package/dist/client/assets/node-repl-Dm685JeL.js +1 -0
- package/dist/client/assets/nsis-Cw-yBAXx.js +1 -0
- package/dist/client/assets/nsis-exP5PZ5F.js +1 -0
- package/dist/client/assets/objectivec-Ba7S1x4Z.js +1 -0
- package/dist/client/assets/objectivec-CpK_agtc.js +1 -0
- package/dist/client/assets/ocaml-B4rrnP2N.js +1 -0
- package/dist/client/assets/ocaml-C7y2xiF_.js +1 -0
- package/dist/client/assets/opencl-BU-wiKBZ.js +1 -0
- package/dist/client/assets/openqasm-DmsXUwSY.js +1 -0
- package/dist/client/assets/openscad-BxRavlOk.js +1 -0
- package/dist/client/assets/oxygene-ChVyQtUM.js +1 -0
- package/dist/client/assets/oz-DqysyeBI.js +1 -0
- package/dist/client/assets/parigp-a9e-pkxj.js +1 -0
- package/dist/client/assets/parser-DzDykvBh.js +1 -0
- package/dist/client/assets/parser3-Jh8cJWvr.js +1 -0
- package/dist/client/assets/pascal-DByeZgix.js +1 -0
- package/dist/client/assets/pascaligo-COnLnb9d.js +1 -0
- package/dist/client/assets/pcaxis-C1PungVs.js +1 -0
- package/dist/client/assets/peoplecode-Dqzrbpxz.js +1 -0
- package/dist/client/assets/perl-C2Pc_F0Z.js +1 -0
- package/dist/client/assets/perl-ZHxsYES_.js +1 -0
- package/dist/client/assets/pf-DiW7WjDK.js +1 -0
- package/dist/client/assets/pgsql-WLS_2uin.js +1 -0
- package/dist/client/assets/php-BMal-KNI.js +1 -0
- package/dist/client/assets/php-extras-ZiDWZXXF.js +1 -0
- package/dist/client/assets/php-ftVaLoJf.js +1 -0
- package/dist/client/assets/php-template-DrD8Iqet.js +1 -0
- package/dist/client/assets/phpdoc-xizP2cNg.js +1 -0
- package/dist/client/assets/plaintext-BohDqSfI.js +1 -0
- package/dist/client/assets/plsql-Czj593yP.js +1 -0
- package/dist/client/assets/pony-iUg-w_X5.js +1 -0
- package/dist/client/assets/powerquery-CzSzf70Y.js +1 -0
- package/dist/client/assets/powershell-BAZk0u0I.js +1 -0
- package/dist/client/assets/powershell-zh0CGQvC.js +1 -0
- package/dist/client/assets/processing-Bkkc3JFE.js +1 -0
- package/dist/client/assets/processing-Cesy-djn.js +1 -0
- package/dist/client/assets/profile-D0HB42KL.js +1 -0
- package/dist/client/assets/prolog-N6JDETEr.js +1 -0
- package/dist/client/assets/prolog-jx91Hgq1.js +1 -0
- package/dist/client/assets/promql-DiTeUQom.js +1 -0
- package/dist/client/assets/properties-D9NBnO2K.js +1 -0
- package/dist/client/assets/properties-DxjeXBXu.js +1 -0
- package/dist/client/assets/protobuf-CPzUjTjp.js +1 -0
- package/dist/client/assets/protobuf-DR_d55cY.js +1 -0
- package/dist/client/assets/psl-BX4miJEK.js +1 -0
- package/dist/client/assets/pug-gStri_Xq.js +1 -0
- package/dist/client/assets/puppet-BfquW406.js +1 -0
- package/dist/client/assets/puppet-HgPyCb6I.js +1 -0
- package/dist/client/assets/pure-pPwtUw2w.js +1 -0
- package/dist/client/assets/purebasic-D_XzMZMf.js +1 -0
- package/dist/client/assets/purebasic-Djh1kKJ1.js +1 -0
- package/dist/client/assets/purescript-BvaZNrm5.js +1 -0
- package/dist/client/assets/python-BveZWkv5.js +1 -0
- package/dist/client/assets/python-repl-DWTtrG3B.js +1 -0
- package/dist/client/assets/python-xFqxwqhF.js +1 -0
- package/dist/client/assets/q-7E0rMyyM.js +1 -0
- package/dist/client/assets/q-BnQZdm_9.js +1 -0
- package/dist/client/assets/qml-Bno1x8E0.js +1 -0
- package/dist/client/assets/qml-C41hwjiH.js +1 -0
- package/dist/client/assets/qore-F9aW8Qay.js +1 -0
- package/dist/client/assets/qsharp-Cf8IuW15.js +1 -0
- package/dist/client/assets/r-DkLvSbO-.js +1 -0
- package/dist/client/assets/r-GkkqJzmk.js +1 -0
- package/dist/client/assets/racket-BKb2RiQ5.js +1 -0
- package/dist/client/assets/reason-CibDMoCx.js +1 -0
- package/dist/client/assets/reasonml-BM7bA_2e.js +1 -0
- package/dist/client/assets/regex-mW64ik50.js +1 -0
- package/dist/client/assets/rego-C9b4jKE_.js +1 -0
- package/dist/client/assets/renpy-ekwT19TS.js +1 -0
- package/dist/client/assets/rest-Bja87_dE.js +1 -0
- package/dist/client/assets/rib-oGRSUkxj.js +1 -0
- package/dist/client/assets/rip-CcP64Z_V.js +1 -0
- package/dist/client/assets/roboconf-BZOjeXzh.js +1 -0
- package/dist/client/assets/roboconf-D8S4hOX-.js +1 -0
- package/dist/client/assets/robotframework-C5hzdsKk.js +1 -0
- package/dist/client/assets/routeros-TvMB2SCe.js +1 -0
- package/dist/client/assets/rsl-8Mhw2dbV.js +1 -0
- package/dist/client/assets/ruby-CQZfcCSN.js +1 -0
- package/dist/client/assets/ruby-D7TR7FoI.js +1 -0
- package/dist/client/assets/ruleslanguage-COtwfMu7.js +1 -0
- package/dist/client/assets/rust-CJ_U1HS9.js +1 -0
- package/dist/client/assets/rust-D8s4_ADS.js +1 -0
- package/dist/client/assets/sas-B4rn5kbO.js +1 -0
- package/dist/client/assets/sas-C1C7PN--.js +1 -0
- package/dist/client/assets/sass-BnBDJQGm.js +1 -0
- package/dist/client/assets/scala-DisWYV_M.js +1 -0
- package/dist/client/assets/scala-x7UuZkVC.js +1 -0
- package/dist/client/assets/scheme-CeJT1MFb.js +1 -0
- package/dist/client/assets/scheme-Dn26tErI.js +1 -0
- package/dist/client/assets/scilab-BYgblvQa.js +1 -0
- package/dist/client/assets/scss-Cqg4bzhF.js +1 -0
- package/dist/client/assets/scss-DP8YKwTY.js +1 -0
- package/dist/client/assets/sequential_chain-BSDR0Wvv.js +1 -0
- package/dist/client/assets/shell-D9VaP7bc.js +1 -0
- package/dist/client/assets/shell-session-BDyRJ9Be.js +1 -0
- package/dist/client/assets/smali-B7-hotzt.js +1 -0
- package/dist/client/assets/smali-DF8hIxm5.js +1 -0
- package/dist/client/assets/smalltalk-BasWhrFV.js +1 -0
- package/dist/client/assets/smalltalk-Cxhqyq1g.js +1 -0
- package/dist/client/assets/smarty-YPsWDfMu.js +1 -0
- package/dist/client/assets/sml-Bg4vM9Vz.js +1 -0
- package/dist/client/assets/sml-DKttm-11.js +1 -0
- package/dist/client/assets/solidity-CLEvZ0m9.js +1 -0
- package/dist/client/assets/solution-file-DCxferRY.js +1 -0
- package/dist/client/assets/soy-025o1YZY.js +1 -0
- package/dist/client/assets/sparql-DkGltLyu.js +1 -0
- package/dist/client/assets/splunk-spl-CyDITQAL.js +1 -0
- package/dist/client/assets/sqf-BzPjezhl.js +1 -0
- package/dist/client/assets/sqf-DIsLhnWS.js +1 -0
- package/dist/client/assets/sql-But40W87.js +1 -0
- package/dist/client/assets/sql-DUE1sX6o.js +1 -0
- package/dist/client/assets/sql_more-BXQ-Pyn2.js +1 -0
- package/dist/client/assets/squirrel-CtvhUxEH.js +1 -0
- package/dist/client/assets/stan-8KVO6VLv.js +1 -0
- package/dist/client/assets/stan-C5rc7fu9.js +1 -0
- package/dist/client/assets/stata-DwaNhV36.js +1 -0
- package/dist/client/assets/step21-6a1s9YHA.js +1 -0
- package/dist/client/assets/stylus-12AOc-lY.js +1 -0
- package/dist/client/assets/stylus-CcmeKxff.js +1 -0
- package/dist/client/assets/subunit-DIdRxN33.js +1 -0
- package/dist/client/assets/swift-5MdubKvU.js +1 -0
- package/dist/client/assets/swift-DS9AtGXO.js +1 -0
- package/dist/client/assets/systemd-DXqmwld0.js +1 -0
- package/dist/client/assets/t4-cs-Bp09xvYg.js +1 -0
- package/dist/client/assets/t4-templating--Vl_qOe8.js +1 -0
- package/dist/client/assets/t4-vb-mVJ-NJFi.js +1 -0
- package/dist/client/assets/taggerscript-DXq4WP9F.js +1 -0
- package/dist/client/assets/tap-DIj8MGZO.js +1 -0
- package/dist/client/assets/tap-lZ1UPH2V.js +1 -0
- package/dist/client/assets/tcl-BYx7iVza.js +1 -0
- package/dist/client/assets/tcl-Di47CT9m.js +1 -0
- package/dist/client/assets/textile-Cu4suufn.js +1 -0
- package/dist/client/assets/thrift-DFY4_p49.js +1 -0
- package/dist/client/assets/toml-CxJkeLz2.js +1 -0
- package/dist/client/assets/tp-BLoTMneh.js +1 -0
- package/dist/client/assets/tremor-D60yO7sk.js +1 -0
- package/dist/client/assets/tsx-CcgVpv-E.js +1 -0
- package/dist/client/assets/tt2-B_ZTPXns.js +1 -0
- package/dist/client/assets/turtle-D0qQDbux.js +1 -0
- package/dist/client/assets/twig-CYLrk8wJ.js +1 -0
- package/dist/client/assets/twig-DOsUIVNH.js +1 -0
- package/dist/client/assets/types-CmQi9glY.js +81 -0
- package/dist/client/assets/typescript-1ETX30Fe.js +1 -0
- package/dist/client/assets/typescript-CESUcp84.js +1 -0
- package/dist/client/assets/typoscript-BUWpsiVo.js +1 -0
- package/dist/client/assets/unrealscript-aYFlCsFL.js +1 -0
- package/dist/client/assets/uorazor-H39AMVmc.js +1 -0
- package/dist/client/assets/uri-CK8hAd4M.js +1 -0
- package/dist/client/assets/v-C6LgZJLT.js +1 -0
- package/dist/client/assets/v4-BKrj-4V8.js +1 -0
- package/dist/client/assets/vala-1_TnBoKp.js +1 -0
- package/dist/client/assets/vala-CpbfXvML.js +1 -0
- package/dist/client/assets/vbnet-Bl26F7Jp.js +1 -0
- package/dist/client/assets/vbnet-vqH9_0Ma.js +1 -0
- package/dist/client/assets/vbscript-CXsWPnMk.js +1 -0
- package/dist/client/assets/vbscript-html-B6D_PN9T.js +1 -0
- package/dist/client/assets/vector_db_qa-Dl73pdLE.js +9 -0
- package/dist/client/assets/velocity-BovabnLc.js +1 -0
- package/dist/client/assets/verilog-DroIKKk3.js +1 -0
- package/dist/client/assets/verilog-VwZ_BUzH.js +1 -0
- package/dist/client/assets/vhdl-BiGLm3u6.js +1 -0
- package/dist/client/assets/vhdl-taMaJCau.js +1 -0
- package/dist/client/assets/vim-Bb-DygKM.js +1 -0
- package/dist/client/assets/vim-Xh36tdBL.js +1 -0
- package/dist/client/assets/visual-basic-D2m-ZC8T.js +1 -0
- package/dist/client/assets/warpscript-YLGBYh6G.js +1 -0
- package/dist/client/assets/wasm-BHWPsKqd.js +1 -0
- package/dist/client/assets/web-idl-9w-kVVy3.js +1 -0
- package/dist/client/assets/wiki-C4aEAQsg.js +1 -0
- package/dist/client/assets/wolfram-CJBoH9IO.js +1 -0
- package/dist/client/assets/wren-C8PfUac6.js +1 -0
- package/dist/client/assets/x86asm-C_x8h4KC.js +1 -0
- package/dist/client/assets/xeora-CEF6aMGJ.js +1 -0
- package/dist/client/assets/xl-33K-LjPn.js +1 -0
- package/dist/client/assets/xml-DjWiials.js +1 -0
- package/dist/client/assets/xml-doc-Bf_ueS1d.js +1 -0
- package/dist/client/assets/xojo-DPFQcYAC.js +1 -0
- package/dist/client/assets/xquery-CxdnVY9l.js +1 -0
- package/dist/client/assets/xquery-F0cAQCqq.js +1 -0
- package/dist/client/assets/yaml-BNSiEiNu.js +1 -0
- package/dist/client/assets/yaml-CKP_qo6T.js +1 -0
- package/dist/client/assets/yang-DnKFU7Us.js +1 -0
- package/dist/client/assets/zephir-Bn5eEsal.js +1 -0
- package/dist/client/assets/zig-BXjkkJwj.js +1 -0
- package/dist/client/assets/zodToJsonSchema-DueTETVe.js +8 -0
- package/dist/client/index.html +3 -3
- package/dist/server/chunk-64PVSQ35.js +115 -0
- package/dist/server/chunk-ITXAOTZI.js +195 -0
- package/dist/server/chunk-WCF7WJPU.js +211 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +6 -0
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +16 -278
- package/dist/server/shared-routes.d.ts +14 -0
- package/dist/server/shared-routes.d.ts.map +1 -0
- package/dist/server/shared-routes.js +10 -0
- package/dist/server/shared-static.d.ts +10 -0
- package/dist/server/shared-static.d.ts.map +1 -0
- package/dist/server/shared-static.js +10 -0
- package/dist/server/shared-utils-browser.d.ts +58 -0
- package/dist/server/shared-utils-browser.d.ts.map +1 -0
- package/dist/server/shared-utils-browser.js +9 -0
- package/package.json +2 -2
- package/dist/client/assets/1c-PqvIW6SA.js +0 -1
- package/dist/client/assets/abap-BelgPNR9.js +0 -1
- package/dist/client/assets/abnf-CEeM48hy.js +0 -1
- package/dist/client/assets/abnf-Cj2eJzks.js +0 -1
- package/dist/client/assets/accesslog-BS5KopaV.js +0 -1
- package/dist/client/assets/actionscript-B36rOfTq.js +0 -1
- package/dist/client/assets/actionscript-CghosOGs.js +0 -1
- package/dist/client/assets/ada-BUX6ujjk.js +0 -1
- package/dist/client/assets/ada-D1WrpsLK.js +0 -1
- package/dist/client/assets/agda-Blh6gBWZ.js +0 -1
- package/dist/client/assets/al-PdSYsap_.js +0 -1
- package/dist/client/assets/angelscript-B57iTJjL.js +0 -1
- package/dist/client/assets/antlr4-Cy6lJ2TV.js +0 -1
- package/dist/client/assets/apache-D5VqZ3UN.js +0 -1
- package/dist/client/assets/apacheconf-C-t-pOM6.js +0 -1
- package/dist/client/assets/apex-CWp8tDte.js +0 -1
- package/dist/client/assets/apl-BwRk4aGt.js +0 -1
- package/dist/client/assets/applescript-BGSQsLEj.js +0 -1
- package/dist/client/assets/applescript-D-TZt-fA.js +0 -1
- package/dist/client/assets/aql-D24KNg5P.js +0 -1
- package/dist/client/assets/arcade-DFoH8Qnf.js +0 -1
- package/dist/client/assets/arduino-DFYnlifP.js +0 -1
- package/dist/client/assets/arduino-Dx6PZeO3.js +0 -1
- package/dist/client/assets/arff-makXNtKY.js +0 -1
- package/dist/client/assets/armasm-CryDMqyu.js +0 -1
- package/dist/client/assets/asciidoc-Cuv7GzcI.js +0 -1
- package/dist/client/assets/asciidoc-Cyi2UbM2.js +0 -1
- package/dist/client/assets/asm6502-DWF4aoz3.js +0 -1
- package/dist/client/assets/asmatmel-CKRxZEVW.js +0 -1
- package/dist/client/assets/aspectj-DlWP2G3N.js +0 -1
- package/dist/client/assets/aspnet-DxQSQCWq.js +0 -1
- package/dist/client/assets/autohotkey-C3FVkUCg.js +0 -1
- package/dist/client/assets/autohotkey-CVo0l6LU.js +0 -1
- package/dist/client/assets/autoit-C1XBDSRu.js +0 -1
- package/dist/client/assets/autoit-DsPlZX_0.js +0 -1
- package/dist/client/assets/avisynth-D5BOhNzX.js +0 -1
- package/dist/client/assets/avrasm-B76BfEPk.js +0 -1
- package/dist/client/assets/avro-idl-BYLQ7gwz.js +0 -1
- package/dist/client/assets/awk-j_kWwjM_.js +0 -1
- package/dist/client/assets/axapta-BqqTtpXI.js +0 -1
- package/dist/client/assets/bash-Bax5rQzD.js +0 -1
- package/dist/client/assets/bash-CS2ZsL17.js +0 -1
- package/dist/client/assets/basic-DM88bxyf.js +0 -1
- package/dist/client/assets/basic-j4CflWCp.js +0 -1
- package/dist/client/assets/batch-B25J79Og.js +0 -1
- package/dist/client/assets/bbcode-C71lMxFC.js +0 -1
- package/dist/client/assets/bicep-C7SxY_1s.js +0 -1
- package/dist/client/assets/birb-CvP2EAV9.js +0 -1
- package/dist/client/assets/bison-DQiL2aM7.js +0 -1
- package/dist/client/assets/bnf-C0-ZbyvZ.js +0 -1
- package/dist/client/assets/bnf-C8REIHuK.js +0 -1
- package/dist/client/assets/brainfuck-Br2Kwq3E.js +0 -1
- package/dist/client/assets/brainfuck-hg_3TaHX.js +0 -1
- package/dist/client/assets/brightscript-C4SqnBe-.js +0 -1
- package/dist/client/assets/bro-gyj2mAPX.js +0 -1
- package/dist/client/assets/bsl-DzMczg3l.js +0 -1
- package/dist/client/assets/c-like-Dl4yypz6.js +0 -1
- package/dist/client/assets/c-smqcsO6d.js +0 -1
- package/dist/client/assets/c-vemspO5D.js +0 -1
- package/dist/client/assets/cal-MRXTtIlv.js +0 -1
- package/dist/client/assets/capnproto-ggQ_-3vu.js +0 -1
- package/dist/client/assets/ceylon-Pf4R8GB5.js +0 -1
- package/dist/client/assets/cfscript-D7IAtjdU.js +0 -1
- package/dist/client/assets/chaiscript-gb6Nplw4.js +0 -1
- package/dist/client/assets/cil-DoVcPR2t.js +0 -1
- package/dist/client/assets/clean-BylB4Wcr.js +0 -1
- package/dist/client/assets/clike-C9djHdbe.js +0 -1
- package/dist/client/assets/clojure-Cg_6RksI.js +0 -1
- package/dist/client/assets/clojure-ktQqrkdJ.js +0 -1
- package/dist/client/assets/clojure-repl-0X--WhhR.js +0 -1
- package/dist/client/assets/cmake-DuRpnx9C.js +0 -1
- package/dist/client/assets/cmake-f9Owxa0e.js +0 -1
- package/dist/client/assets/cobol-DNT4YVO8.js +0 -1
- package/dist/client/assets/coffeescript-C3VmTx1F.js +0 -1
- package/dist/client/assets/coffeescript-mXgQgDBD.js +0 -1
- package/dist/client/assets/concurnas-hIXFse1k.js +0 -1
- package/dist/client/assets/coq-rojx-u25.js +0 -1
- package/dist/client/assets/coq-u54Tu7uM.js +0 -1
- package/dist/client/assets/cos-BuNDEnV_.js +0 -1
- package/dist/client/assets/cpp-BsxIUPzG.js +0 -1
- package/dist/client/assets/cpp-kqGL0-RY.js +0 -1
- package/dist/client/assets/crmsh-DW_tBn6g.js +0 -1
- package/dist/client/assets/crystal-CorlR1lW.js +0 -1
- package/dist/client/assets/crystal-DQXY8IGf.js +0 -1
- package/dist/client/assets/csharp-CfBoiT3X.js +0 -1
- package/dist/client/assets/csharp-TVtaTQDE.js +0 -1
- package/dist/client/assets/cshtml-oa1h_cwA.js +0 -1
- package/dist/client/assets/csp-DUy_gvFA.js +0 -1
- package/dist/client/assets/csp-DaTcNKRb.js +0 -1
- package/dist/client/assets/css-DJkC9IAE.js +0 -1
- package/dist/client/assets/css-DYNgXBLh.js +0 -1
- package/dist/client/assets/css-extras-BnfbNYaP.js +0 -1
- package/dist/client/assets/csv-OdcWDCVf.js +0 -1
- package/dist/client/assets/cypher-DW2nA7nO.js +0 -1
- package/dist/client/assets/d-Bnbo9teU.js +0 -1
- package/dist/client/assets/d-C9_IrnzN.js +0 -1
- package/dist/client/assets/dart-4wZ-fiyX.js +0 -1
- package/dist/client/assets/dart-DCrnLbxG.js +0 -1
- package/dist/client/assets/dataweave-gbdqlJOu.js +0 -1
- package/dist/client/assets/dax-DVGnED9r.js +0 -1
- package/dist/client/assets/delphi-C9bu_N8X.js +0 -1
- package/dist/client/assets/dhall-CQ_09OqU.js +0 -1
- package/dist/client/assets/diff-CLAKSpiP.js +0 -1
- package/dist/client/assets/diff-D_i66Wu6.js +0 -1
- package/dist/client/assets/django-BNTmcGd2.js +0 -1
- package/dist/client/assets/django-C5gZ93CT.js +0 -1
- package/dist/client/assets/dns-0tTeXz8U.js +0 -1
- package/dist/client/assets/dns-zone-file-00-cWTIY.js +0 -1
- package/dist/client/assets/docker-YU7m3T9O.js +0 -1
- package/dist/client/assets/dockerfile-CkuIU-9c.js +0 -1
- package/dist/client/assets/dos-CzYVK19Y.js +0 -1
- package/dist/client/assets/dot-fhaEknCB.js +0 -1
- package/dist/client/assets/dsconfig-BuXhMpfM.js +0 -1
- package/dist/client/assets/dts-Cbyx7VH8.js +0 -1
- package/dist/client/assets/dust-q29lMG-Y.js +0 -1
- package/dist/client/assets/ebnf-AxluDBNC.js +0 -1
- package/dist/client/assets/ebnf-CT56IjeN.js +0 -1
- package/dist/client/assets/editorconfig-zTIBFx-5.js +0 -1
- package/dist/client/assets/eiffel-CxIUujGF.js +0 -1
- package/dist/client/assets/ejs-fxUoujMW.js +0 -1
- package/dist/client/assets/elixir-Blwj-NS1.js +0 -1
- package/dist/client/assets/elixir-CP1wfVRP.js +0 -1
- package/dist/client/assets/elm-BIc--Snd.js +0 -1
- package/dist/client/assets/elm-BOegK_Le.js +0 -1
- package/dist/client/assets/erb-CIKmTa1j.js +0 -1
- package/dist/client/assets/erb-VQAidlR5.js +0 -1
- package/dist/client/assets/erlang-CyAjKDd-.js +0 -1
- package/dist/client/assets/erlang-fn4v6iw6.js +0 -1
- package/dist/client/assets/erlang-repl-QqB2rMxU.js +0 -1
- package/dist/client/assets/etlua-CYsus25N.js +0 -1
- package/dist/client/assets/excel-24R22AVy.js +0 -1
- package/dist/client/assets/excel-formula-CMIeKycl.js +0 -1
- package/dist/client/assets/factor-B_57o35H.js +0 -1
- package/dist/client/assets/false-CcMnSase.js +0 -1
- package/dist/client/assets/firestore-security-rules-CzQH3Ez7.js +0 -1
- package/dist/client/assets/fix-bvxZr6vI.js +0 -1
- package/dist/client/assets/flix-CohKtx_z.js +0 -1
- package/dist/client/assets/flow-DBm4T5h5.js +0 -1
- package/dist/client/assets/fortran-BxyOCfB-.js +0 -1
- package/dist/client/assets/fortran-BzZTVxUy.js +0 -1
- package/dist/client/assets/fsharp-CZEAdz34.js +0 -1
- package/dist/client/assets/fsharp-iHZ8MX6O.js +0 -1
- package/dist/client/assets/ftl-CugoJTf9.js +0 -1
- package/dist/client/assets/gams-Cq76o3M-.js +0 -1
- package/dist/client/assets/gap-CEnckQoT.js +0 -1
- package/dist/client/assets/gauss-CIV1aLHQ.js +0 -1
- package/dist/client/assets/gcode-Cw42XjR0.js +0 -1
- package/dist/client/assets/gcode-L0KpR6Rl.js +0 -1
- package/dist/client/assets/gdscript-BNmuHvxU.js +0 -1
- package/dist/client/assets/gedcom-oplvdpf9.js +0 -1
- package/dist/client/assets/gherkin-CDWxYJuD.js +0 -1
- package/dist/client/assets/gherkin-DDgZB-HP.js +0 -1
- package/dist/client/assets/git-DU0TZvlm.js +0 -1
- package/dist/client/assets/glsl-CL632KcI.js +0 -1
- package/dist/client/assets/glsl-CkzScgIt.js +0 -1
- package/dist/client/assets/gml-C3IZRUKj.js +0 -1
- package/dist/client/assets/gml-FUSaNcv8.js +0 -1
- package/dist/client/assets/gn-Dl3gBdEg.js +0 -1
- package/dist/client/assets/go-BIxp-H1I.js +0 -1
- package/dist/client/assets/go-CoEC45wa.js +0 -1
- package/dist/client/assets/go-module-DMeHiY8o.js +0 -1
- package/dist/client/assets/golo-BKfHfKsC.js +0 -1
- package/dist/client/assets/gradle-SZS-JZLO.js +0 -1
- package/dist/client/assets/graphql-BuQO5Mrr.js +0 -1
- package/dist/client/assets/groovy-Ip-S4scK.js +0 -1
- package/dist/client/assets/groovy-SdBmZv2u.js +0 -1
- package/dist/client/assets/haml-CeX2l1v-.js +0 -1
- package/dist/client/assets/haml-DTgrUzFG.js +0 -1
- package/dist/client/assets/handlebars-B9ixiNj0.js +0 -1
- package/dist/client/assets/handlebars-COVdTa35.js +0 -1
- package/dist/client/assets/haskell-ByaNOAXE.js +0 -1
- package/dist/client/assets/haskell-D2O0V0HZ.js +0 -1
- package/dist/client/assets/haxe-Bwp-176T.js +0 -1
- package/dist/client/assets/haxe-C7BMBCwV.js +0 -1
- package/dist/client/assets/hcl-Bt7ykFMI.js +0 -1
- package/dist/client/assets/hlsl-D3oVpCST.js +0 -1
- package/dist/client/assets/hoon-De-xveic.js +0 -1
- package/dist/client/assets/hpkp-BywwbeUV.js +0 -1
- package/dist/client/assets/hsp-DOzjcKiY.js +0 -1
- package/dist/client/assets/hsts-6KuMA87-.js +0 -1
- package/dist/client/assets/htmlbars-DJc15m3r.js +0 -1
- package/dist/client/assets/http-Cg8mLPnI.js +0 -1
- package/dist/client/assets/http-D2RJQojN.js +0 -1
- package/dist/client/assets/hy-DctawBC8.js +0 -1
- package/dist/client/assets/ichigojam-CUrrEA3H.js +0 -1
- package/dist/client/assets/icon-BupOe3wF.js +0 -1
- package/dist/client/assets/icu-message-format-BAbI-QAD.js +0 -1
- package/dist/client/assets/idris-BWFQ-nN-.js +0 -1
- package/dist/client/assets/iecst-YzBmgNBV.js +0 -1
- package/dist/client/assets/ignore-Bd706Oq6.js +0 -1
- package/dist/client/assets/index-Ck7Qs7an.css +0 -1
- package/dist/client/assets/index-Cy3m9aYL.js +0 -1751
- package/dist/client/assets/inform7-DNvbuiSo.js +0 -1
- package/dist/client/assets/inform7-bKdoGMtw.js +0 -1
- package/dist/client/assets/ini-BhTiO_Ux.js +0 -1
- package/dist/client/assets/ini-bSfMwH8M.js +0 -1
- package/dist/client/assets/io-D-38ELdi.js +0 -1
- package/dist/client/assets/irpf90-DvGYmKk8.js +0 -1
- package/dist/client/assets/isbl-BpuzaC-J.js +0 -1
- package/dist/client/assets/j-C1MKtJ4T.js +0 -1
- package/dist/client/assets/java-DrkXtYXZ.js +0 -1
- package/dist/client/assets/java-KlyEglHf.js +0 -1
- package/dist/client/assets/javadoc-CvxNq7nj.js +0 -1
- package/dist/client/assets/javadoclike-CP20cwli.js +0 -1
- package/dist/client/assets/javascript-B0UI8Dmt.js +0 -1
- package/dist/client/assets/javascript-CUohYg-4.js +0 -1
- package/dist/client/assets/javastacktrace-MIo11Z2f.js +0 -1
- package/dist/client/assets/jboss-cli-_CTFWmTd.js +0 -1
- package/dist/client/assets/jexl-CavV8R1G.js +0 -1
- package/dist/client/assets/jolie-BGGmiVZe.js +0 -1
- package/dist/client/assets/jq-0gtHFFdV.js +0 -1
- package/dist/client/assets/js-extras-ijurcxf8.js +0 -1
- package/dist/client/assets/js-templates-DQg4oOLh.js +0 -1
- package/dist/client/assets/jsdoc-2udSoQpT.js +0 -1
- package/dist/client/assets/json-CI4oYK49.js +0 -1
- package/dist/client/assets/json-DoXf83jP.js +0 -1
- package/dist/client/assets/json5-Br4gEsUV.js +0 -1
- package/dist/client/assets/jsonp-B5BfAAJc.js +0 -1
- package/dist/client/assets/jsstacktrace-Bo8q_h5l.js +0 -1
- package/dist/client/assets/jsx-DI-OH9kR.js +0 -1
- package/dist/client/assets/julia-BH5c9L9E.js +0 -1
- package/dist/client/assets/julia-DJHKLbaf.js +0 -1
- package/dist/client/assets/julia-repl-D7KluTJr.js +0 -1
- package/dist/client/assets/keepalived-BzA3F1oa.js +0 -1
- package/dist/client/assets/keyman-D1qXZnqN.js +0 -1
- package/dist/client/assets/kotlin-BB-Ajng9.js +0 -1
- package/dist/client/assets/kotlin-CIlAYWDb.js +0 -1
- package/dist/client/assets/kumir-Bt4HQ139.js +0 -1
- package/dist/client/assets/kusto-BL8YUwX_.js +0 -1
- package/dist/client/assets/lasso-Bftb53pp.js +0 -1
- package/dist/client/assets/latex-BhCrDjrc.js +0 -1
- package/dist/client/assets/latex-DDq5wpjY.js +0 -1
- package/dist/client/assets/latte-CoOBhGsu.js +0 -1
- package/dist/client/assets/ldif-zHaI5CJK.js +0 -1
- package/dist/client/assets/leaf-CIifw1r4.js +0 -1
- package/dist/client/assets/less-B_rDg9fP.js +0 -1
- package/dist/client/assets/less-D7j-00ml.js +0 -1
- package/dist/client/assets/lilypond-_39Tmwqu.js +0 -1
- package/dist/client/assets/liquid-CwPo9tD3.js +0 -1
- package/dist/client/assets/lisp-4l9f0rLB.js +0 -1
- package/dist/client/assets/lisp-CIQ0lv4S.js +0 -1
- package/dist/client/assets/livecodeserver-Ddp-Eqw3.js +0 -1
- package/dist/client/assets/livescript-Cs3Extyk.js +0 -1
- package/dist/client/assets/livescript-EidzCbzw.js +0 -1
- package/dist/client/assets/llvm-CtsC6M1F.js +0 -1
- package/dist/client/assets/llvm-DXYVhqUZ.js +0 -1
- package/dist/client/assets/log-B3GTD9Zp.js +0 -1
- package/dist/client/assets/lolcode-Bak-2457.js +0 -1
- package/dist/client/assets/lsl-Bn38RFsW.js +0 -1
- package/dist/client/assets/lua-frcfnvd5.js +0 -1
- package/dist/client/assets/lua-reBOt9Qc.js +0 -1
- package/dist/client/assets/magma-Dfn9jCb1.js +0 -1
- package/dist/client/assets/makefile-1VrSPBEE.js +0 -1
- package/dist/client/assets/makefile-DsP7T_Ei.js +0 -1
- package/dist/client/assets/markdown-ApxS9W1u.js +0 -1
- package/dist/client/assets/markdown-CbdU1KS3.js +0 -1
- package/dist/client/assets/markup-kikX4Srb.js +0 -1
- package/dist/client/assets/markup-templating-BhTi6Zv2.js +0 -1
- package/dist/client/assets/mathematica-B_ymujac.js +0 -1
- package/dist/client/assets/matlab-BfwkIcY0.js +0 -1
- package/dist/client/assets/matlab-DgrI8PhT.js +0 -1
- package/dist/client/assets/maxima-BCBFBxHU.js +0 -1
- package/dist/client/assets/maxscript-B_ffO9vL.js +0 -1
- package/dist/client/assets/mel-BIi14igQ.js +0 -1
- package/dist/client/assets/mel-BhZQ5sRR.js +0 -1
- package/dist/client/assets/mercury-BXuaIMS8.js +0 -1
- package/dist/client/assets/mermaid-CNSLnAz1.js +0 -1
- package/dist/client/assets/mipsasm-BaC7G4fM.js +0 -1
- package/dist/client/assets/mizar-BzpVK25S.js +0 -1
- package/dist/client/assets/mizar-gtErANNO.js +0 -1
- package/dist/client/assets/mojolicious-BKO88W4a.js +0 -1
- package/dist/client/assets/mongodb-xMiAAI9M.js +0 -1
- package/dist/client/assets/monkey-Cr7En-7e.js +0 -1
- package/dist/client/assets/monkey-Dw_oRyoZ.js +0 -1
- package/dist/client/assets/moonscript-DxUoHvU9.js +0 -1
- package/dist/client/assets/moonscript-gRKZFzx9.js +0 -1
- package/dist/client/assets/n1ql-BI1i7rNp.js +0 -1
- package/dist/client/assets/n1ql-BdWs_J58.js +0 -1
- package/dist/client/assets/n4js-CDnOfsi7.js +0 -1
- package/dist/client/assets/nand2tetris-hdl-p1dmfaDZ.js +0 -1
- package/dist/client/assets/naniscript-CwZWi_NC.js +0 -1
- package/dist/client/assets/nasm-Bt5CPZ4F.js +0 -1
- package/dist/client/assets/neon-CGyckrqJ.js +0 -1
- package/dist/client/assets/nevod-ByFtnK9Z.js +0 -1
- package/dist/client/assets/nginx-COWw32Jq.js +0 -1
- package/dist/client/assets/nginx-DwZrICQ4.js +0 -1
- package/dist/client/assets/nim-CKdiMe-W.js +0 -1
- package/dist/client/assets/nim-Cp20bFC6.js +0 -1
- package/dist/client/assets/nix-DqRJXXwQ.js +0 -1
- package/dist/client/assets/nix-y2J7z1cM.js +0 -1
- package/dist/client/assets/node-repl-H1gy43Ls.js +0 -1
- package/dist/client/assets/nsis-Bo3H_KNf.js +0 -1
- package/dist/client/assets/nsis-CwvvrjXZ.js +0 -1
- package/dist/client/assets/objectivec-B2baZOGn.js +0 -1
- package/dist/client/assets/objectivec-CIKs0e2s.js +0 -1
- package/dist/client/assets/ocaml-BtmnhzAV.js +0 -1
- package/dist/client/assets/ocaml-CRKckqXU.js +0 -1
- package/dist/client/assets/opencl-DnEJH3tl.js +0 -1
- package/dist/client/assets/openqasm-C4pSJ1Lz.js +0 -1
- package/dist/client/assets/openscad-m06aVSiu.js +0 -1
- package/dist/client/assets/oxygene-F4jw9ijz.js +0 -1
- package/dist/client/assets/oz-fKbxlquf.js +0 -1
- package/dist/client/assets/parigp-Bab5JV43.js +0 -1
- package/dist/client/assets/parser-BN_kZcMf.js +0 -1
- package/dist/client/assets/parser3-BPU8TcZm.js +0 -1
- package/dist/client/assets/pascal-Bi2NUjn_.js +0 -1
- package/dist/client/assets/pascaligo-FrCgTygh.js +0 -1
- package/dist/client/assets/pcaxis-DapRsmSF.js +0 -1
- package/dist/client/assets/peoplecode-Bni8ZIYn.js +0 -1
- package/dist/client/assets/perl-B2QfDra3.js +0 -1
- package/dist/client/assets/perl-Ba2POgEe.js +0 -1
- package/dist/client/assets/pf-BLCA4UBZ.js +0 -1
- package/dist/client/assets/pgsql-uNtwUpSN.js +0 -1
- package/dist/client/assets/php-Dw8LKZRS.js +0 -1
- package/dist/client/assets/php-c_XYv3KV.js +0 -1
- package/dist/client/assets/php-extras-v6npZ0Az.js +0 -1
- package/dist/client/assets/php-template-okOd90r_.js +0 -1
- package/dist/client/assets/phpdoc-C_0yiIZf.js +0 -1
- package/dist/client/assets/plaintext-Q5C0U37U.js +0 -1
- package/dist/client/assets/plsql-CXnRMDVK.js +0 -1
- package/dist/client/assets/pony-CZpozjYU.js +0 -1
- package/dist/client/assets/powerquery-BSGXNA0V.js +0 -1
- package/dist/client/assets/powershell-B4-yQyEW.js +0 -1
- package/dist/client/assets/powershell-DuVwH5Ev.js +0 -1
- package/dist/client/assets/processing-D1kHatyN.js +0 -1
- package/dist/client/assets/processing-DoIEZbvV.js +0 -1
- package/dist/client/assets/profile-DauYVSAu.js +0 -1
- package/dist/client/assets/prolog-DTjFJ5Gd.js +0 -1
- package/dist/client/assets/prolog-DayJ-s9T.js +0 -1
- package/dist/client/assets/promql-DUIF6hRh.js +0 -1
- package/dist/client/assets/properties-Bg6mwP6v.js +0 -1
- package/dist/client/assets/properties-DCfcYzV9.js +0 -1
- package/dist/client/assets/protobuf-CNPefqb0.js +0 -1
- package/dist/client/assets/protobuf-DAy8qINX.js +0 -1
- package/dist/client/assets/psl-B1BQjuQc.js +0 -1
- package/dist/client/assets/pug-CtZ0-X8J.js +0 -1
- package/dist/client/assets/puppet-DJbZlWLs.js +0 -1
- package/dist/client/assets/puppet-H1L99DPJ.js +0 -1
- package/dist/client/assets/pure-DqSpIlkB.js +0 -1
- package/dist/client/assets/purebasic-Ca_xuLxc.js +0 -1
- package/dist/client/assets/purebasic-Lw-c9fjD.js +0 -1
- package/dist/client/assets/purescript-Cx0LhCuw.js +0 -1
- package/dist/client/assets/python-BZ0zcVB2.js +0 -1
- package/dist/client/assets/python-OZLvhRFv.js +0 -1
- package/dist/client/assets/python-repl-CKhW9TWa.js +0 -1
- package/dist/client/assets/q-BLMcwOtC.js +0 -1
- package/dist/client/assets/q-CVAjh3WU.js +0 -1
- package/dist/client/assets/qml-Dwdhs-JD.js +0 -1
- package/dist/client/assets/qml-bSGOTnNZ.js +0 -1
- package/dist/client/assets/qore-JeHVzYZS.js +0 -1
- package/dist/client/assets/qsharp-LbMqMzTl.js +0 -1
- package/dist/client/assets/r-CjpPv3sz.js +0 -1
- package/dist/client/assets/r-pLgm_IkM.js +0 -1
- package/dist/client/assets/racket-C_sJszik.js +0 -1
- package/dist/client/assets/reason-C9XC1FeF.js +0 -1
- package/dist/client/assets/reasonml-CSodofD_.js +0 -1
- package/dist/client/assets/regex-DGnOIdjT.js +0 -1
- package/dist/client/assets/rego-Y7-EtrxG.js +0 -1
- package/dist/client/assets/renpy-B90OOFM2.js +0 -1
- package/dist/client/assets/rest-DVufLd56.js +0 -1
- package/dist/client/assets/rib-DYXxa5TZ.js +0 -1
- package/dist/client/assets/rip-AG18bzN-.js +0 -1
- package/dist/client/assets/roboconf-Bt4CAEOV.js +0 -1
- package/dist/client/assets/roboconf-CruQ4d6h.js +0 -1
- package/dist/client/assets/robotframework-Bi8Lkfxo.js +0 -1
- package/dist/client/assets/routeros-CTG7EhTq.js +0 -1
- package/dist/client/assets/rsl-BwPYqLZJ.js +0 -1
- package/dist/client/assets/ruby-CUpensY-.js +0 -1
- package/dist/client/assets/ruby-OXQwg_4q.js +0 -1
- package/dist/client/assets/ruleslanguage-CVXvg3hQ.js +0 -1
- package/dist/client/assets/rust-BXCHAsps.js +0 -1
- package/dist/client/assets/rust-CqiTpIlx.js +0 -1
- package/dist/client/assets/sas-7VqkMty_.js +0 -1
- package/dist/client/assets/sas-xgOHrTyQ.js +0 -1
- package/dist/client/assets/sass-Css_KIkX.js +0 -1
- package/dist/client/assets/scala-CVqeOMDO.js +0 -1
- package/dist/client/assets/scala-XzlAmOMD.js +0 -1
- package/dist/client/assets/scheme-CO1TpD7C.js +0 -1
- package/dist/client/assets/scheme-DCwRingc.js +0 -1
- package/dist/client/assets/scilab-pokPHqec.js +0 -1
- package/dist/client/assets/scss-CyRe9xeH.js +0 -1
- package/dist/client/assets/scss-D-NMsr6H.js +0 -1
- package/dist/client/assets/shell-BG95lyQH.js +0 -1
- package/dist/client/assets/shell-session-CEc9By_i.js +0 -1
- package/dist/client/assets/smali-C57XQY9P.js +0 -1
- package/dist/client/assets/smali-Dk12rb91.js +0 -1
- package/dist/client/assets/smalltalk-BTwL10Ph.js +0 -1
- package/dist/client/assets/smalltalk-DlWwMguN.js +0 -1
- package/dist/client/assets/smarty-CnKP4Uw4.js +0 -1
- package/dist/client/assets/sml-BQccgEkB.js +0 -1
- package/dist/client/assets/sml-DrlkdC9Y.js +0 -1
- package/dist/client/assets/solidity-Dvk-QEsy.js +0 -1
- package/dist/client/assets/solution-file-CZ36jeQw.js +0 -1
- package/dist/client/assets/soy-Cj6RNkwH.js +0 -1
- package/dist/client/assets/sparql-CGlDRY61.js +0 -1
- package/dist/client/assets/splunk-spl-c7ApjsvO.js +0 -1
- package/dist/client/assets/sqf-BNZ8g-QB.js +0 -1
- package/dist/client/assets/sqf-CrfM-U2O.js +0 -1
- package/dist/client/assets/sql-BnhCwxSW.js +0 -1
- package/dist/client/assets/sql-DqEq8Oyn.js +0 -1
- package/dist/client/assets/sql_more-viS599yU.js +0 -1
- package/dist/client/assets/squirrel-B7Ax4QUZ.js +0 -1
- package/dist/client/assets/stan-B0emjQf0.js +0 -1
- package/dist/client/assets/stan-DrW1-7Zo.js +0 -1
- package/dist/client/assets/stata-D1z_6oKT.js +0 -1
- package/dist/client/assets/step21-CSo2fPFh.js +0 -1
- package/dist/client/assets/stylus-DSH0cEZs.js +0 -1
- package/dist/client/assets/stylus-VBFjxQvx.js +0 -1
- package/dist/client/assets/subunit-Cut7Z046.js +0 -1
- package/dist/client/assets/swift-Ch44yT6Z.js +0 -1
- package/dist/client/assets/swift-pJAPjCEZ.js +0 -1
- package/dist/client/assets/systemd-DGMbWSvc.js +0 -1
- package/dist/client/assets/t4-cs-fn58V-uN.js +0 -1
- package/dist/client/assets/t4-templating-CfnBXWtj.js +0 -1
- package/dist/client/assets/t4-vb-Dd0C3hI0.js +0 -1
- package/dist/client/assets/taggerscript-CvicMPpV.js +0 -1
- package/dist/client/assets/tap-DAwz1913.js +0 -1
- package/dist/client/assets/tap-D_Urp1cK.js +0 -1
- package/dist/client/assets/tcl-CFowaoco.js +0 -1
- package/dist/client/assets/tcl-DHRJGygz.js +0 -1
- package/dist/client/assets/textile-Dfly9rTQ.js +0 -1
- package/dist/client/assets/thrift-C9EXu84V.js +0 -1
- package/dist/client/assets/toml-B89g-cUG.js +0 -1
- package/dist/client/assets/tp-CnV5Q4JZ.js +0 -1
- package/dist/client/assets/tremor-jOBGQvOD.js +0 -1
- package/dist/client/assets/tsx-BKLpg4qL.js +0 -1
- package/dist/client/assets/tt2-BNm2KDys.js +0 -1
- package/dist/client/assets/turtle-S-ENP6ld.js +0 -1
- package/dist/client/assets/twig-Cylcj4u8.js +0 -1
- package/dist/client/assets/twig-DQnPh7N5.js +0 -1
- package/dist/client/assets/typescript-CIBNEys2.js +0 -1
- package/dist/client/assets/typescript-cYLvxTbJ.js +0 -1
- package/dist/client/assets/typoscript-ZYm0YCvr.js +0 -1
- package/dist/client/assets/unrealscript-BvSm39Ue.js +0 -1
- package/dist/client/assets/uorazor-KZYIPTma.js +0 -1
- package/dist/client/assets/uri-CNcaOUZ5.js +0 -1
- package/dist/client/assets/v-D_7RfvgB.js +0 -1
- package/dist/client/assets/vala-BjZqBeZ8.js +0 -1
- package/dist/client/assets/vala-VkQiMYL3.js +0 -1
- package/dist/client/assets/vbnet-B6T3i4-b.js +0 -1
- package/dist/client/assets/vbnet-xnByL5z0.js +0 -1
- package/dist/client/assets/vbscript-DyJZkZCw.js +0 -1
- package/dist/client/assets/vbscript-html-DuIOMZOn.js +0 -1
- package/dist/client/assets/velocity-D53C0GVg.js +0 -1
- package/dist/client/assets/verilog-CgO3bhvZ.js +0 -1
- package/dist/client/assets/verilog-DgSZ-i1D.js +0 -1
- package/dist/client/assets/vhdl-C2pF0FRQ.js +0 -1
- package/dist/client/assets/vhdl-DBB3eVzb.js +0 -1
- package/dist/client/assets/vim-B5nFgRCO.js +0 -1
- package/dist/client/assets/vim-BKrK805V.js +0 -1
- package/dist/client/assets/visual-basic-sZvvMTQS.js +0 -1
- package/dist/client/assets/warpscript-DTzr0tvB.js +0 -1
- package/dist/client/assets/wasm-qBKYSfDo.js +0 -1
- package/dist/client/assets/web-idl-QGu3xmOs.js +0 -1
- package/dist/client/assets/wiki-BtUdgwX3.js +0 -1
- package/dist/client/assets/wolfram-_VLRe_VI.js +0 -1
- package/dist/client/assets/wren-DCAeYAio.js +0 -1
- package/dist/client/assets/x86asm-y5-uAHCt.js +0 -1
- package/dist/client/assets/xeora-B3SL41fu.js +0 -1
- package/dist/client/assets/xl-DO_Q47xK.js +0 -1
- package/dist/client/assets/xml-B9J8WYcq.js +0 -1
- package/dist/client/assets/xml-doc-R7Ouri_5.js +0 -1
- package/dist/client/assets/xojo-DBmeSVbv.js +0 -1
- package/dist/client/assets/xquery-BFnTbqti.js +0 -1
- package/dist/client/assets/xquery-BqAURrjq.js +0 -1
- package/dist/client/assets/yaml-B7RCjynQ.js +0 -1
- package/dist/client/assets/yaml-CknTuhGP.js +0 -1
- package/dist/client/assets/yang-Bm6yGkrE.js +0 -1
- package/dist/client/assets/zephir-B8TuMdMt.js +0 -1
- package/dist/client/assets/zig-xu0whDB7.js +0 -1
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Boe6IUZP.js","assets/index-BtU-sGqa.js","assets/index-DvNb1_yp.js","assets/index-DUE1m-ya.css","assets/zodToJsonSchema-DueTETVe.js","assets/deep-compare-strict-DtUHXpbW.js","assets/v4-BKrj-4V8.js","assets/llm_chain-CYdmV1P-.js","assets/sequential_chain-BSDR0Wvv.js","assets/combine_docs_chain-Bi09clmQ.js","assets/vector_db_qa-Dl73pdLE.js","assets/api_chain-3SKETdru.js","assets/few_shot-ZsJ5YbeJ.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var ih=Object.defineProperty;var ah=(n,e,t)=>e in n?ih(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var jr=(n,e,t)=>ah(n,typeof e!="symbol"?e+"":e,t);import{gA as xi,gB as le,gC as Me,gD as Bi,gE as qi,gw as pt,gF as sh,gG as oh,gy as cn,gH as uh,gx as lt,gI as lh,g as ch,gJ as fh,gK as No,gL as dh,gM as hh,gN as ph,gO as mh}from"./index-DvNb1_yp.js";import{r as gh,s as yh,v as Le,P as gt,p as ai,a as Lo,b as lf,h as bh,T as _h,d as vh,g as Lt,e as si,_ as wh,$ as Eh,t as Fo,z as Nt,f as ti}from"./zodToJsonSchema-DueTETVe.js";import{d as zi}from"./deep-compare-strict-DtUHXpbW.js";import{v as cf}from"./v4-BKrj-4V8.js";var Hi={},_n={},Gi,Do;function We(){if(Do)return Gi;Do=1;function n(p){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(b){return typeof b}:function(b){return b&&typeof Symbol=="function"&&b.constructor===Symbol&&b!==Symbol.prototype?"symbol":typeof b},n(p)}function e(p,b,w){return Object.defineProperty(p,"prototype",{writable:!1}),p}function t(p,b){if(!(p instanceof b))throw new TypeError("Cannot call a class as a function")}function r(p,b,w){return b=f(b),i(p,l()?Reflect.construct(b,w||[],f(p).constructor):b.apply(p,w))}function i(p,b){if(b&&(n(b)=="object"||typeof b=="function"))return b;if(b!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return a(p)}function a(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function s(p,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function");p.prototype=Object.create(b&&b.prototype,{constructor:{value:p,writable:!0,configurable:!0}}),Object.defineProperty(p,"prototype",{writable:!1}),b&&h(p,b)}function o(p){var b=typeof Map=="function"?new Map:void 0;return o=function(m){if(m===null||!c(m))return m;if(typeof m!="function")throw new TypeError("Super expression must either be null or a function");if(b!==void 0){if(b.has(m))return b.get(m);b.set(m,g)}function g(){return u(m,arguments,f(this).constructor)}return g.prototype=Object.create(m.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),h(g,m)},o(p)}function u(p,b,w){if(l())return Reflect.construct.apply(null,arguments);var m=[null];m.push.apply(m,b);var g=new(p.bind.apply(p,m));return w&&h(g,w.prototype),g}function l(){try{var p=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(l=function(){return!!p})()}function c(p){try{return Function.toString.call(p).indexOf("[native code]")!==-1}catch{return typeof p=="function"}}function h(p,b){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(w,m){return w.__proto__=m,w},h(p,b)}function f(p){return f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(b){return b.__proto__||Object.getPrototypeOf(b)},f(p)}var _=(function(p){function b(w){var m;return t(this,b),m=r(this,b,[`Format functions must be synchronous taking a two arguments: (info, opts)
|
|
3
|
+
Found: `.concat(w.toString().split(`
|
|
4
|
+
`)[0],`
|
|
5
|
+
`)]),Error.captureStackTrace(m,b),m}return s(b,p),e(b)})(o(Error));return Gi=function(p){if(p.length>2)throw new _(p);function b(){var m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.options=m}b.prototype.transform=p;function w(m){return new b(m)}return w.Format=b,w},Gi}var Mr={exports:{}},Vi={exports:{}},Wi={exports:{}};function ff(){return()=>{}}function df(n){return JSON.stringify(n)}function hf(){}function pf(){}const Sh={debuglog:ff,inspect:df,inherits:hf,format:pf},Oh=Object.freeze(Object.defineProperty({__proto__:null,debuglog:ff,default:Sh,format:pf,inherits:hf,inspect:df},Symbol.toStringTag,{value:"Module"})),ft=xi(Oh);var Ji={exports:{}},Uo;function Th(){return Uo||(Uo=1,(function(n){var e={};n.exports=e;var t={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgGray:[100,49],bgGrey:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(t).forEach(function(r){var i=t[r],a=e[r]=[];a.open="\x1B["+i[0]+"m",a.close="\x1B["+i[1]+"m"})})(Ji)),Ji.exports}const Ph={},Xr=Object.freeze(Object.defineProperty({__proto__:null,default:Ph},Symbol.toStringTag,{value:"Module"})),ut=xi(Xr);var Ki,Bo;function xh(){return Bo||(Bo=1,Ki=function(n,e){e=e||process.argv||[];var t=e.indexOf("--"),r=/^-{1,2}/.test(n)?"":"--",i=e.indexOf(r+n);return i!==-1&&(t===-1?!0:i<t)}),Ki}var Yi,qo;function Ah(){if(qo)return Yi;qo=1;var n={},e=xh(),t=n,r=void 0;e("no-color")||e("no-colors")||e("color=false")?r=!1:(e("color")||e("colors")||e("color=true")||e("color=always"))&&(r=!0),"FORCE_COLOR"in t&&(r=t.FORCE_COLOR.length===0||parseInt(t.FORCE_COLOR,10)!==0);function i(o){return o===0?!1:{level:o,hasBasic:!0,has256:o>=2,has16m:o>=3}}function a(o){if(r===!1)return 0;if(e("color=16m")||e("color=full")||e("color=truecolor"))return 3;if(e("color=256"))return 2;if(o&&!o.isTTY&&r!==!0)return 0;var u=r?1:0;if("CI"in t)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(function(c){return c in t})||t.CI_NAME==="codeship"?1:u;if("TEAMCITY_VERSION"in t)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(t.TEAMCITY_VERSION)?1:0;if("TERM_PROGRAM"in t){var l=parseInt((t.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(t.TERM_PROGRAM){case"iTerm.app":return l>=3?3:2;case"Hyper":return 3;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(t.TERM)?2:/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(t.TERM)||"COLORTERM"in t?1:(t.TERM==="dumb",u)}function s(o){var u=a(o);return i(u)}return Yi={supportsColor:s,stdout:s(process.stdout),stderr:s(process.stderr)},Yi}var Qi={exports:{}},zo;function Rh(){return zo||(zo=1,(function(n){n.exports=function(t,r){var i="";t=t||"Run the trap, drop the bass",t=t.split("");var a={a:["@","Ą","Ⱥ","Ʌ","Δ","Λ","Д"],b:["ß","Ɓ","Ƀ","ɮ","β","฿"],c:["©","Ȼ","Ͼ"],d:["Ð","Ɗ","Ԁ","ԁ","Ԃ","ԃ"],e:["Ë","ĕ","Ǝ","ɘ","Σ","ξ","Ҽ","੬"],f:["Ӻ"],g:["ɢ"],h:["Ħ","ƕ","Ң","Һ","Ӈ","Ԋ"],i:["༏"],j:["Ĵ"],k:["ĸ","Ҡ","Ӄ","Ԟ"],l:["Ĺ"],m:["ʍ","Ӎ","ӎ","Ԡ","ԡ","൩"],n:["Ñ","ŋ","Ɲ","Ͷ","Π","Ҋ"],o:["Ø","õ","ø","Ǿ","ʘ","Ѻ","ם","","๏"],p:["Ƿ","Ҏ"],q:["্"],r:["®","Ʀ","Ȑ","Ɍ","ʀ","Я"],s:["§","Ϟ","ϟ","Ϩ"],t:["Ł","Ŧ","ͳ"],u:["Ʊ","Ս"],v:["ט"],w:["Ш","Ѡ","Ѽ","൰"],x:["Ҳ","Ӿ","Ӽ","ӽ"],y:["¥","Ұ","Ӌ"],z:["Ƶ","ɀ"]};return t.forEach(function(s){s=s.toLowerCase();var o=a[s]||[" "],u=Math.floor(Math.random()*o.length);typeof a[s]<"u"?i+=a[s][u]:i+=s}),i}})(Qi)),Qi.exports}var Zi={exports:{}},Ho;function Ih(){return Ho||(Ho=1,(function(n){n.exports=function(t,r){t=t||" he is here ";var i={up:["̍","̎","̄","̅","̿","̑","̆","̐","͒","͗","͑","̇","̈","̊","͂","̓","̈","͊","͋","͌","̃","̂","̌","͐","̀","́","̋","̏","̒","̓","̔","̽","̉","ͣ","ͤ","ͥ","ͦ","ͧ","ͨ","ͩ","ͪ","ͫ","ͬ","ͭ","ͮ","ͯ","̾","͛","͆","̚"],down:["̖","̗","̘","̙","̜","̝","̞","̟","̠","̤","̥","̦","̩","̪","̫","̬","̭","̮","̯","̰","̱","̲","̳","̹","̺","̻","̼","ͅ","͇","͈","͉","͍","͎","͓","͔","͕","͖","͙","͚","̣"],mid:["̕","̛","̀","́","͘","̡","̢","̧","̨","̴","̵","̶","͜","͝","͞","͟","͠","͢","̸","̷","͡"," ҉"]},a=[].concat(i.up,i.down,i.mid);function s(l){var c=Math.floor(Math.random()*l);return c}function o(l){var c=!1;return a.filter(function(h){c=h===l}),c}function u(l,c){var h="",f,_;c=c||{},c.up=typeof c.up<"u"?c.up:!0,c.mid=typeof c.mid<"u"?c.mid:!0,c.down=typeof c.down<"u"?c.down:!0,c.size=typeof c.size<"u"?c.size:"maxi",l=l.split("");for(_ in l)if(!o(_)){switch(h=h+l[_],f={up:0,down:0,mid:0},c.size){case"mini":f.up=s(8),f.mid=s(2),f.down=s(8);break;case"maxi":f.up=s(16)+3,f.mid=s(4)+1,f.down=s(64)+3;break;default:f.up=s(8)+1,f.mid=s(6)/2,f.down=s(8)+1;break}var p=["up","mid","down"];for(var b in p)for(var w=p[b],m=0;m<=f[w];m++)c[w]&&(h=h+i[w][s(i[w].length)])}return h}return u(t,r)}})(Zi)),Zi.exports}var Xi={exports:{}},Go;function Ch(){return Go||(Go=1,(function(n){n.exports=function(e){return function(t,r,i){if(t===" ")return t;switch(r%3){case 0:return e.red(t);case 1:return e.white(t);case 2:return e.blue(t)}}}})(Xi)),Xi.exports}var ea={exports:{}},Vo;function $h(){return Vo||(Vo=1,(function(n){n.exports=function(e){return function(t,r,i){return r%2===0?t:e.inverse(t)}}})(ea)),ea.exports}var ta={exports:{}},Wo;function jh(){return Wo||(Wo=1,(function(n){n.exports=function(e){var t=["red","yellow","green","blue","magenta"];return function(r,i,a){return r===" "?r:e[t[i++%t.length]](r)}}})(ta)),ta.exports}var ra={exports:{}},Jo;function Mh(){return Jo||(Jo=1,(function(n){n.exports=function(e){var t=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta","brightYellow","brightRed","brightGreen","brightBlue","brightWhite","brightCyan","brightMagenta"];return function(r,i,a){return r===" "?r:e[t[Math.round(Math.random()*(t.length-2))]](r)}}})(ra)),ra.exports}var Ko;function kh(){return Ko||(Ko=1,(function(n){var e={};n.exports=e,e.themes={};var t=ft,r=e.styles=Th(),i=Object.defineProperties,a=new RegExp(/[\r\n]+/g);e.supportsColor=Ah().supportsColor,typeof e.enabled>"u"&&(e.enabled=e.supportsColor()!==!1),e.enable=function(){e.enabled=!0},e.disable=function(){e.enabled=!1},e.stripColors=e.strip=function(b){return(""+b).replace(/\x1B\[\d+m/g,"")},e.stylize=function(w,m){if(!e.enabled)return w+"";var g=r[m];return!g&&m in e?e[m](w):g.open+w+g.close};var s=/[|\\{}()[\]^$+*?.]/g,o=function(b){if(typeof b!="string")throw new TypeError("Expected a string");return b.replace(s,"\\$&")};function u(b){var w=function m(){return h.apply(m,arguments)};return w._styles=b,w.__proto__=c,w}var l=(function(){var b={};return r.grey=r.gray,Object.keys(r).forEach(function(w){r[w].closeRe=new RegExp(o(r[w].close),"g"),b[w]={get:function(){return u(this._styles.concat(w))}}}),b})(),c=i(function(){},l);function h(){var b=Array.prototype.slice.call(arguments),w=b.map(function(O){return O!=null&&O.constructor===String?O:t.inspect(O)}).join(" ");if(!e.enabled||!w)return w;for(var m=w.indexOf(`
|
|
6
|
+
`)!=-1,g=this._styles,v=g.length;v--;){var E=r[g[v]];w=E.open+w.replace(E.closeRe,E.open)+E.close,m&&(w=w.replace(a,function(O){return E.close+O+E.open}))}return w}e.setTheme=function(b){if(typeof b=="string"){console.log("colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));");return}for(var w in b)(function(m){e[m]=function(g){if(typeof b[m]=="object"){var v=g;for(var E in b[m])v=e[b[m][E]](v);return v}return e[b[m]](g)}})(w)};function f(){var b={};return Object.keys(l).forEach(function(w){b[w]={get:function(){return u([w])}}}),b}var _=function(w,m){var g=m.split("");return g=g.map(w),g.join("")};e.trap=Rh(),e.zalgo=Ih(),e.maps={},e.maps.america=Ch()(e),e.maps.zebra=$h()(e),e.maps.rainbow=jh()(e),e.maps.random=Mh()(e);for(var p in e.maps)(function(b){e[b]=function(w){return _(e.maps[b],w)}})(p);i(e,f())})(Wi)),Wi.exports}var Yo;function mf(){return Yo||(Yo=1,(function(n){var e=kh();n.exports=e})(Vi)),Vi.exports}var na={},ia={},vn={},Qo;function Nh(){return Qo||(Qo=1,vn.levels={error:0,warn:1,help:2,data:3,info:4,debug:5,prompt:6,verbose:7,input:8,silly:9},vn.colors={error:"red",warn:"yellow",help:"cyan",data:"grey",info:"green",debug:"blue",prompt:"grey",verbose:"cyan",input:"grey",silly:"magenta"}),vn}var wn={},Zo;function Lh(){return Zo||(Zo=1,wn.levels={error:0,warn:1,info:2,http:3,verbose:4,debug:5,silly:6},wn.colors={error:"red",warn:"yellow",info:"green",http:"green",verbose:"cyan",debug:"blue",silly:"magenta"}),wn}var En={},Xo;function Fh(){return Xo||(Xo=1,En.levels={emerg:0,alert:1,crit:2,error:3,warning:4,notice:5,info:6,debug:7},En.colors={emerg:"red",alert:"yellow",crit:"red",error:"red",warning:"red",notice:"yellow",info:"green",debug:"blue"}),En}var eu;function Dh(){return eu||(eu=1,(function(n){Object.defineProperty(n,"cli",{value:Nh()}),Object.defineProperty(n,"npm",{value:Lh()}),Object.defineProperty(n,"syslog",{value:Fh()})})(ia)),ia}var tu;function xe(){return tu||(tu=1,(function(n){Object.defineProperty(n,"LEVEL",{value:Symbol.for("level")}),Object.defineProperty(n,"MESSAGE",{value:Symbol.for("message")}),Object.defineProperty(n,"SPLAT",{value:Symbol.for("splat")}),Object.defineProperty(n,"configs",{value:Dh()})})(na)),na}var ru;function no(){if(ru)return Mr.exports;ru=1;function n(f){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(_){return typeof _}:function(_){return _&&typeof Symbol=="function"&&_.constructor===Symbol&&_!==Symbol.prototype?"symbol":typeof _},n(f)}function e(f,_){if(!(f instanceof _))throw new TypeError("Cannot call a class as a function")}function t(f,_){for(var p=0;p<_.length;p++){var b=_[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(f,i(b.key),b)}}function r(f,_,p){return _&&t(f.prototype,_),p&&t(f,p),Object.defineProperty(f,"prototype",{writable:!1}),f}function i(f){var _=a(f,"string");return n(_)=="symbol"?_:_+""}function a(f,_){if(n(f)!="object"||!f)return f;var p=f[Symbol.toPrimitive];if(p!==void 0){var b=p.call(f,_);if(n(b)!="object")return b;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(f)}var s=mf(),o=xe(),u=o.LEVEL,l=o.MESSAGE;s.enabled=!0;var c=/\s+/,h=(function(){function f(){var _=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e(this,f),_.colors&&this.addColors(_.colors),this.options=_}return r(f,[{key:"addColors",value:function(p){return f.addColors(p)}},{key:"colorize",value:function(p,b,w){if(typeof w>"u"&&(w=b),!Array.isArray(f.allColors[p]))return s[f.allColors[p]](w);for(var m=0,g=f.allColors[p].length;m<g;m++)w=s[f.allColors[p][m]](w);return w}},{key:"transform",value:function(p,b){return b.all&&typeof p[l]=="string"&&(p[l]=this.colorize(p[u],p.level,p[l])),(b.level||b.all||!b.message)&&(p.level=this.colorize(p[u],p.level)),(b.all||b.message)&&(p.message=this.colorize(p[u],p.level,p.message)),p}}],[{key:"addColors",value:function(p){var b=Object.keys(p).reduce(function(w,m){return w[m]=c.test(p[m])?p[m].split(c):p[m],w},{});return f.allColors=Object.assign({},f.allColors||{},b),f.allColors}}])})();return Mr.exports=function(f){return new h(f)},Mr.exports.Colorizer=Mr.exports.Format=h,Mr.exports}var aa,nu;function Uh(){if(nu)return aa;nu=1;var n=no(),e=n.Colorizer;return aa=function(t){return e.addColors(t.colors||t),t},aa}var sa,iu;function Bh(){if(iu)return sa;iu=1;var n=We();return sa=n(function(e){return e.message=" ".concat(e.message),e}),sa}var Sn={exports:{}},kr={exports:{}},au;function gf(){if(au)return kr.exports;au=1;function n(m){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(g){return typeof g}:function(g){return g&&typeof Symbol=="function"&&g.constructor===Symbol&&g!==Symbol.prototype?"symbol":typeof g},n(m)}function e(m){return a(m)||i(m)||r(m)||t()}function t(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
7
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function r(m,g){if(m){if(typeof m=="string")return s(m,g);var v={}.toString.call(m).slice(8,-1);return v==="Object"&&m.constructor&&(v=m.constructor.name),v==="Map"||v==="Set"?Array.from(m):v==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(v)?s(m,g):void 0}}function i(m){if(typeof Symbol<"u"&&m[Symbol.iterator]!=null||m["@@iterator"]!=null)return Array.from(m)}function a(m){if(Array.isArray(m))return s(m)}function s(m,g){(g==null||g>m.length)&&(g=m.length);for(var v=0,E=Array(g);v<g;v++)E[v]=m[v];return E}function o(m,g){if(!(m instanceof g))throw new TypeError("Cannot call a class as a function")}function u(m,g){for(var v=0;v<g.length;v++){var E=g[v];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(m,c(E.key),E)}}function l(m,g,v){return g&&u(m.prototype,g),v&&u(m,v),Object.defineProperty(m,"prototype",{writable:!1}),m}function c(m){var g=h(m,"string");return n(g)=="symbol"?g:g+""}function h(m,g){if(n(m)!="object"||!m)return m;var v=m[Symbol.toPrimitive];if(v!==void 0){var E=v.call(m,g);if(n(E)!="object")return E;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(m)}var f=xe(),_=f.configs,p=f.LEVEL,b=f.MESSAGE,w=(function(){function m(){var g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{levels:_.npm.levels};o(this,m),this.paddings=m.paddingForLevels(g.levels,g.filler),this.options=g}return l(m,[{key:"transform",value:function(v,E){return v.message="".concat(this.paddings[v[p]]).concat(v.message),v[b]&&(v[b]="".concat(this.paddings[v[p]]).concat(v[b])),v}}],[{key:"getLongestLevel",value:function(v){var E=Object.keys(v).map(function(O){return O.length});return Math.max.apply(Math,e(E))}},{key:"paddingForLevel",value:function(v,E,O){var C=O+1-v.length,R=Math.floor(C/E.length),I="".concat(E).concat(E.repeat(R));return I.slice(0,C)}},{key:"paddingForLevels",value:function(v){var E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:" ",O=m.getLongestLevel(v);return Object.keys(v).reduce(function(C,R){return C[R]=m.paddingForLevel(R,E,O),C},{})}}])})();return kr.exports=function(m){return new w(m)},kr.exports.Padder=kr.exports.Format=w,kr.exports}var su;function qh(){if(su)return Sn.exports;su=1;function n(p){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(b){return typeof b}:function(b){return b&&typeof Symbol=="function"&&b.constructor===Symbol&&b!==Symbol.prototype?"symbol":typeof b},n(p)}function e(p,b){if(!(p instanceof b))throw new TypeError("Cannot call a class as a function")}function t(p,b){for(var w=0;w<b.length;w++){var m=b[w];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(p,i(m.key),m)}}function r(p,b,w){return b&&t(p.prototype,b),Object.defineProperty(p,"prototype",{writable:!1}),p}function i(p){var b=a(p,"string");return n(b)=="symbol"?b:b+""}function a(p,b){if(n(p)!="object"||!p)return p;var w=p[Symbol.toPrimitive];if(w!==void 0){var m=w.call(p,b);if(n(m)!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(p)}var s=no(),o=s.Colorizer,u=gf(),l=u.Padder,c=xe(),h=c.configs,f=c.MESSAGE,_=(function(){function p(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e(this,p),b.levels||(b.levels=h.cli.levels),this.colorizer=new o(b),this.padder=new l(b),this.options=b}return r(p,[{key:"transform",value:function(w,m){return this.colorizer.transform(this.padder.transform(w,m),m),w[f]="".concat(w.level,":").concat(w.message),w}}])})();return Sn.exports=function(p){return new _(p)},Sn.exports.Format=_,Sn.exports}var On={exports:{}},ou;function zh(){if(ou)return On.exports;ou=1;var n=We();function e(r){if(r.every(t))return function(i){for(var a=i,s=0;s<r.length;s++)if(a=r[s].transform(a,r[s].options),!a)return!1;return a}}function t(r){if(typeof r.transform!="function")throw new Error(["No transform function found on format. Did you create a format instance?","const myFormat = format(formatFn);","const instance = myFormat();"].join(`
|
|
8
|
+
`));return!0}return On.exports=function(){for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];var s=n(e(i)),o=s();return o.Format=s.Format,o},On.exports.cascade=e,On.exports}var oa,uu;function Hh(){if(uu)return oa;uu=1;function n(u){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},n(u)}function e(u,l,c){return(l=t(l))in u?Object.defineProperty(u,l,{value:c,enumerable:!0,configurable:!0,writable:!0}):u[l]=c,u}function t(u){var l=r(u,"string");return n(l)=="symbol"?l:l+""}function r(u,l){if(n(u)!="object"||!u)return u;var c=u[Symbol.toPrimitive];if(c!==void 0){var h=c.call(u,l);if(n(h)!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(l==="string"?String:Number)(u)}var i=We(),a=xe(),s=a.LEVEL,o=a.MESSAGE;return oa=i(function(u,l){var c=l.stack,h=l.cause;if(u instanceof Error){var f=Object.assign({},u,e(e(e({level:u.level},s,u[s]||u.level),"message",u.message),o,u[o]||u.message));return c&&(f.stack=u.stack),h&&(f.cause=u.cause),f}if(!(u.message instanceof Error))return u;var _=u.message;return Object.assign(u,_),u.message=_.message,u[o]=_.message,c&&(u.stack=_.stack),h&&(u.cause=_.cause),u}),oa}var Tn={exports:{}},lu;function fn(){return lu||(lu=1,(function(n,e){const{hasOwnProperty:t}=Object.prototype,r=m();r.configure=m,r.stringify=r,r.default=r,e.stringify=r,e.configure=m,n.exports=r;const i=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function a(g){return g.length<5e3&&!i.test(g)?`"${g}"`:JSON.stringify(g)}function s(g,v){if(g.length>200||v)return g.sort(v);for(let E=1;E<g.length;E++){const O=g[E];let C=E;for(;C!==0&&g[C-1]>O;)g[C]=g[C-1],C--;g[C]=O}return g}const o=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function u(g){return o.call(g)!==void 0&&g.length!==0}function l(g,v,E){g.length<E&&(E=g.length);const O=v===","?"":" ";let C=`"0":${O}${g[0]}`;for(let R=1;R<E;R++)C+=`${v}"${R}":${O}${g[R]}`;return C}function c(g){if(t.call(g,"circularValue")){const v=g.circularValue;if(typeof v=="string")return`"${v}"`;if(v==null)return v;if(v===Error||v===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function h(g){let v;if(t.call(g,"deterministic")&&(v=g.deterministic,typeof v!="boolean"&&typeof v!="function"))throw new TypeError('The "deterministic" argument must be of type boolean or comparator function');return v===void 0?!0:v}function f(g,v){let E;if(t.call(g,v)&&(E=g[v],typeof E!="boolean"))throw new TypeError(`The "${v}" argument must be of type boolean`);return E===void 0?!0:E}function _(g,v){let E;if(t.call(g,v)){if(E=g[v],typeof E!="number")throw new TypeError(`The "${v}" argument must be of type number`);if(!Number.isInteger(E))throw new TypeError(`The "${v}" argument must be an integer`);if(E<1)throw new RangeError(`The "${v}" argument must be >= 1`)}return E===void 0?1/0:E}function p(g){return g===1?"1 item":`${g} items`}function b(g){const v=new Set;for(const E of g)(typeof E=="string"||typeof E=="number")&&v.add(String(E));return v}function w(g){if(t.call(g,"strict")){const v=g.strict;if(typeof v!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(v)return E=>{let O=`Object can not safely be stringified. Received type ${typeof E}`;throw typeof E!="function"&&(O+=` (${E.toString()})`),new Error(O)}}}function m(g){g={...g};const v=w(g);v&&(g.bigint===void 0&&(g.bigint=!1),"circularValue"in g||(g.circularValue=Error));const E=c(g),O=f(g,"bigint"),C=h(g),R=typeof C=="function"?C:void 0,I=_(g,"maximumDepth"),$=_(g,"maximumBreadth");function M(Z,j,D,G,U,H){let J=j[Z];switch(typeof J=="object"&&J!==null&&typeof J.toJSON=="function"&&(J=J.toJSON(Z)),J=G.call(j,Z,J),typeof J){case"string":return a(J);case"object":{if(J===null)return"null";if(D.indexOf(J)!==-1)return E;let X="",ae=",";const Q=H;if(Array.isArray(J)){if(J.length===0)return"[]";if(I<D.length+1)return'"[Array]"';D.push(J),U!==""&&(H+=U,X+=`
|
|
9
|
+
${H}`,ae=`,
|
|
10
|
+
${H}`);const oe=Math.min(J.length,$);let T=0;for(;T<oe-1;T++){const W=M(String(T),J,D,G,U,H);X+=W!==void 0?W:"null",X+=ae}const x=M(String(T),J,D,G,U,H);if(X+=x!==void 0?x:"null",J.length-1>$){const W=J.length-$-1;X+=`${ae}"... ${p(W)} not stringified"`}return U!==""&&(X+=`
|
|
11
|
+
${Q}`),D.pop(),`[${X}]`}let ee=Object.keys(J);const N=ee.length;if(N===0)return"{}";if(I<D.length+1)return'"[Object]"';let k="",V="";U!==""&&(H+=U,ae=`,
|
|
12
|
+
${H}`,k=" ");const se=Math.min(N,$);C&&!u(J)&&(ee=s(ee,R)),D.push(J);for(let oe=0;oe<se;oe++){const T=ee[oe],x=M(T,J,D,G,U,H);x!==void 0&&(X+=`${V}${a(T)}:${k}${x}`,V=ae)}if(N>$){const oe=N-$;X+=`${V}"...":${k}"${p(oe)} not stringified"`,V=ae}return U!==""&&V.length>1&&(X=`
|
|
13
|
+
${H}${X}
|
|
14
|
+
${Q}`),D.pop(),`{${X}}`}case"number":return isFinite(J)?String(J):v?v(J):"null";case"boolean":return J===!0?"true":"false";case"undefined":return;case"bigint":if(O)return String(J);default:return v?v(J):void 0}}function z(Z,j,D,G,U,H){switch(typeof j=="object"&&j!==null&&typeof j.toJSON=="function"&&(j=j.toJSON(Z)),typeof j){case"string":return a(j);case"object":{if(j===null)return"null";if(D.indexOf(j)!==-1)return E;const J=H;let X="",ae=",";if(Array.isArray(j)){if(j.length===0)return"[]";if(I<D.length+1)return'"[Array]"';D.push(j),U!==""&&(H+=U,X+=`
|
|
15
|
+
${H}`,ae=`,
|
|
16
|
+
${H}`);const N=Math.min(j.length,$);let k=0;for(;k<N-1;k++){const se=z(String(k),j[k],D,G,U,H);X+=se!==void 0?se:"null",X+=ae}const V=z(String(k),j[k],D,G,U,H);if(X+=V!==void 0?V:"null",j.length-1>$){const se=j.length-$-1;X+=`${ae}"... ${p(se)} not stringified"`}return U!==""&&(X+=`
|
|
17
|
+
${J}`),D.pop(),`[${X}]`}D.push(j);let Q="";U!==""&&(H+=U,ae=`,
|
|
18
|
+
${H}`,Q=" ");let ee="";for(const N of G){const k=z(N,j[N],D,G,U,H);k!==void 0&&(X+=`${ee}${a(N)}:${Q}${k}`,ee=ae)}return U!==""&&ee.length>1&&(X=`
|
|
19
|
+
${H}${X}
|
|
20
|
+
${J}`),D.pop(),`{${X}}`}case"number":return isFinite(j)?String(j):v?v(j):"null";case"boolean":return j===!0?"true":"false";case"undefined":return;case"bigint":if(O)return String(j);default:return v?v(j):void 0}}function B(Z,j,D,G,U){switch(typeof j){case"string":return a(j);case"object":{if(j===null)return"null";if(typeof j.toJSON=="function"){if(j=j.toJSON(Z),typeof j!="object")return B(Z,j,D,G,U);if(j===null)return"null"}if(D.indexOf(j)!==-1)return E;const H=U;if(Array.isArray(j)){if(j.length===0)return"[]";if(I<D.length+1)return'"[Array]"';D.push(j),U+=G;let k=`
|
|
21
|
+
${U}`;const V=`,
|
|
22
|
+
${U}`,se=Math.min(j.length,$);let oe=0;for(;oe<se-1;oe++){const x=B(String(oe),j[oe],D,G,U);k+=x!==void 0?x:"null",k+=V}const T=B(String(oe),j[oe],D,G,U);if(k+=T!==void 0?T:"null",j.length-1>$){const x=j.length-$-1;k+=`${V}"... ${p(x)} not stringified"`}return k+=`
|
|
23
|
+
${H}`,D.pop(),`[${k}]`}let J=Object.keys(j);const X=J.length;if(X===0)return"{}";if(I<D.length+1)return'"[Object]"';U+=G;const ae=`,
|
|
24
|
+
${U}`;let Q="",ee="",N=Math.min(X,$);u(j)&&(Q+=l(j,ae,$),J=J.slice(j.length),N-=j.length,ee=ae),C&&(J=s(J,R)),D.push(j);for(let k=0;k<N;k++){const V=J[k],se=B(V,j[V],D,G,U);se!==void 0&&(Q+=`${ee}${a(V)}: ${se}`,ee=ae)}if(X>$){const k=X-$;Q+=`${ee}"...": "${p(k)} not stringified"`,ee=ae}return ee!==""&&(Q=`
|
|
25
|
+
${U}${Q}
|
|
26
|
+
${H}`),D.pop(),`{${Q}}`}case"number":return isFinite(j)?String(j):v?v(j):"null";case"boolean":return j===!0?"true":"false";case"undefined":return;case"bigint":if(O)return String(j);default:return v?v(j):void 0}}function F(Z,j,D){switch(typeof j){case"string":return a(j);case"object":{if(j===null)return"null";if(typeof j.toJSON=="function"){if(j=j.toJSON(Z),typeof j!="object")return F(Z,j,D);if(j===null)return"null"}if(D.indexOf(j)!==-1)return E;let G="";const U=j.length!==void 0;if(U&&Array.isArray(j)){if(j.length===0)return"[]";if(I<D.length+1)return'"[Array]"';D.push(j);const Q=Math.min(j.length,$);let ee=0;for(;ee<Q-1;ee++){const k=F(String(ee),j[ee],D);G+=k!==void 0?k:"null",G+=","}const N=F(String(ee),j[ee],D);if(G+=N!==void 0?N:"null",j.length-1>$){const k=j.length-$-1;G+=`,"... ${p(k)} not stringified"`}return D.pop(),`[${G}]`}let H=Object.keys(j);const J=H.length;if(J===0)return"{}";if(I<D.length+1)return'"[Object]"';let X="",ae=Math.min(J,$);U&&u(j)&&(G+=l(j,",",$),H=H.slice(j.length),ae-=j.length,X=","),C&&(H=s(H,R)),D.push(j);for(let Q=0;Q<ae;Q++){const ee=H[Q],N=F(ee,j[ee],D);N!==void 0&&(G+=`${X}${a(ee)}:${N}`,X=",")}if(J>$){const Q=J-$;G+=`${X}"...":"${p(Q)} not stringified"`}return D.pop(),`{${G}}`}case"number":return isFinite(j)?String(j):v?v(j):"null";case"boolean":return j===!0?"true":"false";case"undefined":return;case"bigint":if(O)return String(j);default:return v?v(j):void 0}}function Y(Z,j,D){if(arguments.length>1){let G="";if(typeof D=="number"?G=" ".repeat(Math.min(D,10)):typeof D=="string"&&(G=D.slice(0,10)),j!=null){if(typeof j=="function")return M("",{"":Z},[],j,G,"");if(Array.isArray(j))return z("",Z,[],b(j),G,"")}if(G.length!==0)return B("",Z,[],G,"")}return F("",Z,[])}return Y}})(Tn,Tn.exports)),Tn.exports}var ua,cu;function Gh(){if(cu)return ua;cu=1;var n=We(),e=xe(),t=e.MESSAGE,r=fn();function i(a,s){return typeof s=="bigint"?s.toString():s}return ua=n(function(a,s){var o=r.configure(s);return a[t]=o(a,s.replacer||i,s.space),a}),ua}var la,fu;function Vh(){if(fu)return la;fu=1;var n=We();return la=n(function(e,t){return t.message?(e.message="[".concat(t.label,"] ").concat(e.message),e):(e.label=t.label,e)}),la}var ca,du;function Wh(){if(du)return ca;du=1;var n=We(),e=xe(),t=e.MESSAGE,r=fn();return ca=n(function(i){var a={};return i.message&&(a["@message"]=i.message,delete i.message),i.timestamp&&(a["@timestamp"]=i.timestamp,delete i.timestamp),a["@fields"]=i,i[t]=r(a),i}),ca}var fa,hu;function Jh(){if(hu)return fa;hu=1;function n(o){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(u){return typeof u}:function(u){return u&&typeof Symbol=="function"&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},n(o)}function e(o,u,l){return(u=t(u))in o?Object.defineProperty(o,u,{value:l,enumerable:!0,configurable:!0,writable:!0}):o[u]=l,o}function t(o){var u=r(o,"string");return n(u)=="symbol"?u:u+""}function r(o,u){if(n(o)!="object"||!o)return o;var l=o[Symbol.toPrimitive];if(l!==void 0){var c=l.call(o,u);if(n(c)!="object")return c;throw new TypeError("@@toPrimitive must return a primitive value.")}return(u==="string"?String:Number)(o)}var i=We();function a(o,u,l){var c=u.reduce(function(f,_){return f[_]=o[_],delete o[_],f},{}),h=Object.keys(o).reduce(function(f,_){return f[_]=o[_],delete o[_],f},{});return Object.assign(o,c,e({},l,h)),o}function s(o,u,l){return o[l]=u.reduce(function(c,h){return c[h]=o[h],delete o[h],c},{}),o}return fa=i(function(o){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l="metadata";u.key&&(l=u.key);var c=[];return!u.fillExcept&&!u.fillWith&&(c.push("level"),c.push("message")),u.fillExcept&&(c=u.fillExcept),c.length>0?a(o,c,l):u.fillWith?s(o,u.fillWith,l):o}),fa}var da,pu;function Kh(){if(pu)return da;pu=1;var n=1e3,e=n*60,t=e*60,r=t*24,i=r*7,a=r*365.25;da=function(c,h){h=h||{};var f=typeof c;if(f==="string"&&c.length>0)return s(c);if(f==="number"&&isFinite(c))return h.long?u(c):o(c);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(c))};function s(c){if(c=String(c),!(c.length>100)){var h=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(c);if(h){var f=parseFloat(h[1]),_=(h[2]||"ms").toLowerCase();switch(_){case"years":case"year":case"yrs":case"yr":case"y":return f*a;case"weeks":case"week":case"w":return f*i;case"days":case"day":case"d":return f*r;case"hours":case"hour":case"hrs":case"hr":case"h":return f*t;case"minutes":case"minute":case"mins":case"min":case"m":return f*e;case"seconds":case"second":case"secs":case"sec":case"s":return f*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return f;default:return}}}}function o(c){var h=Math.abs(c);return h>=r?Math.round(c/r)+"d":h>=t?Math.round(c/t)+"h":h>=e?Math.round(c/e)+"m":h>=n?Math.round(c/n)+"s":c+"ms"}function u(c){var h=Math.abs(c);return h>=r?l(c,h,r,"day"):h>=t?l(c,h,t,"hour"):h>=e?l(c,h,e,"minute"):h>=n?l(c,h,n,"second"):c+" ms"}function l(c,h,f,_){var p=h>=f*1.5;return Math.round(c/f)+" "+_+(p?"s":"")}return da}var ha,mu;function Yh(){if(mu)return ha;mu=1;var n=void 0,e=We(),t=Kh();return ha=e(function(r){var i=+new Date;return n.diff=i-(n.prevTime||i),n.prevTime=i,r.ms="+".concat(t(n.diff)),r}),ha}var pa,gu;function Qh(){if(gu)return pa;gu=1;var n=ft.inspect,e=We(),t=xe(),r=t.LEVEL,i=t.MESSAGE,a=t.SPLAT;return pa=e(function(s){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=Object.assign({},s);return delete u[r],delete u[i],delete u[a],s[i]=n(u,!1,o.depth||null,o.colorize),s}),pa}var Nr={exports:{}},yu;function Zh(){if(yu)return Nr.exports;yu=1;function n(l){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(c){return typeof c}:function(c){return c&&typeof Symbol=="function"&&c.constructor===Symbol&&c!==Symbol.prototype?"symbol":typeof c},n(l)}function e(l,c){if(!(l instanceof c))throw new TypeError("Cannot call a class as a function")}function t(l,c){for(var h=0;h<c.length;h++){var f=c[h];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(l,i(f.key),f)}}function r(l,c,h){return c&&t(l.prototype,c),Object.defineProperty(l,"prototype",{writable:!1}),l}function i(l){var c=a(l,"string");return n(c)=="symbol"?c:c+""}function a(l,c){if(n(l)!="object"||!l)return l;var h=l[Symbol.toPrimitive];if(h!==void 0){var f=h.call(l,c);if(n(f)!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(l)}var s=xe(),o=s.MESSAGE,u=(function(){function l(c){e(this,l),this.template=c}return r(l,[{key:"transform",value:function(h){return h[o]=this.template(h),h}}])})();return Nr.exports=function(l){return new u(l)},Nr.exports.Printf=Nr.exports.Format=u,Nr.exports}var ma,bu;function Xh(){if(bu)return ma;bu=1;var n=We(),e=xe(),t=e.MESSAGE,r=fn();return ma=n(function(i){var a=r(Object.assign({},i,{level:void 0,message:void 0,splat:void 0})),s=i.padding&&i.padding[i.level]||"";return a!=="{}"?i[t]="".concat(i.level,":").concat(s," ").concat(i.message," ").concat(a):i[t]="".concat(i.level,":").concat(s," ").concat(i.message),i}),ma}var ga,_u;function ep(){if(_u)return ga;_u=1;function n(g){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(v){return typeof v}:function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v},n(g)}function e(g){return a(g)||i(g)||r(g)||t()}function t(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
27
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function r(g,v){if(g){if(typeof g=="string")return s(g,v);var E={}.toString.call(g).slice(8,-1);return E==="Object"&&g.constructor&&(E=g.constructor.name),E==="Map"||E==="Set"?Array.from(g):E==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(E)?s(g,v):void 0}}function i(g){if(typeof Symbol<"u"&&g[Symbol.iterator]!=null||g["@@iterator"]!=null)return Array.from(g)}function a(g){if(Array.isArray(g))return s(g)}function s(g,v){(v==null||v>g.length)&&(v=g.length);for(var E=0,O=Array(v);E<v;E++)O[E]=g[E];return O}function o(g,v){if(!(g instanceof v))throw new TypeError("Cannot call a class as a function")}function u(g,v){for(var E=0;E<v.length;E++){var O=v[E];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(g,c(O.key),O)}}function l(g,v,E){return v&&u(g.prototype,v),Object.defineProperty(g,"prototype",{writable:!1}),g}function c(g){var v=h(g,"string");return n(v)=="symbol"?v:v+""}function h(g,v){if(n(g)!="object"||!g)return g;var E=g[Symbol.toPrimitive];if(E!==void 0){var O=E.call(g,v);if(n(O)!="object")return O;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}var f=ft,_=xe(),p=_.SPLAT,b=/%[scdjifoO%]/g,w=/%%/g,m=(function(){function g(v){o(this,g),this.options=v}return l(g,[{key:"_splat",value:function(E,O){var C=E.message,R=E[p]||E.splat||[],I=C.match(w),$=I&&I.length||0,M=O.length-$,z=M-R.length,B=z<0?R.splice(z,-1*z):[],F=B.length;if(F)for(var Y=0;Y<F;Y++)Object.assign(E,B[Y]);return E.message=f.format.apply(f,[C].concat(e(R))),E}},{key:"transform",value:function(E){var O=E.message,C=E[p]||E.splat;if(!C||!C.length)return E;var R=O&&O.match&&O.match(b);if(!R&&(C||C.length)){var I=C.length>1?C.splice(0):C,$=I.length;if($)for(var M=0;M<$;M++)Object.assign(E,I[M]);return E}return R?this._splat(E,R):E}}])})();return ga=function(g){return new m(g)},ga}var yf=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,Pt="\\d\\d?",St="\\d\\d",tp="\\d{3}",rp="\\d{4}",qr="[^\\s]+",bf=/\[([^]*?)\]/gm;function _f(n,e){for(var t=[],r=0,i=n.length;r<i;r++)t.push(n[r].substr(0,e));return t}var vu=function(n){return function(e,t){var r=t[n].map(function(a){return a.toLowerCase()}),i=r.indexOf(e.toLowerCase());return i>-1?i:null}};function Ct(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];for(var r=0,i=e;r<i.length;r++){var a=i[r];for(var s in a)n[s]=a[s]}return n}var vf=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],wf=["January","February","March","April","May","June","July","August","September","October","November","December"],np=_f(wf,3),ip=_f(vf,3),io={dayNamesShort:ip,dayNames:vf,monthNamesShort:np,monthNames:wf,amPm:["am","pm"],DoFn:function(n){return n+["th","st","nd","rd"][n%10>3?0:(n-n%10!==10?1:0)*n%10]}},oi=Ct({},io),Ef=function(n){return oi=Ct(oi,n)},wu=function(n){return n.replace(/[|\\{()[^$+*?.-]/g,"\\$&")},Ue=function(n,e){for(e===void 0&&(e=2),n=String(n);n.length<e;)n="0"+n;return n},ap={D:function(n){return String(n.getDate())},DD:function(n){return Ue(n.getDate())},Do:function(n,e){return e.DoFn(n.getDate())},d:function(n){return String(n.getDay())},dd:function(n){return Ue(n.getDay())},ddd:function(n,e){return e.dayNamesShort[n.getDay()]},dddd:function(n,e){return e.dayNames[n.getDay()]},M:function(n){return String(n.getMonth()+1)},MM:function(n){return Ue(n.getMonth()+1)},MMM:function(n,e){return e.monthNamesShort[n.getMonth()]},MMMM:function(n,e){return e.monthNames[n.getMonth()]},YY:function(n){return Ue(String(n.getFullYear()),4).substr(2)},YYYY:function(n){return Ue(n.getFullYear(),4)},h:function(n){return String(n.getHours()%12||12)},hh:function(n){return Ue(n.getHours()%12||12)},H:function(n){return String(n.getHours())},HH:function(n){return Ue(n.getHours())},m:function(n){return String(n.getMinutes())},mm:function(n){return Ue(n.getMinutes())},s:function(n){return String(n.getSeconds())},ss:function(n){return Ue(n.getSeconds())},S:function(n){return String(Math.round(n.getMilliseconds()/100))},SS:function(n){return Ue(Math.round(n.getMilliseconds()/10),2)},SSS:function(n){return Ue(n.getMilliseconds(),3)},a:function(n,e){return n.getHours()<12?e.amPm[0]:e.amPm[1]},A:function(n,e){return n.getHours()<12?e.amPm[0].toUpperCase():e.amPm[1].toUpperCase()},ZZ:function(n){var e=n.getTimezoneOffset();return(e>0?"-":"+")+Ue(Math.floor(Math.abs(e)/60)*100+Math.abs(e)%60,4)},Z:function(n){var e=n.getTimezoneOffset();return(e>0?"-":"+")+Ue(Math.floor(Math.abs(e)/60),2)+":"+Ue(Math.abs(e)%60,2)}},Eu=function(n){return+n-1},Su=[null,Pt],Ou=[null,qr],Tu=["isPm",qr,function(n,e){var t=n.toLowerCase();return t===e.amPm[0]?0:t===e.amPm[1]?1:null}],Pu=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(n){var e=(n+"").match(/([+-]|\d\d)/gi);if(e){var t=+e[1]*60+parseInt(e[2],10);return e[0]==="+"?t:-t}return 0}],sp={D:["day",Pt],DD:["day",St],Do:["day",Pt+qr,function(n){return parseInt(n,10)}],M:["month",Pt,Eu],MM:["month",St,Eu],YY:["year",St,function(n){var e=new Date,t=+(""+e.getFullYear()).substr(0,2);return+(""+(+n>68?t-1:t)+n)}],h:["hour",Pt,void 0,"isPm"],hh:["hour",St,void 0,"isPm"],H:["hour",Pt],HH:["hour",St],m:["minute",Pt],mm:["minute",St],s:["second",Pt],ss:["second",St],YYYY:["year",rp],S:["millisecond","\\d",function(n){return+n*100}],SS:["millisecond",St,function(n){return+n*10}],SSS:["millisecond",tp],d:Su,dd:Su,ddd:Ou,dddd:Ou,MMM:["month",qr,vu("monthNamesShort")],MMMM:["month",qr,vu("monthNames")],a:Tu,A:Tu,ZZ:Pu,Z:Pu},ui={default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"},Sf=function(n){return Ct(ui,n)},Of=function(n,e,t){if(e===void 0&&(e=ui.default),t===void 0&&(t={}),typeof n=="number"&&(n=new Date(n)),Object.prototype.toString.call(n)!=="[object Date]"||isNaN(n.getTime()))throw new Error("Invalid Date pass to format");e=ui[e]||e;var r=[];e=e.replace(bf,function(a,s){return r.push(s),"@@@"});var i=Ct(Ct({},oi),t);return e=e.replace(yf,function(a){return ap[a](n,i)}),e.replace(/@@@/g,function(){return r.shift()})};function Tf(n,e,t){if(t===void 0&&(t={}),typeof e!="string")throw new Error("Invalid format in fecha parse");if(e=ui[e]||e,n.length>1e3)return null;var r=new Date,i={year:r.getFullYear(),month:0,day:1,hour:0,minute:0,second:0,millisecond:0,isPm:null,timezoneOffset:null},a=[],s=[],o=e.replace(bf,function(E,O){return s.push(wu(O)),"@@@"}),u={},l={};o=wu(o).replace(yf,function(E){var O=sp[E],C=O[0],R=O[1],I=O[3];if(u[C])throw new Error("Invalid format. "+C+" specified twice in format");return u[C]=!0,I&&(l[I]=!0),a.push(O),"("+R+")"}),Object.keys(l).forEach(function(E){if(!u[E])throw new Error("Invalid format. "+E+" is required in specified format")}),o=o.replace(/@@@/g,function(){return s.shift()});var c=n.match(new RegExp(o,"i"));if(!c)return null;for(var h=Ct(Ct({},oi),t),f=1;f<c.length;f++){var _=a[f-1],p=_[0],b=_[2],w=b?b(c[f],h):+c[f];if(w==null)return null;i[p]=w}i.isPm===1&&i.hour!=null&&+i.hour!=12?i.hour=+i.hour+12:i.isPm===0&&+i.hour==12&&(i.hour=0);var m;if(i.timezoneOffset==null){m=new Date(i.year,i.month,i.day,i.hour,i.minute,i.second,i.millisecond);for(var g=[["month","getMonth"],["day","getDate"],["hour","getHours"],["minute","getMinutes"],["second","getSeconds"]],f=0,v=g.length;f<v;f++)if(u[g[f][0]]&&i[g[f][0]]!==m[g[f][1]]())return null}else if(m=new Date(Date.UTC(i.year,i.month,i.day,i.hour,i.minute-i.timezoneOffset,i.second,i.millisecond)),i.month>11||i.month<0||i.day>31||i.day<1||i.hour>23||i.hour<0||i.minute>59||i.minute<0||i.second>59||i.second<0)return null;return m}var op={format:Of,parse:Tf,defaultI18n:io,setGlobalDateI18n:Ef,setGlobalDateMasks:Sf};const up=Object.freeze(Object.defineProperty({__proto__:null,assign:Ct,default:op,defaultI18n:io,format:Of,parse:Tf,setGlobalDateI18n:Ef,setGlobalDateMasks:Sf},Symbol.toStringTag,{value:"Module"})),lp=xi(up);var ya,xu;function cp(){if(xu)return ya;xu=1;var n=lp,e=We();return ya=e(function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return r.format&&(t.timestamp=typeof r.format=="function"?r.format():n.format(new Date,r.format)),t.timestamp||(t.timestamp=new Date().toISOString()),r.alias&&(t[r.alias]=t.timestamp),t}),ya}var ba,Au;function fp(){if(Au)return ba;Au=1;var n=mf(),e=We(),t=xe(),r=t.MESSAGE;return ba=e(function(i,a){return a.level!==!1&&(i.level=n.strip(i.level)),a.message!==!1&&(i.message=n.strip(String(i.message))),a.raw!==!1&&i[r]&&(i[r]=n.strip(String(i[r]))),i}),ba}var Ru;function Pf(){if(Ru)return _n;Ru=1;var n=_n.format=We();return _n.levels=Uh(),Object.defineProperty(n,"align",{value:Bh()}),Object.defineProperty(n,"cli",{value:qh()}),Object.defineProperty(n,"colorize",{value:no()}),Object.defineProperty(n,"combine",{value:zh()}),Object.defineProperty(n,"errors",{value:Hh()}),Object.defineProperty(n,"json",{value:Gh()}),Object.defineProperty(n,"label",{value:Vh()}),Object.defineProperty(n,"logstash",{value:Wh()}),Object.defineProperty(n,"metadata",{value:Jh()}),Object.defineProperty(n,"ms",{value:Yh()}),Object.defineProperty(n,"padLevels",{value:gf()}),Object.defineProperty(n,"prettyPrint",{value:Qh()}),Object.defineProperty(n,"printf",{value:Zh()}),Object.defineProperty(n,"simple",{value:Xh()}),Object.defineProperty(n,"splat",{value:ep()}),Object.defineProperty(n,"timestamp",{value:cp()}),Object.defineProperty(n,"uncolorize",{value:fp()}),_n}var _a={},Iu;function xf(){return Iu||(Iu=1,(function(n){var e=ft,t=e.format;n.warn={deprecated:function(i){return function(){throw new Error(t("{ %s } was removed in winston@3.0.0.",i))}},useFormat:function(i){return function(){throw new Error([t("{ %s } was removed in winston@3.0.0.",i),"Use a custom winston.format = winston.format(function) instead."].join(`
|
|
28
|
+
`))}},forFunctions:function(i,a,s){s.forEach(function(o){i[o]=n.warn[a](o)})},forProperties:function(i,a,s){s.forEach(function(o){var u=n.warn[a](o);Object.defineProperty(i,o,{get:u,set:u})})}}})(_a)),_a}const dp="3.18.3",hp={version:dp};var va={},Pn={exports:{}},wa={exports:{}},Ea,Cu;function pp(){if(Cu)return Ea;Cu=1,Ea=n;function n(t,r){if(e("noDeprecation"))return t;var i=!1;function a(){if(!i){if(e("throwDeprecation"))throw new Error(r);e("traceDeprecation")?console.trace(r):console.warn(r),i=!0}return t.apply(this,arguments)}return a}function e(t){try{if(!globalThis.localStorage)return!1}catch{return!1}var r=globalThis.localStorage[t];return r==null?!1:String(r).toLowerCase()==="true"}return Ea}var xn={exports:{}},$u;function Af(){if($u)return xn.exports;$u=1;var n=typeof Reflect=="object"?Reflect:null,e=n&&typeof n.apply=="function"?n.apply:function(O,C,R){return Function.prototype.apply.call(O,C,R)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(O){return Object.getOwnPropertyNames(O).concat(Object.getOwnPropertySymbols(O))}:t=function(O){return Object.getOwnPropertyNames(O)};function r(E){console&&console.warn&&console.warn(E)}var i=Number.isNaN||function(O){return O!==O};function a(){a.init.call(this)}xn.exports=a,xn.exports.once=m,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var s=10;function o(E){if(typeof E!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof E)}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(E){if(typeof E!="number"||E<0||i(E))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+E+".");s=E}}),a.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(O){if(typeof O!="number"||O<0||i(O))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+O+".");return this._maxListeners=O,this};function u(E){return E._maxListeners===void 0?a.defaultMaxListeners:E._maxListeners}a.prototype.getMaxListeners=function(){return u(this)},a.prototype.emit=function(O){for(var C=[],R=1;R<arguments.length;R++)C.push(arguments[R]);var I=O==="error",$=this._events;if($!==void 0)I=I&&$.error===void 0;else if(!I)return!1;if(I){var M;if(C.length>0&&(M=C[0]),M instanceof Error)throw M;var z=new Error("Unhandled error."+(M?" ("+M.message+")":""));throw z.context=M,z}var B=$[O];if(B===void 0)return!1;if(typeof B=="function")e(B,this,C);else for(var F=B.length,Y=p(B,F),R=0;R<F;++R)e(Y[R],this,C);return!0};function l(E,O,C,R){var I,$,M;if(o(C),$=E._events,$===void 0?($=E._events=Object.create(null),E._eventsCount=0):($.newListener!==void 0&&(E.emit("newListener",O,C.listener?C.listener:C),$=E._events),M=$[O]),M===void 0)M=$[O]=C,++E._eventsCount;else if(typeof M=="function"?M=$[O]=R?[C,M]:[M,C]:R?M.unshift(C):M.push(C),I=u(E),I>0&&M.length>I&&!M.warned){M.warned=!0;var z=new Error("Possible EventEmitter memory leak detected. "+M.length+" "+String(O)+" listeners added. Use emitter.setMaxListeners() to increase limit");z.name="MaxListenersExceededWarning",z.emitter=E,z.type=O,z.count=M.length,r(z)}return E}a.prototype.addListener=function(O,C){return l(this,O,C,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(O,C){return l(this,O,C,!0)};function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(E,O,C){var R={fired:!1,wrapFn:void 0,target:E,type:O,listener:C},I=c.bind(R);return I.listener=C,R.wrapFn=I,I}a.prototype.once=function(O,C){return o(C),this.on(O,h(this,O,C)),this},a.prototype.prependOnceListener=function(O,C){return o(C),this.prependListener(O,h(this,O,C)),this},a.prototype.removeListener=function(O,C){var R,I,$,M,z;if(o(C),I=this._events,I===void 0)return this;if(R=I[O],R===void 0)return this;if(R===C||R.listener===C)--this._eventsCount===0?this._events=Object.create(null):(delete I[O],I.removeListener&&this.emit("removeListener",O,R.listener||C));else if(typeof R!="function"){for($=-1,M=R.length-1;M>=0;M--)if(R[M]===C||R[M].listener===C){z=R[M].listener,$=M;break}if($<0)return this;$===0?R.shift():b(R,$),R.length===1&&(I[O]=R[0]),I.removeListener!==void 0&&this.emit("removeListener",O,z||C)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(O){var C,R,I;if(R=this._events,R===void 0)return this;if(R.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):R[O]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete R[O]),this;if(arguments.length===0){var $=Object.keys(R),M;for(I=0;I<$.length;++I)M=$[I],M!=="removeListener"&&this.removeAllListeners(M);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(C=R[O],typeof C=="function")this.removeListener(O,C);else if(C!==void 0)for(I=C.length-1;I>=0;I--)this.removeListener(O,C[I]);return this};function f(E,O,C){var R=E._events;if(R===void 0)return[];var I=R[O];return I===void 0?[]:typeof I=="function"?C?[I.listener||I]:[I]:C?w(I):p(I,I.length)}a.prototype.listeners=function(O){return f(this,O,!0)},a.prototype.rawListeners=function(O){return f(this,O,!1)},a.listenerCount=function(E,O){return typeof E.listenerCount=="function"?E.listenerCount(O):_.call(E,O)},a.prototype.listenerCount=_;function _(E){var O=this._events;if(O!==void 0){var C=O[E];if(typeof C=="function")return 1;if(C!==void 0)return C.length}return 0}a.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function p(E,O){for(var C=new Array(O),R=0;R<O;++R)C[R]=E[R];return C}function b(E,O){for(;O+1<E.length;O++)E[O]=E[O+1];E.pop()}function w(E){for(var O=new Array(E.length),C=0;C<O.length;++C)O[C]=E[C].listener||E[C];return O}function m(E,O){return new Promise(function(C,R){function I(M){E.removeListener(O,$),R(M)}function $(){typeof E.removeListener=="function"&&E.removeListener("error",I),C([].slice.call(arguments))}v(E,O,$,{once:!0}),O!=="error"&&g(E,I,{once:!0})})}function g(E,O,C){typeof E.on=="function"&&v(E,"error",O,C)}function v(E,O,C,R){if(typeof E.on=="function")R.once?E.once(O,C):E.on(O,C);else if(typeof E.addEventListener=="function")E.addEventListener(O,function I($){R.once&&E.removeEventListener(O,I),C($)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof E)}return xn.exports}var Sa,ju;function Rf(){return ju||(ju=1,Sa=Af().EventEmitter),Sa}var Oa={},An={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var Mu;function mp(){return Mu||(Mu=1,An.read=function(n,e,t,r,i){var a,s,o=i*8-r-1,u=(1<<o)-1,l=u>>1,c=-7,h=t?i-1:0,f=t?-1:1,_=n[e+h];for(h+=f,a=_&(1<<-c)-1,_>>=-c,c+=o;c>0;a=a*256+n[e+h],h+=f,c-=8);for(s=a&(1<<-c)-1,a>>=-c,c+=r;c>0;s=s*256+n[e+h],h+=f,c-=8);if(a===0)a=1-l;else{if(a===u)return s?NaN:(_?-1:1)*(1/0);s=s+Math.pow(2,r),a=a-l}return(_?-1:1)*s*Math.pow(2,a-r)},An.write=function(n,e,t,r,i,a){var s,o,u,l=a*8-i-1,c=(1<<l)-1,h=c>>1,f=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,_=r?0:a-1,p=r?1:-1,b=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+h>=1?e+=f/u:e+=f*Math.pow(2,1-h),e*u>=2&&(s++,u/=2),s+h>=c?(o=0,s=c):s+h>=1?(o=(e*u-1)*Math.pow(2,i),s=s+h):(o=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;n[t+_]=o&255,_+=p,o/=256,i-=8);for(s=s<<i|o,l+=i;l>0;n[t+_]=s&255,_+=p,s/=256,l-=8);n[t+_-p]|=b*128}),An}/*!
|
|
29
|
+
* The buffer module from node.js, for the browser.
|
|
30
|
+
*
|
|
31
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
32
|
+
* @license MIT
|
|
33
|
+
*/var ku;function Ai(){return ku||(ku=1,(function(n){const e=gh(),t=mp(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=o,n.SlowBuffer=g,n.INSPECT_MAX_BYTES=50;const i=2147483647;n.kMaxLength=i,o.TYPED_ARRAY_SUPPORT=a(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function a(){try{const S=new Uint8Array(1),d={foo:function(){return 42}};return Object.setPrototypeOf(d,Uint8Array.prototype),Object.setPrototypeOf(S,d),S.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function s(S){if(S>i)throw new RangeError('The value "'+S+'" is invalid for option "size"');const d=new Uint8Array(S);return Object.setPrototypeOf(d,o.prototype),d}function o(S,d,y){if(typeof S=="number"){if(typeof d=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return h(S)}return u(S,d,y)}o.poolSize=8192;function u(S,d,y){if(typeof S=="string")return f(S,d);if(ArrayBuffer.isView(S))return p(S);if(S==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof S);if(ce(S,ArrayBuffer)||S&&ce(S.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ce(S,SharedArrayBuffer)||S&&ce(S.buffer,SharedArrayBuffer)))return b(S,d,y);if(typeof S=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const P=S.valueOf&&S.valueOf();if(P!=null&&P!==S)return o.from(P,d,y);const L=w(S);if(L)return L;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof S[Symbol.toPrimitive]=="function")return o.from(S[Symbol.toPrimitive]("string"),d,y);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof S)}o.from=function(S,d,y){return u(S,d,y)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function l(S){if(typeof S!="number")throw new TypeError('"size" argument must be of type number');if(S<0)throw new RangeError('The value "'+S+'" is invalid for option "size"')}function c(S,d,y){return l(S),S<=0?s(S):d!==void 0?typeof y=="string"?s(S).fill(d,y):s(S).fill(d):s(S)}o.alloc=function(S,d,y){return c(S,d,y)};function h(S){return l(S),s(S<0?0:m(S)|0)}o.allocUnsafe=function(S){return h(S)},o.allocUnsafeSlow=function(S){return h(S)};function f(S,d){if((typeof d!="string"||d==="")&&(d="utf8"),!o.isEncoding(d))throw new TypeError("Unknown encoding: "+d);const y=v(S,d)|0;let P=s(y);const L=P.write(S,d);return L!==y&&(P=P.slice(0,L)),P}function _(S){const d=S.length<0?0:m(S.length)|0,y=s(d);for(let P=0;P<d;P+=1)y[P]=S[P]&255;return y}function p(S){if(ce(S,Uint8Array)){const d=new Uint8Array(S);return b(d.buffer,d.byteOffset,d.byteLength)}return _(S)}function b(S,d,y){if(d<0||S.byteLength<d)throw new RangeError('"offset" is outside of buffer bounds');if(S.byteLength<d+(y||0))throw new RangeError('"length" is outside of buffer bounds');let P;return d===void 0&&y===void 0?P=new Uint8Array(S):y===void 0?P=new Uint8Array(S,d):P=new Uint8Array(S,d,y),Object.setPrototypeOf(P,o.prototype),P}function w(S){if(o.isBuffer(S)){const d=m(S.length)|0,y=s(d);return y.length===0||S.copy(y,0,0,d),y}if(S.length!==void 0)return typeof S.length!="number"||ue(S.length)?s(0):_(S);if(S.type==="Buffer"&&Array.isArray(S.data))return _(S.data)}function m(S){if(S>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return S|0}function g(S){return+S!=S&&(S=0),o.alloc(+S)}o.isBuffer=function(d){return d!=null&&d._isBuffer===!0&&d!==o.prototype},o.compare=function(d,y){if(ce(d,Uint8Array)&&(d=o.from(d,d.offset,d.byteLength)),ce(y,Uint8Array)&&(y=o.from(y,y.offset,y.byteLength)),!o.isBuffer(d)||!o.isBuffer(y))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(d===y)return 0;let P=d.length,L=y.length;for(let q=0,K=Math.min(P,L);q<K;++q)if(d[q]!==y[q]){P=d[q],L=y[q];break}return P<L?-1:L<P?1:0},o.isEncoding=function(d){switch(String(d).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(d,y){if(!Array.isArray(d))throw new TypeError('"list" argument must be an Array of Buffers');if(d.length===0)return o.alloc(0);let P;if(y===void 0)for(y=0,P=0;P<d.length;++P)y+=d[P].length;const L=o.allocUnsafe(y);let q=0;for(P=0;P<d.length;++P){let K=d[P];if(ce(K,Uint8Array))q+K.length>L.length?(o.isBuffer(K)||(K=o.from(K)),K.copy(L,q)):Uint8Array.prototype.set.call(L,K,q);else if(o.isBuffer(K))K.copy(L,q);else throw new TypeError('"list" argument must be an Array of Buffers');q+=K.length}return L};function v(S,d){if(o.isBuffer(S))return S.length;if(ArrayBuffer.isView(S)||ce(S,ArrayBuffer))return S.byteLength;if(typeof S!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof S);const y=S.length,P=arguments.length>2&&arguments[2]===!0;if(!P&&y===0)return 0;let L=!1;for(;;)switch(d){case"ascii":case"latin1":case"binary":return y;case"utf8":case"utf-8":return ye(S).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return y*2;case"hex":return y>>>1;case"base64":return ie(S).length;default:if(L)return P?-1:ye(S).length;d=(""+d).toLowerCase(),L=!0}}o.byteLength=v;function E(S,d,y){let P=!1;if((d===void 0||d<0)&&(d=0),d>this.length||((y===void 0||y>this.length)&&(y=this.length),y<=0)||(y>>>=0,d>>>=0,y<=d))return"";for(S||(S="utf8");;)switch(S){case"hex":return U(this,d,y);case"utf8":case"utf-8":return Y(this,d,y);case"ascii":return D(this,d,y);case"latin1":case"binary":return G(this,d,y);case"base64":return F(this,d,y);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return H(this,d,y);default:if(P)throw new TypeError("Unknown encoding: "+S);S=(S+"").toLowerCase(),P=!0}}o.prototype._isBuffer=!0;function O(S,d,y){const P=S[d];S[d]=S[y],S[y]=P}o.prototype.swap16=function(){const d=this.length;if(d%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let y=0;y<d;y+=2)O(this,y,y+1);return this},o.prototype.swap32=function(){const d=this.length;if(d%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let y=0;y<d;y+=4)O(this,y,y+3),O(this,y+1,y+2);return this},o.prototype.swap64=function(){const d=this.length;if(d%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let y=0;y<d;y+=8)O(this,y,y+7),O(this,y+1,y+6),O(this,y+2,y+5),O(this,y+3,y+4);return this},o.prototype.toString=function(){const d=this.length;return d===0?"":arguments.length===0?Y(this,0,d):E.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(d){if(!o.isBuffer(d))throw new TypeError("Argument must be a Buffer");return this===d?!0:o.compare(this,d)===0},o.prototype.inspect=function(){let d="";const y=n.INSPECT_MAX_BYTES;return d=this.toString("hex",0,y).replace(/(.{2})/g,"$1 ").trim(),this.length>y&&(d+=" ... "),"<Buffer "+d+">"},r&&(o.prototype[r]=o.prototype.inspect),o.prototype.compare=function(d,y,P,L,q){if(ce(d,Uint8Array)&&(d=o.from(d,d.offset,d.byteLength)),!o.isBuffer(d))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof d);if(y===void 0&&(y=0),P===void 0&&(P=d?d.length:0),L===void 0&&(L=0),q===void 0&&(q=this.length),y<0||P>d.length||L<0||q>this.length)throw new RangeError("out of range index");if(L>=q&&y>=P)return 0;if(L>=q)return-1;if(y>=P)return 1;if(y>>>=0,P>>>=0,L>>>=0,q>>>=0,this===d)return 0;let K=q-L,ge=P-y;const Oe=Math.min(K,ge),Ee=this.slice(L,q),Te=d.slice(y,P);for(let ve=0;ve<Oe;++ve)if(Ee[ve]!==Te[ve]){K=Ee[ve],ge=Te[ve];break}return K<ge?-1:ge<K?1:0};function C(S,d,y,P,L){if(S.length===0)return-1;if(typeof y=="string"?(P=y,y=0):y>2147483647?y=2147483647:y<-2147483648&&(y=-2147483648),y=+y,ue(y)&&(y=L?0:S.length-1),y<0&&(y=S.length+y),y>=S.length){if(L)return-1;y=S.length-1}else if(y<0)if(L)y=0;else return-1;if(typeof d=="string"&&(d=o.from(d,P)),o.isBuffer(d))return d.length===0?-1:R(S,d,y,P,L);if(typeof d=="number")return d=d&255,typeof Uint8Array.prototype.indexOf=="function"?L?Uint8Array.prototype.indexOf.call(S,d,y):Uint8Array.prototype.lastIndexOf.call(S,d,y):R(S,[d],y,P,L);throw new TypeError("val must be string, number or Buffer")}function R(S,d,y,P,L){let q=1,K=S.length,ge=d.length;if(P!==void 0&&(P=String(P).toLowerCase(),P==="ucs2"||P==="ucs-2"||P==="utf16le"||P==="utf-16le")){if(S.length<2||d.length<2)return-1;q=2,K/=2,ge/=2,y/=2}function Oe(Te,ve){return q===1?Te[ve]:Te.readUInt16BE(ve*q)}let Ee;if(L){let Te=-1;for(Ee=y;Ee<K;Ee++)if(Oe(S,Ee)===Oe(d,Te===-1?0:Ee-Te)){if(Te===-1&&(Te=Ee),Ee-Te+1===ge)return Te*q}else Te!==-1&&(Ee-=Ee-Te),Te=-1}else for(y+ge>K&&(y=K-ge),Ee=y;Ee>=0;Ee--){let Te=!0;for(let ve=0;ve<ge;ve++)if(Oe(S,Ee+ve)!==Oe(d,ve)){Te=!1;break}if(Te)return Ee}return-1}o.prototype.includes=function(d,y,P){return this.indexOf(d,y,P)!==-1},o.prototype.indexOf=function(d,y,P){return C(this,d,y,P,!0)},o.prototype.lastIndexOf=function(d,y,P){return C(this,d,y,P,!1)};function I(S,d,y,P){y=Number(y)||0;const L=S.length-y;P?(P=Number(P),P>L&&(P=L)):P=L;const q=d.length;P>q/2&&(P=q/2);let K;for(K=0;K<P;++K){const ge=parseInt(d.substr(K*2,2),16);if(ue(ge))return K;S[y+K]=ge}return K}function $(S,d,y,P){return Ye(ye(d,S.length-y),S,y,P)}function M(S,d,y,P){return Ye(ke(d),S,y,P)}function z(S,d,y,P){return Ye(ie(d),S,y,P)}function B(S,d,y,P){return Ye(Et(d,S.length-y),S,y,P)}o.prototype.write=function(d,y,P,L){if(y===void 0)L="utf8",P=this.length,y=0;else if(P===void 0&&typeof y=="string")L=y,P=this.length,y=0;else if(isFinite(y))y=y>>>0,isFinite(P)?(P=P>>>0,L===void 0&&(L="utf8")):(L=P,P=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const q=this.length-y;if((P===void 0||P>q)&&(P=q),d.length>0&&(P<0||y<0)||y>this.length)throw new RangeError("Attempt to write outside buffer bounds");L||(L="utf8");let K=!1;for(;;)switch(L){case"hex":return I(this,d,y,P);case"utf8":case"utf-8":return $(this,d,y,P);case"ascii":case"latin1":case"binary":return M(this,d,y,P);case"base64":return z(this,d,y,P);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,d,y,P);default:if(K)throw new TypeError("Unknown encoding: "+L);L=(""+L).toLowerCase(),K=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function F(S,d,y){return d===0&&y===S.length?e.fromByteArray(S):e.fromByteArray(S.slice(d,y))}function Y(S,d,y){y=Math.min(S.length,y);const P=[];let L=d;for(;L<y;){const q=S[L];let K=null,ge=q>239?4:q>223?3:q>191?2:1;if(L+ge<=y){let Oe,Ee,Te,ve;switch(ge){case 1:q<128&&(K=q);break;case 2:Oe=S[L+1],(Oe&192)===128&&(ve=(q&31)<<6|Oe&63,ve>127&&(K=ve));break;case 3:Oe=S[L+1],Ee=S[L+2],(Oe&192)===128&&(Ee&192)===128&&(ve=(q&15)<<12|(Oe&63)<<6|Ee&63,ve>2047&&(ve<55296||ve>57343)&&(K=ve));break;case 4:Oe=S[L+1],Ee=S[L+2],Te=S[L+3],(Oe&192)===128&&(Ee&192)===128&&(Te&192)===128&&(ve=(q&15)<<18|(Oe&63)<<12|(Ee&63)<<6|Te&63,ve>65535&&ve<1114112&&(K=ve))}}K===null?(K=65533,ge=1):K>65535&&(K-=65536,P.push(K>>>10&1023|55296),K=56320|K&1023),P.push(K),L+=ge}return j(P)}const Z=4096;function j(S){const d=S.length;if(d<=Z)return String.fromCharCode.apply(String,S);let y="",P=0;for(;P<d;)y+=String.fromCharCode.apply(String,S.slice(P,P+=Z));return y}function D(S,d,y){let P="";y=Math.min(S.length,y);for(let L=d;L<y;++L)P+=String.fromCharCode(S[L]&127);return P}function G(S,d,y){let P="";y=Math.min(S.length,y);for(let L=d;L<y;++L)P+=String.fromCharCode(S[L]);return P}function U(S,d,y){const P=S.length;(!d||d<0)&&(d=0),(!y||y<0||y>P)&&(y=P);let L="";for(let q=d;q<y;++q)L+=de[S[q]];return L}function H(S,d,y){const P=S.slice(d,y);let L="";for(let q=0;q<P.length-1;q+=2)L+=String.fromCharCode(P[q]+P[q+1]*256);return L}o.prototype.slice=function(d,y){const P=this.length;d=~~d,y=y===void 0?P:~~y,d<0?(d+=P,d<0&&(d=0)):d>P&&(d=P),y<0?(y+=P,y<0&&(y=0)):y>P&&(y=P),y<d&&(y=d);const L=this.subarray(d,y);return Object.setPrototypeOf(L,o.prototype),L};function J(S,d,y){if(S%1!==0||S<0)throw new RangeError("offset is not uint");if(S+d>y)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(d,y,P){d=d>>>0,y=y>>>0,P||J(d,y,this.length);let L=this[d],q=1,K=0;for(;++K<y&&(q*=256);)L+=this[d+K]*q;return L},o.prototype.readUintBE=o.prototype.readUIntBE=function(d,y,P){d=d>>>0,y=y>>>0,P||J(d,y,this.length);let L=this[d+--y],q=1;for(;y>0&&(q*=256);)L+=this[d+--y]*q;return L},o.prototype.readUint8=o.prototype.readUInt8=function(d,y){return d=d>>>0,y||J(d,1,this.length),this[d]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(d,y){return d=d>>>0,y||J(d,2,this.length),this[d]|this[d+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(d,y){return d=d>>>0,y||J(d,2,this.length),this[d]<<8|this[d+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(d,y){return d=d>>>0,y||J(d,4,this.length),(this[d]|this[d+1]<<8|this[d+2]<<16)+this[d+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(d,y){return d=d>>>0,y||J(d,4,this.length),this[d]*16777216+(this[d+1]<<16|this[d+2]<<8|this[d+3])},o.prototype.readBigUInt64LE=ne(function(d){d=d>>>0,W(d,"offset");const y=this[d],P=this[d+7];(y===void 0||P===void 0)&&re(d,this.length-8);const L=y+this[++d]*2**8+this[++d]*2**16+this[++d]*2**24,q=this[++d]+this[++d]*2**8+this[++d]*2**16+P*2**24;return BigInt(L)+(BigInt(q)<<BigInt(32))}),o.prototype.readBigUInt64BE=ne(function(d){d=d>>>0,W(d,"offset");const y=this[d],P=this[d+7];(y===void 0||P===void 0)&&re(d,this.length-8);const L=y*2**24+this[++d]*2**16+this[++d]*2**8+this[++d],q=this[++d]*2**24+this[++d]*2**16+this[++d]*2**8+P;return(BigInt(L)<<BigInt(32))+BigInt(q)}),o.prototype.readIntLE=function(d,y,P){d=d>>>0,y=y>>>0,P||J(d,y,this.length);let L=this[d],q=1,K=0;for(;++K<y&&(q*=256);)L+=this[d+K]*q;return q*=128,L>=q&&(L-=Math.pow(2,8*y)),L},o.prototype.readIntBE=function(d,y,P){d=d>>>0,y=y>>>0,P||J(d,y,this.length);let L=y,q=1,K=this[d+--L];for(;L>0&&(q*=256);)K+=this[d+--L]*q;return q*=128,K>=q&&(K-=Math.pow(2,8*y)),K},o.prototype.readInt8=function(d,y){return d=d>>>0,y||J(d,1,this.length),this[d]&128?(255-this[d]+1)*-1:this[d]},o.prototype.readInt16LE=function(d,y){d=d>>>0,y||J(d,2,this.length);const P=this[d]|this[d+1]<<8;return P&32768?P|4294901760:P},o.prototype.readInt16BE=function(d,y){d=d>>>0,y||J(d,2,this.length);const P=this[d+1]|this[d]<<8;return P&32768?P|4294901760:P},o.prototype.readInt32LE=function(d,y){return d=d>>>0,y||J(d,4,this.length),this[d]|this[d+1]<<8|this[d+2]<<16|this[d+3]<<24},o.prototype.readInt32BE=function(d,y){return d=d>>>0,y||J(d,4,this.length),this[d]<<24|this[d+1]<<16|this[d+2]<<8|this[d+3]},o.prototype.readBigInt64LE=ne(function(d){d=d>>>0,W(d,"offset");const y=this[d],P=this[d+7];(y===void 0||P===void 0)&&re(d,this.length-8);const L=this[d+4]+this[d+5]*2**8+this[d+6]*2**16+(P<<24);return(BigInt(L)<<BigInt(32))+BigInt(y+this[++d]*2**8+this[++d]*2**16+this[++d]*2**24)}),o.prototype.readBigInt64BE=ne(function(d){d=d>>>0,W(d,"offset");const y=this[d],P=this[d+7];(y===void 0||P===void 0)&&re(d,this.length-8);const L=(y<<24)+this[++d]*2**16+this[++d]*2**8+this[++d];return(BigInt(L)<<BigInt(32))+BigInt(this[++d]*2**24+this[++d]*2**16+this[++d]*2**8+P)}),o.prototype.readFloatLE=function(d,y){return d=d>>>0,y||J(d,4,this.length),t.read(this,d,!0,23,4)},o.prototype.readFloatBE=function(d,y){return d=d>>>0,y||J(d,4,this.length),t.read(this,d,!1,23,4)},o.prototype.readDoubleLE=function(d,y){return d=d>>>0,y||J(d,8,this.length),t.read(this,d,!0,52,8)},o.prototype.readDoubleBE=function(d,y){return d=d>>>0,y||J(d,8,this.length),t.read(this,d,!1,52,8)};function X(S,d,y,P,L,q){if(!o.isBuffer(S))throw new TypeError('"buffer" argument must be a Buffer instance');if(d>L||d<q)throw new RangeError('"value" argument is out of bounds');if(y+P>S.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(d,y,P,L){if(d=+d,y=y>>>0,P=P>>>0,!L){const ge=Math.pow(2,8*P)-1;X(this,d,y,P,ge,0)}let q=1,K=0;for(this[y]=d&255;++K<P&&(q*=256);)this[y+K]=d/q&255;return y+P},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(d,y,P,L){if(d=+d,y=y>>>0,P=P>>>0,!L){const ge=Math.pow(2,8*P)-1;X(this,d,y,P,ge,0)}let q=P-1,K=1;for(this[y+q]=d&255;--q>=0&&(K*=256);)this[y+q]=d/K&255;return y+P},o.prototype.writeUint8=o.prototype.writeUInt8=function(d,y,P){return d=+d,y=y>>>0,P||X(this,d,y,1,255,0),this[y]=d&255,y+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(d,y,P){return d=+d,y=y>>>0,P||X(this,d,y,2,65535,0),this[y]=d&255,this[y+1]=d>>>8,y+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(d,y,P){return d=+d,y=y>>>0,P||X(this,d,y,2,65535,0),this[y]=d>>>8,this[y+1]=d&255,y+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(d,y,P){return d=+d,y=y>>>0,P||X(this,d,y,4,4294967295,0),this[y+3]=d>>>24,this[y+2]=d>>>16,this[y+1]=d>>>8,this[y]=d&255,y+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(d,y,P){return d=+d,y=y>>>0,P||X(this,d,y,4,4294967295,0),this[y]=d>>>24,this[y+1]=d>>>16,this[y+2]=d>>>8,this[y+3]=d&255,y+4};function ae(S,d,y,P,L){x(d,P,L,S,y,7);let q=Number(d&BigInt(4294967295));S[y++]=q,q=q>>8,S[y++]=q,q=q>>8,S[y++]=q,q=q>>8,S[y++]=q;let K=Number(d>>BigInt(32)&BigInt(4294967295));return S[y++]=K,K=K>>8,S[y++]=K,K=K>>8,S[y++]=K,K=K>>8,S[y++]=K,y}function Q(S,d,y,P,L){x(d,P,L,S,y,7);let q=Number(d&BigInt(4294967295));S[y+7]=q,q=q>>8,S[y+6]=q,q=q>>8,S[y+5]=q,q=q>>8,S[y+4]=q;let K=Number(d>>BigInt(32)&BigInt(4294967295));return S[y+3]=K,K=K>>8,S[y+2]=K,K=K>>8,S[y+1]=K,K=K>>8,S[y]=K,y+8}o.prototype.writeBigUInt64LE=ne(function(d,y=0){return ae(this,d,y,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=ne(function(d,y=0){return Q(this,d,y,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(d,y,P,L){if(d=+d,y=y>>>0,!L){const Oe=Math.pow(2,8*P-1);X(this,d,y,P,Oe-1,-Oe)}let q=0,K=1,ge=0;for(this[y]=d&255;++q<P&&(K*=256);)d<0&&ge===0&&this[y+q-1]!==0&&(ge=1),this[y+q]=(d/K>>0)-ge&255;return y+P},o.prototype.writeIntBE=function(d,y,P,L){if(d=+d,y=y>>>0,!L){const Oe=Math.pow(2,8*P-1);X(this,d,y,P,Oe-1,-Oe)}let q=P-1,K=1,ge=0;for(this[y+q]=d&255;--q>=0&&(K*=256);)d<0&&ge===0&&this[y+q+1]!==0&&(ge=1),this[y+q]=(d/K>>0)-ge&255;return y+P},o.prototype.writeInt8=function(d,y,P){return d=+d,y=y>>>0,P||X(this,d,y,1,127,-128),d<0&&(d=255+d+1),this[y]=d&255,y+1},o.prototype.writeInt16LE=function(d,y,P){return d=+d,y=y>>>0,P||X(this,d,y,2,32767,-32768),this[y]=d&255,this[y+1]=d>>>8,y+2},o.prototype.writeInt16BE=function(d,y,P){return d=+d,y=y>>>0,P||X(this,d,y,2,32767,-32768),this[y]=d>>>8,this[y+1]=d&255,y+2},o.prototype.writeInt32LE=function(d,y,P){return d=+d,y=y>>>0,P||X(this,d,y,4,2147483647,-2147483648),this[y]=d&255,this[y+1]=d>>>8,this[y+2]=d>>>16,this[y+3]=d>>>24,y+4},o.prototype.writeInt32BE=function(d,y,P){return d=+d,y=y>>>0,P||X(this,d,y,4,2147483647,-2147483648),d<0&&(d=4294967295+d+1),this[y]=d>>>24,this[y+1]=d>>>16,this[y+2]=d>>>8,this[y+3]=d&255,y+4},o.prototype.writeBigInt64LE=ne(function(d,y=0){return ae(this,d,y,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=ne(function(d,y=0){return Q(this,d,y,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ee(S,d,y,P,L,q){if(y+P>S.length)throw new RangeError("Index out of range");if(y<0)throw new RangeError("Index out of range")}function N(S,d,y,P,L){return d=+d,y=y>>>0,L||ee(S,d,y,4),t.write(S,d,y,P,23,4),y+4}o.prototype.writeFloatLE=function(d,y,P){return N(this,d,y,!0,P)},o.prototype.writeFloatBE=function(d,y,P){return N(this,d,y,!1,P)};function k(S,d,y,P,L){return d=+d,y=y>>>0,L||ee(S,d,y,8),t.write(S,d,y,P,52,8),y+8}o.prototype.writeDoubleLE=function(d,y,P){return k(this,d,y,!0,P)},o.prototype.writeDoubleBE=function(d,y,P){return k(this,d,y,!1,P)},o.prototype.copy=function(d,y,P,L){if(!o.isBuffer(d))throw new TypeError("argument should be a Buffer");if(P||(P=0),!L&&L!==0&&(L=this.length),y>=d.length&&(y=d.length),y||(y=0),L>0&&L<P&&(L=P),L===P||d.length===0||this.length===0)return 0;if(y<0)throw new RangeError("targetStart out of bounds");if(P<0||P>=this.length)throw new RangeError("Index out of range");if(L<0)throw new RangeError("sourceEnd out of bounds");L>this.length&&(L=this.length),d.length-y<L-P&&(L=d.length-y+P);const q=L-P;return this===d&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(y,P,L):Uint8Array.prototype.set.call(d,this.subarray(P,L),y),q},o.prototype.fill=function(d,y,P,L){if(typeof d=="string"){if(typeof y=="string"?(L=y,y=0,P=this.length):typeof P=="string"&&(L=P,P=this.length),L!==void 0&&typeof L!="string")throw new TypeError("encoding must be a string");if(typeof L=="string"&&!o.isEncoding(L))throw new TypeError("Unknown encoding: "+L);if(d.length===1){const K=d.charCodeAt(0);(L==="utf8"&&K<128||L==="latin1")&&(d=K)}}else typeof d=="number"?d=d&255:typeof d=="boolean"&&(d=Number(d));if(y<0||this.length<y||this.length<P)throw new RangeError("Out of range index");if(P<=y)return this;y=y>>>0,P=P===void 0?this.length:P>>>0,d||(d=0);let q;if(typeof d=="number")for(q=y;q<P;++q)this[q]=d;else{const K=o.isBuffer(d)?d:o.from(d,L),ge=K.length;if(ge===0)throw new TypeError('The value "'+d+'" is invalid for argument "value"');for(q=0;q<P-y;++q)this[q+y]=K[q%ge]}return this};const V={};function se(S,d,y){V[S]=class extends y{constructor(){super(),Object.defineProperty(this,"message",{value:d.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${S}]`,this.stack,delete this.name}get code(){return S}set code(L){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:L,writable:!0})}toString(){return`${this.name} [${S}]: ${this.message}`}}}se("ERR_BUFFER_OUT_OF_BOUNDS",function(S){return S?`${S} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),se("ERR_INVALID_ARG_TYPE",function(S,d){return`The "${S}" argument must be of type number. Received type ${typeof d}`},TypeError),se("ERR_OUT_OF_RANGE",function(S,d,y){let P=`The value of "${S}" is out of range.`,L=y;return Number.isInteger(y)&&Math.abs(y)>2**32?L=oe(String(y)):typeof y=="bigint"&&(L=String(y),(y>BigInt(2)**BigInt(32)||y<-(BigInt(2)**BigInt(32)))&&(L=oe(L)),L+="n"),P+=` It must be ${d}. Received ${L}`,P},RangeError);function oe(S){let d="",y=S.length;const P=S[0]==="-"?1:0;for(;y>=P+4;y-=3)d=`_${S.slice(y-3,y)}${d}`;return`${S.slice(0,y)}${d}`}function T(S,d,y){W(d,"offset"),(S[d]===void 0||S[d+y]===void 0)&&re(d,S.length-(y+1))}function x(S,d,y,P,L,q){if(S>y||S<d){const K=typeof d=="bigint"?"n":"";let ge;throw d===0||d===BigInt(0)?ge=`>= 0${K} and < 2${K} ** ${(q+1)*8}${K}`:ge=`>= -(2${K} ** ${(q+1)*8-1}${K}) and < 2 ** ${(q+1)*8-1}${K}`,new V.ERR_OUT_OF_RANGE("value",ge,S)}T(P,L,q)}function W(S,d){if(typeof S!="number")throw new V.ERR_INVALID_ARG_TYPE(d,"number",S)}function re(S,d,y){throw Math.floor(S)!==S?(W(S,y),new V.ERR_OUT_OF_RANGE("offset","an integer",S)):d<0?new V.ERR_BUFFER_OUT_OF_BOUNDS:new V.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${d}`,S)}const _e=/[^+/0-9A-Za-z-_]/g;function he(S){if(S=S.split("=")[0],S=S.trim().replace(_e,""),S.length<2)return"";for(;S.length%4!==0;)S=S+"=";return S}function ye(S,d){d=d||1/0;let y;const P=S.length;let L=null;const q=[];for(let K=0;K<P;++K){if(y=S.charCodeAt(K),y>55295&&y<57344){if(!L){if(y>56319){(d-=3)>-1&&q.push(239,191,189);continue}else if(K+1===P){(d-=3)>-1&&q.push(239,191,189);continue}L=y;continue}if(y<56320){(d-=3)>-1&&q.push(239,191,189),L=y;continue}y=(L-55296<<10|y-56320)+65536}else L&&(d-=3)>-1&&q.push(239,191,189);if(L=null,y<128){if((d-=1)<0)break;q.push(y)}else if(y<2048){if((d-=2)<0)break;q.push(y>>6|192,y&63|128)}else if(y<65536){if((d-=3)<0)break;q.push(y>>12|224,y>>6&63|128,y&63|128)}else if(y<1114112){if((d-=4)<0)break;q.push(y>>18|240,y>>12&63|128,y>>6&63|128,y&63|128)}else throw new Error("Invalid code point")}return q}function ke(S){const d=[];for(let y=0;y<S.length;++y)d.push(S.charCodeAt(y)&255);return d}function Et(S,d){let y,P,L;const q=[];for(let K=0;K<S.length&&!((d-=2)<0);++K)y=S.charCodeAt(K),P=y>>8,L=y%256,q.push(L),q.push(P);return q}function ie(S){return e.toByteArray(he(S))}function Ye(S,d,y,P){let L;for(L=0;L<P&&!(L+y>=d.length||L>=S.length);++L)d[L+y]=S[L];return L}function ce(S,d){return S instanceof d||S!=null&&S.constructor!=null&&S.constructor.name!=null&&S.constructor.name===d.name}function ue(S){return S!==S}const de=(function(){const S="0123456789abcdef",d=new Array(256);for(let y=0;y<16;++y){const P=y*16;for(let L=0;L<16;++L)d[P+L]=S[y]+S[L]}return d})();function ne(S){return typeof BigInt>"u"?te:S}function te(){throw new Error("BigInt not supported")}})(Oa)),Oa}var Ta,Nu;function If(){if(Nu)return Ta;Nu=1;function n(s,o){var u=this,l=this._readableState&&this._readableState.destroyed,c=this._writableState&&this._writableState.destroyed;return l||c?(o?o(s):s&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(i,this,s)):process.nextTick(i,this,s)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(s||null,function(h){!o&&h?u._writableState?u._writableState.errorEmitted?process.nextTick(t,u):(u._writableState.errorEmitted=!0,process.nextTick(e,u,h)):process.nextTick(e,u,h):o?(process.nextTick(t,u),o(h)):process.nextTick(t,u)}),this)}function e(s,o){i(s,o),t(s)}function t(s){s._writableState&&!s._writableState.emitClose||s._readableState&&!s._readableState.emitClose||s.emit("close")}function r(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function i(s,o){s.emit("error",o)}function a(s,o){var u=s._readableState,l=s._writableState;u&&u.autoDestroy||l&&l.autoDestroy?s.destroy(o):s.emit("error",o)}return Ta={destroy:n,undestroy:r,errorOrDestroy:a},Ta}var Pa={},Lu;function Pr(){if(Lu)return Pa;Lu=1;function n(o,u){o.prototype=Object.create(u.prototype),o.prototype.constructor=o,o.__proto__=u}var e={};function t(o,u,l){l||(l=Error);function c(f,_,p){return typeof u=="string"?u:u(f,_,p)}var h=(function(f){n(_,f);function _(p,b,w){return f.call(this,c(p,b,w))||this}return _})(l);h.prototype.name=l.name,h.prototype.code=o,e[o]=h}function r(o,u){if(Array.isArray(o)){var l=o.length;return o=o.map(function(c){return String(c)}),l>2?"one of ".concat(u," ").concat(o.slice(0,l-1).join(", "),", or ")+o[l-1]:l===2?"one of ".concat(u," ").concat(o[0]," or ").concat(o[1]):"of ".concat(u," ").concat(o[0])}else return"of ".concat(u," ").concat(String(o))}function i(o,u,l){return o.substr(0,u.length)===u}function a(o,u,l){return(l===void 0||l>o.length)&&(l=o.length),o.substring(l-u.length,l)===u}function s(o,u,l){return typeof l!="number"&&(l=0),l+u.length>o.length?!1:o.indexOf(u,l)!==-1}return t("ERR_INVALID_OPT_VALUE",function(o,u){return'The value "'+u+'" is invalid for option "'+o+'"'},TypeError),t("ERR_INVALID_ARG_TYPE",function(o,u,l){var c;typeof u=="string"&&i(u,"not ")?(c="must not be",u=u.replace(/^not /,"")):c="must be";var h;if(a(o," argument"))h="The ".concat(o," ").concat(c," ").concat(r(u,"type"));else{var f=s(o,".")?"property":"argument";h='The "'.concat(o,'" ').concat(f," ").concat(c," ").concat(r(u,"type"))}return h+=". Received type ".concat(typeof l),h},TypeError),t("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),t("ERR_METHOD_NOT_IMPLEMENTED",function(o){return"The "+o+" method is not implemented"}),t("ERR_STREAM_PREMATURE_CLOSE","Premature close"),t("ERR_STREAM_DESTROYED",function(o){return"Cannot call "+o+" after a stream was destroyed"}),t("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),t("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),t("ERR_STREAM_WRITE_AFTER_END","write after end"),t("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),t("ERR_UNKNOWN_ENCODING",function(o){return"Unknown encoding: "+o},TypeError),t("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),Pa.codes=e,Pa}var xa,Fu;function Cf(){if(Fu)return xa;Fu=1;var n=Pr().codes.ERR_INVALID_OPT_VALUE;function e(r,i,a){return r.highWaterMark!=null?r.highWaterMark:i?r[a]:null}function t(r,i,a,s){var o=e(i,s,a);if(o!=null){if(!(isFinite(o)&&Math.floor(o)===o)||o<0){var u=s?a:"highWaterMark";throw new n(u,o)}return Math.floor(o)}return r.objectMode?16:16*1024}return xa={getHighWaterMark:t},xa}var Rn={exports:{}},Du;function dn(){return Du||(Du=1,typeof Object.create=="function"?Rn.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Rn.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}),Rn.exports}var Aa,Uu;function gp(){if(Uu)return Aa;Uu=1;function n(p,b){var w=Object.keys(p);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(p);b&&(m=m.filter(function(g){return Object.getOwnPropertyDescriptor(p,g).enumerable})),w.push.apply(w,m)}return w}function e(p){for(var b=1;b<arguments.length;b++){var w=arguments[b]!=null?arguments[b]:{};b%2?n(Object(w),!0).forEach(function(m){t(p,m,w[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(w)):n(Object(w)).forEach(function(m){Object.defineProperty(p,m,Object.getOwnPropertyDescriptor(w,m))})}return p}function t(p,b,w){return b=s(b),b in p?Object.defineProperty(p,b,{value:w,enumerable:!0,configurable:!0,writable:!0}):p[b]=w,p}function r(p,b){if(!(p instanceof b))throw new TypeError("Cannot call a class as a function")}function i(p,b){for(var w=0;w<b.length;w++){var m=b[w];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(p,s(m.key),m)}}function a(p,b,w){return b&&i(p.prototype,b),Object.defineProperty(p,"prototype",{writable:!1}),p}function s(p){var b=o(p,"string");return typeof b=="symbol"?b:String(b)}function o(p,b){if(typeof p!="object"||p===null)return p;var w=p[Symbol.toPrimitive];if(w!==void 0){var m=w.call(p,b);if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(p)}var u=Ai(),l=u.Buffer,c=ft,h=c.inspect,f=h&&h.custom||"inspect";function _(p,b,w){l.prototype.copy.call(p,b,w)}return Aa=(function(){function p(){r(this,p),this.head=null,this.tail=null,this.length=0}return a(p,[{key:"push",value:function(w){var m={data:w,next:null};this.length>0?this.tail.next=m:this.head=m,this.tail=m,++this.length}},{key:"unshift",value:function(w){var m={data:w,next:this.head};this.length===0&&(this.tail=m),this.head=m,++this.length}},{key:"shift",value:function(){if(this.length!==0){var w=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,w}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(w){if(this.length===0)return"";for(var m=this.head,g=""+m.data;m=m.next;)g+=w+m.data;return g}},{key:"concat",value:function(w){if(this.length===0)return l.alloc(0);for(var m=l.allocUnsafe(w>>>0),g=this.head,v=0;g;)_(g.data,m,v),v+=g.data.length,g=g.next;return m}},{key:"consume",value:function(w,m){var g;return w<this.head.data.length?(g=this.head.data.slice(0,w),this.head.data=this.head.data.slice(w)):w===this.head.data.length?g=this.shift():g=m?this._getString(w):this._getBuffer(w),g}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(w){var m=this.head,g=1,v=m.data;for(w-=v.length;m=m.next;){var E=m.data,O=w>E.length?E.length:w;if(O===E.length?v+=E:v+=E.slice(0,w),w-=O,w===0){O===E.length?(++g,m.next?this.head=m.next:this.head=this.tail=null):(this.head=m,m.data=E.slice(O));break}++g}return this.length-=g,v}},{key:"_getBuffer",value:function(w){var m=l.allocUnsafe(w),g=this.head,v=1;for(g.data.copy(m),w-=g.data.length;g=g.next;){var E=g.data,O=w>E.length?E.length:w;if(E.copy(m,m.length-w,0,O),w-=O,w===0){O===E.length?(++v,g.next?this.head=g.next:this.head=this.tail=null):(this.head=g,g.data=E.slice(O));break}++v}return this.length-=v,m}},{key:f,value:function(w,m){return h(this,e(e({},m),{},{depth:0,customInspect:!1}))}}]),p})(),Aa}var Ra={},In={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var Bu;function yp(){return Bu||(Bu=1,(function(n,e){var t=Ai(),r=t.Buffer;function i(s,o){for(var u in s)o[u]=s[u]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=t:(i(t,e),e.Buffer=a);function a(s,o,u){return r(s,o,u)}a.prototype=Object.create(r.prototype),i(r,a),a.from=function(s,o,u){if(typeof s=="number")throw new TypeError("Argument must not be a number");return r(s,o,u)},a.alloc=function(s,o,u){if(typeof s!="number")throw new TypeError("Argument must be a number");var l=r(s);return o!==void 0?typeof u=="string"?l.fill(o,u):l.fill(o):l.fill(0),l},a.allocUnsafe=function(s){if(typeof s!="number")throw new TypeError("Argument must be a number");return r(s)},a.allocUnsafeSlow=function(s){if(typeof s!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(s)}})(In,In.exports)),In.exports}var qu;function Rs(){if(qu)return Ra;qu=1;var n=yp().Buffer,e=n.isEncoding||function(m){switch(m=""+m,m&&m.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function t(m){if(!m)return"utf8";for(var g;;)switch(m){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return m;default:if(g)return;m=(""+m).toLowerCase(),g=!0}}function r(m){var g=t(m);if(typeof g!="string"&&(n.isEncoding===e||!e(m)))throw new Error("Unknown encoding: "+m);return g||m}Ra.StringDecoder=i;function i(m){this.encoding=r(m);var g;switch(this.encoding){case"utf16le":this.text=h,this.end=f,g=4;break;case"utf8":this.fillLast=u,g=4;break;case"base64":this.text=_,this.end=p,g=3;break;default:this.write=b,this.end=w;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(g)}i.prototype.write=function(m){if(m.length===0)return"";var g,v;if(this.lastNeed){if(g=this.fillLast(m),g===void 0)return"";v=this.lastNeed,this.lastNeed=0}else v=0;return v<m.length?g?g+this.text(m,v):this.text(m,v):g||""},i.prototype.end=c,i.prototype.text=l,i.prototype.fillLast=function(m){if(this.lastNeed<=m.length)return m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,m.length),this.lastNeed-=m.length};function a(m){return m<=127?0:m>>5===6?2:m>>4===14?3:m>>3===30?4:m>>6===2?-1:-2}function s(m,g,v){var E=g.length-1;if(E<v)return 0;var O=a(g[E]);return O>=0?(O>0&&(m.lastNeed=O-1),O):--E<v||O===-2?0:(O=a(g[E]),O>=0?(O>0&&(m.lastNeed=O-2),O):--E<v||O===-2?0:(O=a(g[E]),O>=0?(O>0&&(O===2?O=0:m.lastNeed=O-3),O):0))}function o(m,g,v){if((g[0]&192)!==128)return m.lastNeed=0,"�";if(m.lastNeed>1&&g.length>1){if((g[1]&192)!==128)return m.lastNeed=1,"�";if(m.lastNeed>2&&g.length>2&&(g[2]&192)!==128)return m.lastNeed=2,"�"}}function u(m){var g=this.lastTotal-this.lastNeed,v=o(this,m);if(v!==void 0)return v;if(this.lastNeed<=m.length)return m.copy(this.lastChar,g,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,g,0,m.length),this.lastNeed-=m.length}function l(m,g){var v=s(this,m,g);if(!this.lastNeed)return m.toString("utf8",g);this.lastTotal=v;var E=m.length-(v-this.lastNeed);return m.copy(this.lastChar,0,E),m.toString("utf8",g,E)}function c(m){var g=m&&m.length?this.write(m):"";return this.lastNeed?g+"�":g}function h(m,g){if((m.length-g)%2===0){var v=m.toString("utf16le",g);if(v){var E=v.charCodeAt(v.length-1);if(E>=55296&&E<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1],v.slice(0,-1)}return v}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=m[m.length-1],m.toString("utf16le",g,m.length-1)}function f(m){var g=m&&m.length?this.write(m):"";if(this.lastNeed){var v=this.lastTotal-this.lastNeed;return g+this.lastChar.toString("utf16le",0,v)}return g}function _(m,g){var v=(m.length-g)%3;return v===0?m.toString("base64",g):(this.lastNeed=3-v,this.lastTotal=3,v===1?this.lastChar[0]=m[m.length-1]:(this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1]),m.toString("base64",g,m.length-v))}function p(m){var g=m&&m.length?this.write(m):"";return this.lastNeed?g+this.lastChar.toString("base64",0,3-this.lastNeed):g}function b(m){return m.toString(this.encoding)}function w(m){return m&&m.length?this.write(m):""}return Ra}var Ia,zu;function ao(){if(zu)return Ia;zu=1;var n=Pr().codes.ERR_STREAM_PREMATURE_CLOSE;function e(a){var s=!1;return function(){if(!s){s=!0;for(var o=arguments.length,u=new Array(o),l=0;l<o;l++)u[l]=arguments[l];a.apply(this,u)}}}function t(){}function r(a){return a.setHeader&&typeof a.abort=="function"}function i(a,s,o){if(typeof s=="function")return i(a,null,s);s||(s={}),o=e(o||t);var u=s.readable||s.readable!==!1&&a.readable,l=s.writable||s.writable!==!1&&a.writable,c=function(){a.writable||f()},h=a._writableState&&a._writableState.finished,f=function(){l=!1,h=!0,u||o.call(a)},_=a._readableState&&a._readableState.endEmitted,p=function(){u=!1,_=!0,l||o.call(a)},b=function(v){o.call(a,v)},w=function(){var v;if(u&&!_)return(!a._readableState||!a._readableState.ended)&&(v=new n),o.call(a,v);if(l&&!h)return(!a._writableState||!a._writableState.ended)&&(v=new n),o.call(a,v)},m=function(){a.req.on("finish",f)};return r(a)?(a.on("complete",f),a.on("abort",w),a.req?m():a.on("request",m)):l&&!a._writableState&&(a.on("end",c),a.on("close",c)),a.on("end",p),a.on("finish",f),s.error!==!1&&a.on("error",b),a.on("close",w),function(){a.removeListener("complete",f),a.removeListener("abort",w),a.removeListener("request",m),a.req&&a.req.removeListener("finish",f),a.removeListener("end",c),a.removeListener("close",c),a.removeListener("finish",f),a.removeListener("end",p),a.removeListener("error",b),a.removeListener("close",w)}}return Ia=i,Ia}var Ca,Hu;function bp(){if(Hu)return Ca;Hu=1;var n;function e(v,E,O){return E=t(E),E in v?Object.defineProperty(v,E,{value:O,enumerable:!0,configurable:!0,writable:!0}):v[E]=O,v}function t(v){var E=r(v,"string");return typeof E=="symbol"?E:String(E)}function r(v,E){if(typeof v!="object"||v===null)return v;var O=v[Symbol.toPrimitive];if(O!==void 0){var C=O.call(v,E);if(typeof C!="object")return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return(E==="string"?String:Number)(v)}var i=ao(),a=Symbol("lastResolve"),s=Symbol("lastReject"),o=Symbol("error"),u=Symbol("ended"),l=Symbol("lastPromise"),c=Symbol("handlePromise"),h=Symbol("stream");function f(v,E){return{value:v,done:E}}function _(v){var E=v[a];if(E!==null){var O=v[h].read();O!==null&&(v[l]=null,v[a]=null,v[s]=null,E(f(O,!1)))}}function p(v){process.nextTick(_,v)}function b(v,E){return function(O,C){v.then(function(){if(E[u]){O(f(void 0,!0));return}E[c](O,C)},C)}}var w=Object.getPrototypeOf(function(){}),m=Object.setPrototypeOf((n={get stream(){return this[h]},next:function(){var E=this,O=this[o];if(O!==null)return Promise.reject(O);if(this[u])return Promise.resolve(f(void 0,!0));if(this[h].destroyed)return new Promise(function($,M){process.nextTick(function(){E[o]?M(E[o]):$(f(void 0,!0))})});var C=this[l],R;if(C)R=new Promise(b(C,this));else{var I=this[h].read();if(I!==null)return Promise.resolve(f(I,!1));R=new Promise(this[c])}return this[l]=R,R}},e(n,Symbol.asyncIterator,function(){return this}),e(n,"return",function(){var E=this;return new Promise(function(O,C){E[h].destroy(null,function(R){if(R){C(R);return}O(f(void 0,!0))})})}),n),w),g=function(E){var O,C=Object.create(m,(O={},e(O,h,{value:E,writable:!0}),e(O,a,{value:null,writable:!0}),e(O,s,{value:null,writable:!0}),e(O,o,{value:null,writable:!0}),e(O,u,{value:E._readableState.endEmitted,writable:!0}),e(O,c,{value:function(I,$){var M=C[h].read();M?(C[l]=null,C[a]=null,C[s]=null,I(f(M,!1))):(C[a]=I,C[s]=$)},writable:!0}),O));return C[l]=null,i(E,function(R){if(R&&R.code!=="ERR_STREAM_PREMATURE_CLOSE"){var I=C[s];I!==null&&(C[l]=null,C[a]=null,C[s]=null,I(R)),C[o]=R;return}var $=C[a];$!==null&&(C[l]=null,C[a]=null,C[s]=null,$(f(void 0,!0))),C[u]=!0}),E.on("readable",p.bind(null,C)),C};return Ca=g,Ca}var $a,Gu;function _p(){return Gu||(Gu=1,$a=function(){throw new Error("Readable.from is not available in the browser")}),$a}var ja,Vu;function $f(){if(Vu)return ja;Vu=1,ja=$;var n;$.ReadableState=I,Af().EventEmitter;var e=function(x,W){return x.listeners(W).length},t=Rf(),r=Ai().Buffer,i=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function a(T){return r.from(T)}function s(T){return r.isBuffer(T)||T instanceof i}var o=ft,u;o&&o.debuglog?u=o.debuglog("stream"):u=function(){};var l=gp(),c=If(),h=Cf(),f=h.getHighWaterMark,_=Pr().codes,p=_.ERR_INVALID_ARG_TYPE,b=_.ERR_STREAM_PUSH_AFTER_EOF,w=_.ERR_METHOD_NOT_IMPLEMENTED,m=_.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,g,v,E;dn()($,t);var O=c.errorOrDestroy,C=["error","close","destroy","pause","resume"];function R(T,x,W){if(typeof T.prependListener=="function")return T.prependListener(x,W);!T._events||!T._events[x]?T.on(x,W):Array.isArray(T._events[x])?T._events[x].unshift(W):T._events[x]=[W,T._events[x]]}function I(T,x,W){n=n||vr(),T=T||{},typeof W!="boolean"&&(W=x instanceof n),this.objectMode=!!T.objectMode,W&&(this.objectMode=this.objectMode||!!T.readableObjectMode),this.highWaterMark=f(this,T,"readableHighWaterMark",W),this.buffer=new l,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=T.emitClose!==!1,this.autoDestroy=!!T.autoDestroy,this.destroyed=!1,this.defaultEncoding=T.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,T.encoding&&(g||(g=Rs().StringDecoder),this.decoder=new g(T.encoding),this.encoding=T.encoding)}function $(T){if(n=n||vr(),!(this instanceof $))return new $(T);var x=this instanceof n;this._readableState=new I(T,this,x),this.readable=!0,T&&(typeof T.read=="function"&&(this._read=T.read),typeof T.destroy=="function"&&(this._destroy=T.destroy)),t.call(this)}Object.defineProperty($.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(x){this._readableState&&(this._readableState.destroyed=x)}}),$.prototype.destroy=c.destroy,$.prototype._undestroy=c.undestroy,$.prototype._destroy=function(T,x){x(T)},$.prototype.push=function(T,x){var W=this._readableState,re;return W.objectMode?re=!0:typeof T=="string"&&(x=x||W.defaultEncoding,x!==W.encoding&&(T=r.from(T,x),x=""),re=!0),M(this,T,x,!1,re)},$.prototype.unshift=function(T){return M(this,T,null,!0,!1)};function M(T,x,W,re,_e){u("readableAddChunk",x);var he=T._readableState;if(x===null)he.reading=!1,j(T,he);else{var ye;if(_e||(ye=B(he,x)),ye)O(T,ye);else if(he.objectMode||x&&x.length>0)if(typeof x!="string"&&!he.objectMode&&Object.getPrototypeOf(x)!==r.prototype&&(x=a(x)),re)he.endEmitted?O(T,new m):z(T,he,x,!0);else if(he.ended)O(T,new b);else{if(he.destroyed)return!1;he.reading=!1,he.decoder&&!W?(x=he.decoder.write(x),he.objectMode||x.length!==0?z(T,he,x,!1):U(T,he)):z(T,he,x,!1)}else re||(he.reading=!1,U(T,he))}return!he.ended&&(he.length<he.highWaterMark||he.length===0)}function z(T,x,W,re){x.flowing&&x.length===0&&!x.sync?(x.awaitDrain=0,T.emit("data",W)):(x.length+=x.objectMode?1:W.length,re?x.buffer.unshift(W):x.buffer.push(W),x.needReadable&&D(T)),U(T,x)}function B(T,x){var W;return!s(x)&&typeof x!="string"&&x!==void 0&&!T.objectMode&&(W=new p("chunk",["string","Buffer","Uint8Array"],x)),W}$.prototype.isPaused=function(){return this._readableState.flowing===!1},$.prototype.setEncoding=function(T){g||(g=Rs().StringDecoder);var x=new g(T);this._readableState.decoder=x,this._readableState.encoding=this._readableState.decoder.encoding;for(var W=this._readableState.buffer.head,re="";W!==null;)re+=x.write(W.data),W=W.next;return this._readableState.buffer.clear(),re!==""&&this._readableState.buffer.push(re),this._readableState.length=re.length,this};var F=1073741824;function Y(T){return T>=F?T=F:(T--,T|=T>>>1,T|=T>>>2,T|=T>>>4,T|=T>>>8,T|=T>>>16,T++),T}function Z(T,x){return T<=0||x.length===0&&x.ended?0:x.objectMode?1:T!==T?x.flowing&&x.length?x.buffer.head.data.length:x.length:(T>x.highWaterMark&&(x.highWaterMark=Y(T)),T<=x.length?T:x.ended?x.length:(x.needReadable=!0,0))}$.prototype.read=function(T){u("read",T),T=parseInt(T,10);var x=this._readableState,W=T;if(T!==0&&(x.emittedReadable=!1),T===0&&x.needReadable&&((x.highWaterMark!==0?x.length>=x.highWaterMark:x.length>0)||x.ended))return u("read: emitReadable",x.length,x.ended),x.length===0&&x.ended?V(this):D(this),null;if(T=Z(T,x),T===0&&x.ended)return x.length===0&&V(this),null;var re=x.needReadable;u("need readable",re),(x.length===0||x.length-T<x.highWaterMark)&&(re=!0,u("length less than watermark",re)),x.ended||x.reading?(re=!1,u("reading or ended",re)):re&&(u("do read"),x.reading=!0,x.sync=!0,x.length===0&&(x.needReadable=!0),this._read(x.highWaterMark),x.sync=!1,x.reading||(T=Z(W,x)));var _e;return T>0?_e=k(T,x):_e=null,_e===null?(x.needReadable=x.length<=x.highWaterMark,T=0):(x.length-=T,x.awaitDrain=0),x.length===0&&(x.ended||(x.needReadable=!0),W!==T&&x.ended&&V(this)),_e!==null&&this.emit("data",_e),_e};function j(T,x){if(u("onEofChunk"),!x.ended){if(x.decoder){var W=x.decoder.end();W&&W.length&&(x.buffer.push(W),x.length+=x.objectMode?1:W.length)}x.ended=!0,x.sync?D(T):(x.needReadable=!1,x.emittedReadable||(x.emittedReadable=!0,G(T)))}}function D(T){var x=T._readableState;u("emitReadable",x.needReadable,x.emittedReadable),x.needReadable=!1,x.emittedReadable||(u("emitReadable",x.flowing),x.emittedReadable=!0,process.nextTick(G,T))}function G(T){var x=T._readableState;u("emitReadable_",x.destroyed,x.length,x.ended),!x.destroyed&&(x.length||x.ended)&&(T.emit("readable"),x.emittedReadable=!1),x.needReadable=!x.flowing&&!x.ended&&x.length<=x.highWaterMark,N(T)}function U(T,x){x.readingMore||(x.readingMore=!0,process.nextTick(H,T,x))}function H(T,x){for(;!x.reading&&!x.ended&&(x.length<x.highWaterMark||x.flowing&&x.length===0);){var W=x.length;if(u("maybeReadMore read 0"),T.read(0),W===x.length)break}x.readingMore=!1}$.prototype._read=function(T){O(this,new w("_read()"))},$.prototype.pipe=function(T,x){var W=this,re=this._readableState;switch(re.pipesCount){case 0:re.pipes=T;break;case 1:re.pipes=[re.pipes,T];break;default:re.pipes.push(T);break}re.pipesCount+=1,u("pipe count=%d opts=%j",re.pipesCount,x);var _e=(!x||x.end!==!1)&&T!==process.stdout&&T!==process.stderr,he=_e?ke:te;re.endEmitted?process.nextTick(he):W.once("end",he),T.on("unpipe",ye);function ye(S,d){u("onunpipe"),S===W&&d&&d.hasUnpiped===!1&&(d.hasUnpiped=!0,Ye())}function ke(){u("onend"),T.end()}var Et=J(W);T.on("drain",Et);var ie=!1;function Ye(){u("cleanup"),T.removeListener("close",de),T.removeListener("finish",ne),T.removeListener("drain",Et),T.removeListener("error",ue),T.removeListener("unpipe",ye),W.removeListener("end",ke),W.removeListener("end",te),W.removeListener("data",ce),ie=!0,re.awaitDrain&&(!T._writableState||T._writableState.needDrain)&&Et()}W.on("data",ce);function ce(S){u("ondata");var d=T.write(S);u("dest.write",d),d===!1&&((re.pipesCount===1&&re.pipes===T||re.pipesCount>1&&oe(re.pipes,T)!==-1)&&!ie&&(u("false write response, pause",re.awaitDrain),re.awaitDrain++),W.pause())}function ue(S){u("onerror",S),te(),T.removeListener("error",ue),e(T,"error")===0&&O(T,S)}R(T,"error",ue);function de(){T.removeListener("finish",ne),te()}T.once("close",de);function ne(){u("onfinish"),T.removeListener("close",de),te()}T.once("finish",ne);function te(){u("unpipe"),W.unpipe(T)}return T.emit("pipe",W),re.flowing||(u("pipe resume"),W.resume()),T};function J(T){return function(){var W=T._readableState;u("pipeOnDrain",W.awaitDrain),W.awaitDrain&&W.awaitDrain--,W.awaitDrain===0&&e(T,"data")&&(W.flowing=!0,N(T))}}$.prototype.unpipe=function(T){var x=this._readableState,W={hasUnpiped:!1};if(x.pipesCount===0)return this;if(x.pipesCount===1)return T&&T!==x.pipes?this:(T||(T=x.pipes),x.pipes=null,x.pipesCount=0,x.flowing=!1,T&&T.emit("unpipe",this,W),this);if(!T){var re=x.pipes,_e=x.pipesCount;x.pipes=null,x.pipesCount=0,x.flowing=!1;for(var he=0;he<_e;he++)re[he].emit("unpipe",this,{hasUnpiped:!1});return this}var ye=oe(x.pipes,T);return ye===-1?this:(x.pipes.splice(ye,1),x.pipesCount-=1,x.pipesCount===1&&(x.pipes=x.pipes[0]),T.emit("unpipe",this,W),this)},$.prototype.on=function(T,x){var W=t.prototype.on.call(this,T,x),re=this._readableState;return T==="data"?(re.readableListening=this.listenerCount("readable")>0,re.flowing!==!1&&this.resume()):T==="readable"&&!re.endEmitted&&!re.readableListening&&(re.readableListening=re.needReadable=!0,re.flowing=!1,re.emittedReadable=!1,u("on readable",re.length,re.reading),re.length?D(this):re.reading||process.nextTick(ae,this)),W},$.prototype.addListener=$.prototype.on,$.prototype.removeListener=function(T,x){var W=t.prototype.removeListener.call(this,T,x);return T==="readable"&&process.nextTick(X,this),W},$.prototype.removeAllListeners=function(T){var x=t.prototype.removeAllListeners.apply(this,arguments);return(T==="readable"||T===void 0)&&process.nextTick(X,this),x};function X(T){var x=T._readableState;x.readableListening=T.listenerCount("readable")>0,x.resumeScheduled&&!x.paused?x.flowing=!0:T.listenerCount("data")>0&&T.resume()}function ae(T){u("readable nexttick read 0"),T.read(0)}$.prototype.resume=function(){var T=this._readableState;return T.flowing||(u("resume"),T.flowing=!T.readableListening,Q(this,T)),T.paused=!1,this};function Q(T,x){x.resumeScheduled||(x.resumeScheduled=!0,process.nextTick(ee,T,x))}function ee(T,x){u("resume",x.reading),x.reading||T.read(0),x.resumeScheduled=!1,T.emit("resume"),N(T),x.flowing&&!x.reading&&T.read(0)}$.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function N(T){var x=T._readableState;for(u("flow",x.flowing);x.flowing&&T.read()!==null;);}$.prototype.wrap=function(T){var x=this,W=this._readableState,re=!1;T.on("end",function(){if(u("wrapped end"),W.decoder&&!W.ended){var ye=W.decoder.end();ye&&ye.length&&x.push(ye)}x.push(null)}),T.on("data",function(ye){if(u("wrapped data"),W.decoder&&(ye=W.decoder.write(ye)),!(W.objectMode&&ye==null)&&!(!W.objectMode&&(!ye||!ye.length))){var ke=x.push(ye);ke||(re=!0,T.pause())}});for(var _e in T)this[_e]===void 0&&typeof T[_e]=="function"&&(this[_e]=(function(ke){return function(){return T[ke].apply(T,arguments)}})(_e));for(var he=0;he<C.length;he++)T.on(C[he],this.emit.bind(this,C[he]));return this._read=function(ye){u("wrapped _read",ye),re&&(re=!1,T.resume())},this},typeof Symbol=="function"&&($.prototype[Symbol.asyncIterator]=function(){return v===void 0&&(v=bp()),v(this)}),Object.defineProperty($.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty($.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty($.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(x){this._readableState&&(this._readableState.flowing=x)}}),$._fromList=k,Object.defineProperty($.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function k(T,x){if(x.length===0)return null;var W;return x.objectMode?W=x.buffer.shift():!T||T>=x.length?(x.decoder?W=x.buffer.join(""):x.buffer.length===1?W=x.buffer.first():W=x.buffer.concat(x.length),x.buffer.clear()):W=x.buffer.consume(T,x.decoder),W}function V(T){var x=T._readableState;u("endReadable",x.endEmitted),x.endEmitted||(x.ended=!0,process.nextTick(se,x,T))}function se(T,x){if(u("endReadableNT",T.endEmitted,T.length),!T.endEmitted&&T.length===0&&(T.endEmitted=!0,x.readable=!1,x.emit("end"),T.autoDestroy)){var W=x._writableState;(!W||W.autoDestroy&&W.finished)&&x.destroy()}}typeof Symbol=="function"&&($.from=function(T,x){return E===void 0&&(E=_p()),E($,T,x)});function oe(T,x){for(var W=0,re=T.length;W<re;W++)if(T[W]===x)return W;return-1}return ja}var Ma,Wu;function vr(){if(Wu)return Ma;Wu=1;var n=Object.keys||function(l){var c=[];for(var h in l)c.push(h);return c};Ma=s;var e=$f(),t=Ri();dn()(s,e);for(var r=n(t.prototype),i=0;i<r.length;i++){var a=r[i];s.prototype[a]||(s.prototype[a]=t.prototype[a])}function s(l){if(!(this instanceof s))return new s(l);e.call(this,l),t.call(this,l),this.allowHalfOpen=!0,l&&(l.readable===!1&&(this.readable=!1),l.writable===!1&&(this.writable=!1),l.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",o)))}Object.defineProperty(s.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(s.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(s.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function o(){this._writableState.ended||process.nextTick(u,this)}function u(l){l.end()}return Object.defineProperty(s.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(c){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=c,this._writableState.destroyed=c)}}),Ma}var ka,Ju;function Ri(){if(Ju)return ka;Ju=1,ka=I;function n(N){var k=this;this.next=null,this.entry=null,this.finish=function(){ee(k,N)}}var e;I.WritableState=C;var t={deprecate:pp()},r=Rf(),i=Ai().Buffer,a=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function s(N){return i.from(N)}function o(N){return i.isBuffer(N)||N instanceof a}var u=If(),l=Cf(),c=l.getHighWaterMark,h=Pr().codes,f=h.ERR_INVALID_ARG_TYPE,_=h.ERR_METHOD_NOT_IMPLEMENTED,p=h.ERR_MULTIPLE_CALLBACK,b=h.ERR_STREAM_CANNOT_PIPE,w=h.ERR_STREAM_DESTROYED,m=h.ERR_STREAM_NULL_VALUES,g=h.ERR_STREAM_WRITE_AFTER_END,v=h.ERR_UNKNOWN_ENCODING,E=u.errorOrDestroy;dn()(I,r);function O(){}function C(N,k,V){e=e||vr(),N=N||{},typeof V!="boolean"&&(V=k instanceof e),this.objectMode=!!N.objectMode,V&&(this.objectMode=this.objectMode||!!N.writableObjectMode),this.highWaterMark=c(this,N,"writableHighWaterMark",V),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var se=N.decodeStrings===!1;this.decodeStrings=!se,this.defaultEncoding=N.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(oe){j(k,oe)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=N.emitClose!==!1,this.autoDestroy=!!N.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new n(this)}C.prototype.getBuffer=function(){for(var k=this.bufferedRequest,V=[];k;)V.push(k),k=k.next;return V},(function(){try{Object.defineProperty(C.prototype,"buffer",{get:t.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var R;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(R=Function.prototype[Symbol.hasInstance],Object.defineProperty(I,Symbol.hasInstance,{value:function(k){return R.call(this,k)?!0:this!==I?!1:k&&k._writableState instanceof C}})):R=function(k){return k instanceof this};function I(N){e=e||vr();var k=this instanceof e;if(!k&&!R.call(I,this))return new I(N);this._writableState=new C(N,this,k),this.writable=!0,N&&(typeof N.write=="function"&&(this._write=N.write),typeof N.writev=="function"&&(this._writev=N.writev),typeof N.destroy=="function"&&(this._destroy=N.destroy),typeof N.final=="function"&&(this._final=N.final)),r.call(this)}I.prototype.pipe=function(){E(this,new b)};function $(N,k){var V=new g;E(N,V),process.nextTick(k,V)}function M(N,k,V,se){var oe;return V===null?oe=new m:typeof V!="string"&&!k.objectMode&&(oe=new f("chunk",["string","Buffer"],V)),oe?(E(N,oe),process.nextTick(se,oe),!1):!0}I.prototype.write=function(N,k,V){var se=this._writableState,oe=!1,T=!se.objectMode&&o(N);return T&&!i.isBuffer(N)&&(N=s(N)),typeof k=="function"&&(V=k,k=null),T?k="buffer":k||(k=se.defaultEncoding),typeof V!="function"&&(V=O),se.ending?$(this,V):(T||M(this,se,N,V))&&(se.pendingcb++,oe=B(this,se,T,N,k,V)),oe},I.prototype.cork=function(){this._writableState.corked++},I.prototype.uncork=function(){var N=this._writableState;N.corked&&(N.corked--,!N.writing&&!N.corked&&!N.bufferProcessing&&N.bufferedRequest&&U(this,N))},I.prototype.setDefaultEncoding=function(k){if(typeof k=="string"&&(k=k.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((k+"").toLowerCase())>-1))throw new v(k);return this._writableState.defaultEncoding=k,this},Object.defineProperty(I.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function z(N,k,V){return!N.objectMode&&N.decodeStrings!==!1&&typeof k=="string"&&(k=i.from(k,V)),k}Object.defineProperty(I.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function B(N,k,V,se,oe,T){if(!V){var x=z(k,se,oe);se!==x&&(V=!0,oe="buffer",se=x)}var W=k.objectMode?1:se.length;k.length+=W;var re=k.length<k.highWaterMark;if(re||(k.needDrain=!0),k.writing||k.corked){var _e=k.lastBufferedRequest;k.lastBufferedRequest={chunk:se,encoding:oe,isBuf:V,callback:T,next:null},_e?_e.next=k.lastBufferedRequest:k.bufferedRequest=k.lastBufferedRequest,k.bufferedRequestCount+=1}else F(N,k,!1,W,se,oe,T);return re}function F(N,k,V,se,oe,T,x){k.writelen=se,k.writecb=x,k.writing=!0,k.sync=!0,k.destroyed?k.onwrite(new w("write")):V?N._writev(oe,k.onwrite):N._write(oe,T,k.onwrite),k.sync=!1}function Y(N,k,V,se,oe){--k.pendingcb,V?(process.nextTick(oe,se),process.nextTick(ae,N,k),N._writableState.errorEmitted=!0,E(N,se)):(oe(se),N._writableState.errorEmitted=!0,E(N,se),ae(N,k))}function Z(N){N.writing=!1,N.writecb=null,N.length-=N.writelen,N.writelen=0}function j(N,k){var V=N._writableState,se=V.sync,oe=V.writecb;if(typeof oe!="function")throw new p;if(Z(V),k)Y(N,V,se,k,oe);else{var T=H(V)||N.destroyed;!T&&!V.corked&&!V.bufferProcessing&&V.bufferedRequest&&U(N,V),se?process.nextTick(D,N,V,T,oe):D(N,V,T,oe)}}function D(N,k,V,se){V||G(N,k),k.pendingcb--,se(),ae(N,k)}function G(N,k){k.length===0&&k.needDrain&&(k.needDrain=!1,N.emit("drain"))}function U(N,k){k.bufferProcessing=!0;var V=k.bufferedRequest;if(N._writev&&V&&V.next){var se=k.bufferedRequestCount,oe=new Array(se),T=k.corkedRequestsFree;T.entry=V;for(var x=0,W=!0;V;)oe[x]=V,V.isBuf||(W=!1),V=V.next,x+=1;oe.allBuffers=W,F(N,k,!0,k.length,oe,"",T.finish),k.pendingcb++,k.lastBufferedRequest=null,T.next?(k.corkedRequestsFree=T.next,T.next=null):k.corkedRequestsFree=new n(k),k.bufferedRequestCount=0}else{for(;V;){var re=V.chunk,_e=V.encoding,he=V.callback,ye=k.objectMode?1:re.length;if(F(N,k,!1,ye,re,_e,he),V=V.next,k.bufferedRequestCount--,k.writing)break}V===null&&(k.lastBufferedRequest=null)}k.bufferedRequest=V,k.bufferProcessing=!1}I.prototype._write=function(N,k,V){V(new _("_write()"))},I.prototype._writev=null,I.prototype.end=function(N,k,V){var se=this._writableState;return typeof N=="function"?(V=N,N=null,k=null):typeof k=="function"&&(V=k,k=null),N!=null&&this.write(N,k),se.corked&&(se.corked=1,this.uncork()),se.ending||Q(this,se,V),this},Object.defineProperty(I.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function H(N){return N.ending&&N.length===0&&N.bufferedRequest===null&&!N.finished&&!N.writing}function J(N,k){N._final(function(V){k.pendingcb--,V&&E(N,V),k.prefinished=!0,N.emit("prefinish"),ae(N,k)})}function X(N,k){!k.prefinished&&!k.finalCalled&&(typeof N._final=="function"&&!k.destroyed?(k.pendingcb++,k.finalCalled=!0,process.nextTick(J,N,k)):(k.prefinished=!0,N.emit("prefinish")))}function ae(N,k){var V=H(k);if(V&&(X(N,k),k.pendingcb===0&&(k.finished=!0,N.emit("finish"),k.autoDestroy))){var se=N._readableState;(!se||se.autoDestroy&&se.endEmitted)&&N.destroy()}return V}function Q(N,k,V){k.ending=!0,ae(N,k),V&&(k.finished?process.nextTick(V):N.once("finish",V)),k.ended=!0,N.writable=!1}function ee(N,k,V){var se=N.entry;for(N.entry=null;se;){var oe=se.callback;k.pendingcb--,oe(V),se=se.next}k.corkedRequestsFree.next=N}return Object.defineProperty(I.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(k){this._writableState&&(this._writableState.destroyed=k)}}),I.prototype.destroy=u.destroy,I.prototype._undestroy=u.undestroy,I.prototype._destroy=function(N,k){k(N)},ka}var Ku;function jf(){if(Ku)return wa.exports;Ku=1;var n=ft,e=Ri(),t=xe(),r=t.LEVEL,i=wa.exports=function(){var s=this,o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e.call(this,{objectMode:!0,highWaterMark:o.highWaterMark}),this.format=o.format,this.level=o.level,this.handleExceptions=o.handleExceptions,this.handleRejections=o.handleRejections,this.silent=o.silent,o.log&&(this.log=o.log),o.logv&&(this.logv=o.logv),o.close&&(this.close=o.close),this.once("pipe",function(u){s.levels=u.levels,s.parent=u}),this.once("unpipe",function(u){u===s.parent&&(s.parent=null,s.close&&s.close())})};return n.inherits(i,e),i.prototype._write=function(s,o,u){if(this.silent||s.exception===!0&&!this.handleExceptions)return u(null);var l=this.level||this.parent&&this.parent.level;if(!l||this.levels[l]>=this.levels[s[r]]){if(s&&!this.format)return this.log(s,u);var c=void 0,h=void 0;try{h=this.format.transform(Object.assign({},s),this.format.options)}catch(f){c=f}if(c||!h){if(u(),c)throw c;return}return this.log(h,u)}return this._writableState.sync=!1,u(null)},i.prototype._writev=function(s,o){if(this.logv){var u=s.filter(this._accept,this);return u.length?this.logv(u,o):o(null)}for(var l=0;l<s.length;l++)if(this._accept(s[l])){if(s[l].chunk&&!this.format){this.log(s[l].chunk,s[l].callback);continue}var c=void 0,h=void 0;try{h=this.format.transform(Object.assign({},s[l].chunk),this.format.options)}catch(f){c=f}if(c||!h){if(s[l].callback(),c)throw o(null),c}else this.log(h,s[l].callback)}return o(null)},i.prototype._accept=function(s){var o=s.chunk;if(this.silent)return!1;var u=this.level||this.parent&&this.parent.level;return!!((o.exception===!0||!u||this.levels[u]>=this.levels[o[r]])&&(this.handleExceptions||o.exception!==!0))},i.prototype._nop=function(){},wa.exports}var Na={exports:{}},Yu;function vp(){if(Yu)return Na.exports;Yu=1;var n=ft,e=xe(),t=e.LEVEL,r=jf(),i=Na.exports=function(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(r.call(this,s),!s.transport||typeof s.transport.log!="function")throw new Error("Invalid transport, must be an object with a log method.");this.transport=s.transport,this.level=this.level||s.transport.level,this.handleExceptions=this.handleExceptions||s.transport.handleExceptions,this._deprecated();function o(u){this.emit("error",u,this.transport)}this.transport.__winstonError||(this.transport.__winstonError=o.bind(this),this.transport.on("error",this.transport.__winstonError))};return n.inherits(i,r),i.prototype._write=function(s,o,u){if(this.silent||s.exception===!0&&!this.handleExceptions)return u(null);(!this.level||this.levels[this.level]>=this.levels[s[t]])&&this.transport.log(s[t],s.message,s,this._nop),u(null)},i.prototype._writev=function(s,o){for(var u=0;u<s.length;u++)this._accept(s[u])&&(this.transport.log(s[u].chunk[t],s[u].chunk.message,s[u].chunk,this._nop),s[u].callback());return o(null)},i.prototype._deprecated=function(){console.error([this.transport.name+" is a legacy winston transport. Consider upgrading: ","- Upgrade docs: https://github.com/winstonjs/winston/blob/master/UPGRADE-3.0.md"].join(`
|
|
34
|
+
`))},i.prototype.close=function(){this.transport.close&&this.transport.close(),this.transport.__winstonError&&(this.transport.removeListener("error",this.transport.__winstonError),this.transport.__winstonError=null)},Na.exports}var Qu;function hn(){return Qu||(Qu=1,Pn.exports=jf(),Pn.exports.LegacyTransportStream=vp()),Pn.exports}var La,Zu;function wp(){if(Zu)return La;Zu=1;function n(g){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(v){return typeof v}:function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v},n(g)}function e(g,v){if(!(g instanceof v))throw new TypeError("Cannot call a class as a function")}function t(g,v){for(var E=0;E<v.length;E++){var O=v[E];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(g,i(O.key),O)}}function r(g,v,E){return v&&t(g.prototype,v),Object.defineProperty(g,"prototype",{writable:!1}),g}function i(g){var v=a(g,"string");return n(v)=="symbol"?v:v+""}function a(g,v){if(n(g)!="object"||!g)return g;var E=g[Symbol.toPrimitive];if(E!==void 0){var O=E.call(g,v);if(n(O)!="object")return O;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}function s(g,v,E){return v=c(v),o(g,l()?Reflect.construct(v,E||[],c(g).constructor):v.apply(g,E))}function o(g,v){if(v&&(n(v)=="object"||typeof v=="function"))return v;if(v!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return u(g)}function u(g){if(g===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g}function l(){try{var g=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(l=function(){return!!g})()}function c(g){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(v){return v.__proto__||Object.getPrototypeOf(v)},c(g)}function h(g,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function");g.prototype=Object.create(v&&v.prototype,{constructor:{value:g,writable:!0,configurable:!0}}),Object.defineProperty(g,"prototype",{writable:!1}),v&&f(g,v)}function f(g,v){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,O){return E.__proto__=O,E},f(g,v)}var _=ut,p=xe(),b=p.LEVEL,w=p.MESSAGE,m=hn();return La=(function(g){function v(){var E,O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return e(this,v),E=s(this,v,[O]),E.name=O.name||"console",E.stderrLevels=E._stringArrayToSet(O.stderrLevels),E.consoleWarnLevels=E._stringArrayToSet(O.consoleWarnLevels),E.eol=typeof O.eol=="string"?O.eol:_.EOL,E.forceConsole=O.forceConsole||!1,E._consoleLog=console.log.bind(console),E._consoleWarn=console.warn.bind(console),E._consoleError=console.error.bind(console),E.setMaxListeners(30),E}return h(v,g),r(v,[{key:"log",value:function(O,C){var R=this;if(setImmediate(function(){return R.emit("logged",O)}),this.stderrLevels[O[b]]){console._stderr&&!this.forceConsole?console._stderr.write("".concat(O[w]).concat(this.eol)):this._consoleError(O[w]),C&&C();return}else if(this.consoleWarnLevels[O[b]]){console._stderr&&!this.forceConsole?console._stderr.write("".concat(O[w]).concat(this.eol)):this._consoleWarn(O[w]),C&&C();return}console._stdout&&!this.forceConsole?console._stdout.write("".concat(O[w]).concat(this.eol)):this._consoleLog(O[w]),C&&C()}},{key:"_stringArrayToSet",value:function(O,C){if(!O)return{};if(C=C||"Cannot make set from type other than Array of string elements",!Array.isArray(O))throw new Error(C);return O.reduce(function(R,I){if(typeof I!="string")throw new Error(C);return R[I]=!0,R},{})}}])})(m),La}function Bt(...n){return n.filter(Boolean).join("/").replace(/\/+/g,"/").replace(/\/$/,"")}function Mf(...n){return Bt(...n)}function li(n){const e=n.split("/");return e.pop(),e.join("/")||"/"}function so(n,e){const t=n.split("/");let r=t[t.length-1]||"";return e&&r.endsWith(e)&&(r=r.slice(0,-e.length)),r}function kf(n){const e=so(n),t=e.lastIndexOf(".");return t>0?e.slice(t):""}function Nf(n){return n.replace(/\/+/g,"/")}function oo(n){return n.startsWith("/")}const Lf="/",Ff=":",Ep={join:Bt,resolve:Mf,dirname:li,basename:so,extname:kf,normalize:Nf,isAbsolute:oo,sep:Lf,delimiter:Ff},Df=Object.freeze(Object.defineProperty({__proto__:null,basename:so,default:Ep,delimiter:Ff,dirname:li,extname:kf,isAbsolute:oo,join:Bt,normalize:Nf,resolve:Mf,sep:Lf},Symbol.toStringTag,{value:"Module"})),Sp=xi(Df);var Cn={exports:{}},$n={exports:{}},jn={exports:{}},Xu;function uo(){return Xu||(Xu=1,(function(n,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(r){return r&&typeof r.length=="number"&&r.length>=0&&r.length%1===0}n.exports=e.default})(jn,jn.exports)),jn.exports}var it={},Mn={exports:{}},kn={exports:{}},el;function Op(){return el||(el=1,(function(n,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){return function(...r){var i=r.pop();return t.call(this,r,i)}},n.exports=e.default})(kn,kn.exports)),kn.exports}var dt={},tl;function Tp(){if(tl)return dt;tl=1,Object.defineProperty(dt,"__esModule",{value:!0}),dt.fallback=r,dt.wrap=i;var n=dt.hasQueueMicrotask=typeof queueMicrotask=="function"&&queueMicrotask,e=dt.hasSetImmediate=typeof setImmediate=="function"&&setImmediate,t=dt.hasNextTick=typeof process=="object"&&typeof process.nextTick=="function";function r(s){setTimeout(s,0)}function i(s){return(o,...u)=>s(()=>o(...u))}var a;return n?a=queueMicrotask:e?a=setImmediate:t?a=process.nextTick:a=r,dt.default=i(a),dt}var rl;function Pp(){return rl||(rl=1,(function(n,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var t=Op(),r=o(t),i=Tp(),a=o(i),s=xr();function o(h){return h&&h.__esModule?h:{default:h}}function u(h){return(0,s.isAsync)(h)?function(...f){const _=f.pop(),p=h.apply(this,f);return l(p,_)}:(0,r.default)(function(f,_){var p;try{p=h.apply(this,f)}catch(b){return _(b)}if(p&&typeof p.then=="function")return l(p,_);_(null,p)})}function l(h,f){return h.then(_=>{c(f,null,_)},_=>{c(f,_&&(_ instanceof Error||_.message)?_:new Error(_))})}function c(h,f,_){try{h(f,_)}catch(p){(0,a.default)(b=>{throw b},p)}}n.exports=e.default})(Mn,Mn.exports)),Mn.exports}var nl;function xr(){if(nl)return it;nl=1,Object.defineProperty(it,"__esModule",{value:!0}),it.isAsyncIterable=it.isAsyncGenerator=it.isAsync=void 0;var n=Pp(),e=t(n);function t(o){return o&&o.__esModule?o:{default:o}}function r(o){return o[Symbol.toStringTag]==="AsyncFunction"}function i(o){return o[Symbol.toStringTag]==="AsyncGenerator"}function a(o){return typeof o[Symbol.asyncIterator]=="function"}function s(o){if(typeof o!="function")throw new Error("expected a function");return r(o)?(0,e.default)(o):o}return it.default=s,it.isAsync=r,it.isAsyncGenerator=i,it.isAsyncIterable=a,it}var Nn={exports:{}},il;function pn(){return il||(il=1,(function(n,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(r,i){if(i||(i=r.length),!i)throw new Error("arity is undefined");function a(...s){return typeof s[i-1]=="function"?r.apply(this,s):new Promise((o,u)=>{s[i-1]=(l,...c)=>{if(l)return u(l);o(c.length>1?c:c[0])},r.apply(this,s)})}return a}n.exports=e.default})(Nn,Nn.exports)),Nn.exports}var al;function xp(){return al||(al=1,(function(n,e){Object.defineProperty(e,"__esModule",{value:!0});var t=uo(),r=u(t),i=xr(),a=u(i),s=pn(),o=u(s);function u(l){return l&&l.__esModule?l:{default:l}}e.default=(0,o.default)((l,c,h)=>{var f=(0,r.default)(c)?[]:{};l(c,(_,p,b)=>{(0,a.default)(_)((w,...m)=>{m.length<2&&([m]=m),f[p]=m,b(w)})},_=>h(_,f))},3),n.exports=e.default})($n,$n.exports)),$n.exports}var Ln={exports:{}},Fn={exports:{}},Dn={exports:{}},Un={exports:{}},sl;function Uf(){return sl||(sl=1,(function(n,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(r){function i(...a){if(r!==null){var s=r;r=null,s.apply(this,a)}}return Object.assign(i,r),i}n.exports=e.default})(Un,Un.exports)),Un.exports}var Bn={exports:{}},qn={exports:{}},ol;function Ap(){return ol||(ol=1,(function(n,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){return t[Symbol.iterator]&&t[Symbol.iterator]()},n.exports=e.default})(qn,qn.exports)),qn.exports}var ul;function Rp(){return ul||(ul=1,(function(n,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var t=uo(),r=s(t),i=Ap(),a=s(i);function s(h){return h&&h.__esModule?h:{default:h}}function o(h){var f=-1,_=h.length;return function(){return++f<_?{value:h[f],key:f}:null}}function u(h){var f=-1;return function(){var p=h.next();return p.done?null:(f++,{value:p.value,key:f})}}function l(h){var f=h?Object.keys(h):[],_=-1,p=f.length;return function b(){var w=f[++_];return w==="__proto__"?b():_<p?{value:h[w],key:w}:null}}function c(h){if((0,r.default)(h))return o(h);var f=(0,a.default)(h);return f?u(f):l(h)}n.exports=e.default})(Bn,Bn.exports)),Bn.exports}var zn={exports:{}},ll;function Bf(){return ll||(ll=1,(function(n,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(r){return function(...i){if(r===null)throw new Error("Callback was already called.");var a=r;r=null,a.apply(this,i)}}n.exports=e.default})(zn,zn.exports)),zn.exports}var Hn={exports:{}},Gn={exports:{}},cl;function lo(){return cl||(cl=1,(function(n,e){Object.defineProperty(e,"__esModule",{value:!0});const t={};e.default=t,n.exports=e.default})(Gn,Gn.exports)),Gn.exports}var fl;function Ip(){return fl||(fl=1,(function(n,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=a;var t=lo(),r=i(t);function i(s){return s&&s.__esModule?s:{default:s}}function a(s,o,u,l){let c=!1,h=!1,f=!1,_=0,p=0;function b(){_>=o||f||c||(f=!0,s.next().then(({value:g,done:v})=>{if(!(h||c)){if(f=!1,v){c=!0,_<=0&&l(null);return}_++,u(g,p,w),p++,b()}}).catch(m))}function w(g,v){if(_-=1,!h){if(g)return m(g);if(g===!1){c=!0,h=!0;return}if(v===r.default||c&&_<=0)return c=!0,l(null);b()}}function m(g){h||(f=!1,c=!0,l(g))}b()}n.exports=e.default})(Hn,Hn.exports)),Hn.exports}var dl;function Cp(){return dl||(dl=1,(function(n,e){Object.defineProperty(e,"__esModule",{value:!0});var t=Uf(),r=_(t),i=Rp(),a=_(i),s=Bf(),o=_(s),u=xr(),l=Ip(),c=_(l),h=lo(),f=_(h);function _(p){return p&&p.__esModule?p:{default:p}}e.default=p=>(b,w,m)=>{if(m=(0,r.default)(m),p<=0)throw new RangeError("concurrency limit cannot be less than 1");if(!b)return m(null);if((0,u.isAsyncGenerator)(b))return(0,c.default)(b,p,w,m);if((0,u.isAsyncIterable)(b))return(0,c.default)(b[Symbol.asyncIterator](),p,w,m);var g=(0,a.default)(b),v=!1,E=!1,O=0,C=!1;function R($,M){if(!E)if(O-=1,$)v=!0,m($);else if($===!1)v=!0,E=!0;else{if(M===f.default||v&&O<=0)return v=!0,m(null);C||I()}}function I(){for(C=!0;O<p&&!v;){var $=g();if($===null){v=!0,O<=0&&m(null);return}O+=1,w($.value,$.key,(0,o.default)(R))}C=!1}I()},n.exports=e.default})(Dn,Dn.exports)),Dn.exports}var hl;function qf(){return hl||(hl=1,(function(n,e){Object.defineProperty(e,"__esModule",{value:!0});var t=Cp(),r=u(t),i=xr(),a=u(i),s=pn(),o=u(s);function u(c){return c&&c.__esModule?c:{default:c}}function l(c,h,f,_){return(0,r.default)(h)(c,(0,a.default)(f),_)}e.default=(0,o.default)(l,4),n.exports=e.default})(Fn,Fn.exports)),Fn.exports}var pl;function $p(){return pl||(pl=1,(function(n,e){Object.defineProperty(e,"__esModule",{value:!0});var t=qf(),r=s(t),i=pn(),a=s(i);function s(u){return u&&u.__esModule?u:{default:u}}function o(u,l,c){return(0,r.default)(u,1,l,c)}e.default=(0,a.default)(o,3),n.exports=e.default})(Ln,Ln.exports)),Ln.exports}var ml;function jp(){return ml||(ml=1,(function(n,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=o;var t=xp(),r=s(t),i=$p(),a=s(i);function s(u){return u&&u.__esModule?u:{default:u}}function o(u,l){return(0,r.default)(a.default,u,l)}n.exports=e.default})(Cn,Cn.exports)),Cn.exports}var Vn={exports:{}},Fa,gl;function zf(){if(gl)return Fa;gl=1,Fa=o;var n=Pr().codes,e=n.ERR_METHOD_NOT_IMPLEMENTED,t=n.ERR_MULTIPLE_CALLBACK,r=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,i=n.ERR_TRANSFORM_WITH_LENGTH_0,a=vr();dn()(o,a);function s(c,h){var f=this._transformState;f.transforming=!1;var _=f.writecb;if(_===null)return this.emit("error",new t);f.writechunk=null,f.writecb=null,h!=null&&this.push(h),_(c);var p=this._readableState;p.reading=!1,(p.needReadable||p.length<p.highWaterMark)&&this._read(p.highWaterMark)}function o(c){if(!(this instanceof o))return new o(c);a.call(this,c),this._transformState={afterTransform:s.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,c&&(typeof c.transform=="function"&&(this._transform=c.transform),typeof c.flush=="function"&&(this._flush=c.flush)),this.on("prefinish",u)}function u(){var c=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(h,f){l(c,h,f)}):l(this,null,null)}o.prototype.push=function(c,h){return this._transformState.needTransform=!1,a.prototype.push.call(this,c,h)},o.prototype._transform=function(c,h,f){f(new e("_transform()"))},o.prototype._write=function(c,h,f){var _=this._transformState;if(_.writecb=f,_.writechunk=c,_.writeencoding=h,!_.transforming){var p=this._readableState;(_.needTransform||p.needReadable||p.length<p.highWaterMark)&&this._read(p.highWaterMark)}},o.prototype._read=function(c){var h=this._transformState;h.writechunk!==null&&!h.transforming?(h.transforming=!0,this._transform(h.writechunk,h.writeencoding,h.afterTransform)):h.needTransform=!0},o.prototype._destroy=function(c,h){a.prototype._destroy.call(this,c,function(f){h(f)})};function l(c,h,f){if(h)return c.emit("error",h);if(f!=null&&c.push(f),c._writableState.length)throw new i;if(c._transformState.transforming)throw new r;return c.push(null)}return Fa}var Da,yl;function Mp(){if(yl)return Da;yl=1,Da=e;var n=zf();dn()(e,n);function e(t){if(!(this instanceof e))return new e(t);n.call(this,t)}return e.prototype._transform=function(t,r,i){i(null,t)},Da}var Ua,bl;function kp(){if(bl)return Ua;bl=1;var n;function e(f){var _=!1;return function(){_||(_=!0,f.apply(void 0,arguments))}}var t=Pr().codes,r=t.ERR_MISSING_ARGS,i=t.ERR_STREAM_DESTROYED;function a(f){if(f)throw f}function s(f){return f.setHeader&&typeof f.abort=="function"}function o(f,_,p,b){b=e(b);var w=!1;f.on("close",function(){w=!0}),n===void 0&&(n=ao()),n(f,{readable:_,writable:p},function(g){if(g)return b(g);w=!0,b()});var m=!1;return function(g){if(!w&&!m){if(m=!0,s(f))return f.abort();if(typeof f.destroy=="function")return f.destroy();b(g||new i("pipe"))}}}function u(f){f()}function l(f,_){return f.pipe(_)}function c(f){return!f.length||typeof f[f.length-1]!="function"?a:f.pop()}function h(){for(var f=arguments.length,_=new Array(f),p=0;p<f;p++)_[p]=arguments[p];var b=c(_);if(Array.isArray(_[0])&&(_=_[0]),_.length<2)throw new r("streams");var w,m=_.map(function(g,v){var E=v<_.length-1,O=v>0;return o(g,E,O,function(C){w||(w=C),C&&m.forEach(u),!E&&(m.forEach(u),b(w))})});return _.reduce(l)}return Ua=h,Ua}var _l;function Ar(){return _l||(_l=1,(function(n,e){e=n.exports=$f(),e.Stream=e,e.Readable=e,e.Writable=Ri(),e.Duplex=vr(),e.Transform=zf(),e.PassThrough=Mp(),e.finished=ao(),e.pipeline=kp()})(Vn,Vn.exports)),Vn.exports}var Ba={exports:{}},qa,vl;function Np(){if(vl)return qa;vl=1;var n=[],e=[],t=function(){};function r(f){return~n.indexOf(f)?!1:(n.push(f),!0)}function i(f){t=f}function a(f){for(var _=[],p=0;p<n.length;p++){if(n[p].async){_.push(n[p]);continue}if(n[p](f))return!0}return _.length?new Promise(function(w){Promise.all(_.map(function(g){return g(f)})).then(function(g){w(g.some(Boolean))})}):!1}function s(f){return~e.indexOf(f)?!1:(e.push(f),!0)}function o(){t.apply(t,arguments)}function u(f){for(var _=0;_<e.length;_++)f=e[_].apply(e[_],arguments);return f}function l(f,_){var p=Object.prototype.hasOwnProperty;for(var b in _)p.call(_,b)&&(f[b]=_[b]);return f}function c(f){return f.enabled=!1,f.modify=s,f.set=i,f.use=r,l(function(){return!1},f)}function h(f){function _(){var p=Array.prototype.slice.call(arguments,0);return o.call(o,f,u(p,f)),!0}return f.enabled=!0,f.modify=s,f.set=i,f.use=r,l(_,f)}return qa=function(_){return _.introduce=l,_.enabled=a,_.process=u,_.modify=s,_.write=o,_.nope=c,_.yep=h,_.set=i,_.use=r,_},qa}var za,wl;function Lp(){if(wl)return za;wl=1;var n=Np(),e=n(function t(r,i){return i=i||{},i.namespace=r,i.prod=!0,i.dev=!1,i.force||t.force?t.yep(i):t.nope(i)});return za=e,za}var El;function Ii(){return El||(El=1,Ba.exports=Lp()),Ba.exports}var Ha,Sl;function Fp(){if(Sl)return Ha;Sl=1;var n=ut,e=Rs(),t=e.StringDecoder,r=Ar(),i=r.Stream;function a(){}return Ha=function(s,o){var u=Buffer.alloc(65536),l=new t("utf8"),c=new i,h="",f=0,_=0;return s.start===-1&&delete s.start,c.readable=!0,c.destroy=function(){c.destroyed=!0,c.emit("end"),c.emit("close")},n.open(s.file,"a+","0644",function(p,b){if(p){o?o(p):c.emit("error",p),c.destroy();return}(function w(){if(c.destroyed){n.close(b,a);return}return n.read(b,u,0,u.length,f,function(m,g){if(m){o?o(m):c.emit("error",m),c.destroy();return}if(!g)return h&&((s.start==null||_>s.start)&&(o?o(null,h):c.emit("line",h)),_++,h=""),setTimeout(w,1e3);var v=l.write(u.slice(0,g));o||c.emit("data",v),v=(h+v).split(/\n+/);for(var E=v.length-1,O=0;O<E;O++)(s.start==null||_>s.start)&&(o?o(null,v[O]):c.emit("line",v[O])),_++;return h=v[E],f+=g,w()})})()}),o?c.destroy:c},Ha}var Ga,Ol;function Dp(){if(Ol)return Ga;Ol=1;function n(M){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(z){return typeof z}:function(z){return z&&typeof Symbol=="function"&&z.constructor===Symbol&&z!==Symbol.prototype?"symbol":typeof z},n(M)}function e(M,z){if(!(M instanceof z))throw new TypeError("Cannot call a class as a function")}function t(M,z){for(var B=0;B<z.length;B++){var F=z[B];F.enumerable=F.enumerable||!1,F.configurable=!0,"value"in F&&(F.writable=!0),Object.defineProperty(M,i(F.key),F)}}function r(M,z,B){return z&&t(M.prototype,z),Object.defineProperty(M,"prototype",{writable:!1}),M}function i(M){var z=a(M,"string");return n(z)=="symbol"?z:z+""}function a(M,z){if(n(M)!="object"||!M)return M;var B=M[Symbol.toPrimitive];if(B!==void 0){var F=B.call(M,z);if(n(F)!="object")return F;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(M)}function s(M,z,B){return z=c(z),o(M,l()?Reflect.construct(z,B||[],c(M).constructor):z.apply(M,B))}function o(M,z){if(z&&(n(z)=="object"||typeof z=="function"))return z;if(z!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return u(M)}function u(M){if(M===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return M}function l(){try{var M=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(l=function(){return!!M})()}function c(M){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(z){return z.__proto__||Object.getPrototypeOf(z)},c(M)}function h(M,z){if(typeof z!="function"&&z!==null)throw new TypeError("Super expression must either be null or a function");M.prototype=Object.create(z&&z.prototype,{constructor:{value:M,writable:!0,configurable:!0}}),Object.defineProperty(M,"prototype",{writable:!1}),z&&f(M,z)}function f(M,z){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(B,F){return B.__proto__=F,B},f(M,z)}var _=ut,p=Sp,b=jp(),w=ut,m=xe(),g=m.MESSAGE,v=Ar(),E=v.Stream,O=v.PassThrough,C=hn(),R=Ii()("winston:file"),I=ut,$=Fp();return Ga=(function(M){function z(){var B,F=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e(this,z),B=s(this,z,[F]),B.name=F.name||"file";function Y(Z){for(var j=arguments.length,D=new Array(j>1?j-1:0),G=1;G<j;G++)D[G-1]=arguments[G];D.slice(1).forEach(function(U){if(F[U])throw new Error("Cannot set ".concat(U," and ").concat(Z," together"))})}if(B._stream=new O,B._stream.setMaxListeners(30),B._onError=B._onError.bind(B),F.filename||F.dirname)Y("filename or dirname","stream"),B._basename=B.filename=F.filename?p.basename(F.filename):"winston.log",B.dirname=F.dirname||p.dirname(F.filename),B.options=F.options||{flags:"a"};else if(F.stream)console.warn("options.stream will be removed in winston@4. Use winston.transports.Stream"),Y("stream","filename","maxsize"),B._dest=B._stream.pipe(B._setupStream(F.stream)),B.dirname=p.dirname(B._dest.path);else throw new Error("Cannot log to file without filename or stream.");return B.maxsize=F.maxsize||null,B.rotationFormat=F.rotationFormat||!1,B.zippedArchive=F.zippedArchive||!1,B.maxFiles=F.maxFiles||null,B.eol=typeof F.eol=="string"?F.eol:I.EOL,B.tailable=F.tailable||!1,B.lazy=F.lazy||!1,B._size=0,B._pendingSize=0,B._created=0,B._drain=!1,B._opening=!1,B._ending=!1,B._fileExist=!1,B.dirname&&B._createLogDirIfNotExist(B.dirname),B.lazy||B.open(),B}return h(z,M),r(z,[{key:"finishIfEnding",value:function(){var F=this;this._ending&&(this._opening?this.once("open",function(){F._stream.once("finish",function(){return F.emit("finish")}),setImmediate(function(){return F._stream.end()})}):(this._stream.once("finish",function(){return F.emit("finish")}),setImmediate(function(){return F._stream.end()})))}},{key:"log",value:function(F){var Y=this,Z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){};if(this.silent)return Z(),!0;if(this._drain){this._stream.once("drain",function(){Y._drain=!1,Y.log(F,Z)});return}if(this._rotate){this._stream.once("rotate",function(){Y._rotate=!1,Y.log(F,Z)});return}if(this.lazy){if(!this._fileExist){this._opening||this.open(),this.once("open",function(){Y._fileExist=!0,Y.log(F,Z)});return}if(this._needsNewFile(this._pendingSize)){this._dest.once("close",function(){Y._opening||Y.open(),Y.once("open",function(){Y.log(F,Z)})});return}}var j="".concat(F[g]).concat(this.eol),D=Buffer.byteLength(j);function G(){var H=this;if(this._size+=D,this._pendingSize-=D,R("logged %s %s",this._size,j),this.emit("logged",F),!this._rotate&&!this._opening&&this._needsNewFile()){if(this.lazy){this._endStream(function(){H.emit("fileclosed")});return}this._rotate=!0,this._endStream(function(){return H._rotateFile()})}}this._pendingSize+=D,this._opening&&!this.rotatedWhileOpening&&this._needsNewFile(this._size+this._pendingSize)&&(this.rotatedWhileOpening=!0);var U=this._stream.write(j,G.bind(this));return U?Z():(this._drain=!0,this._stream.once("drain",function(){Y._drain=!1,Z()})),R("written",U,this._drain),this.finishIfEnding(),U}},{key:"query",value:function(F,Y){typeof F=="function"&&(Y=F,F={}),F=ae(F);var Z=p.join(this.dirname,this.filename),j="",D=[],G=0,U=_.createReadStream(Z,{encoding:"utf8"});U.on("error",function(Q){if(U.readable&&U.destroy(),!!Y)return Q.code!=="ENOENT"?Y(Q):Y(null,D)}),U.on("data",function(Q){Q=(j+Q).split(/\n+/);for(var ee=Q.length-1,N=0;N<ee;N++)(!F.start||G>=F.start)&&H(Q[N]),G++;j=Q[ee]}),U.on("close",function(){j&&H(j,!0),F.order==="desc"&&(D=D.reverse()),Y&&Y(null,D)});function H(Q,ee){try{var N=JSON.parse(Q);X(N)&&J(N)}catch(k){ee||U.emit("error",k)}}function J(Q){if(F.rows&&D.length>=F.rows&&F.order!=="desc"){U.readable&&U.destroy();return}F.fields&&(Q=F.fields.reduce(function(ee,N){return ee[N]=Q[N],ee},{})),F.order==="desc"&&D.length>=F.rows&&D.shift(),D.push(Q)}function X(Q){if(Q&&n(Q)==="object"){var ee=new Date(Q.timestamp);if(!(F.from&&ee<F.from||F.until&&ee>F.until||F.level&&F.level!==Q.level))return!0}}function ae(Q){return Q=Q||{},Q.rows=Q.rows||Q.limit||10,Q.start=Q.start||0,Q.until=Q.until||new Date,n(Q.until)!=="object"&&(Q.until=new Date(Q.until)),Q.from=Q.from||Q.until-1440*60*1e3,n(Q.from)!=="object"&&(Q.from=new Date(Q.from)),Q.order=Q.order||"desc",Q}}},{key:"stream",value:function(){var F=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},Y=p.join(this.dirname,this.filename),Z=new E,j={file:Y,start:F.start};return Z.destroy=$(j,function(D,G){if(D)return Z.emit("error",D);try{Z.emit("data",G),G=JSON.parse(G),Z.emit("log",G)}catch(U){Z.emit("error",U)}}),Z}},{key:"open",value:function(){var F=this;this.filename&&(this._opening||(this._opening=!0,this.stat(function(Y,Z){if(Y)return F.emit("error",Y);R("stat done: %s { size: %s }",F.filename,Z),F._size=Z,F._dest=F._createStream(F._stream),F._opening=!1,F.once("open",function(){F._stream.emit("rotate")||(F._rotate=!1)})})))}},{key:"stat",value:function(F){var Y=this,Z=this._getFile(),j=p.join(this.dirname,Z);_.stat(j,function(D,G){if(D&&D.code==="ENOENT")return R("ENOENT ok",j),Y.filename=Z,F(null,0);if(D)return R("err ".concat(D.code," ").concat(j)),F(D);if(!G||Y._needsNewFile(G.size))return Y._incFile(function(){return Y.stat(F)});Y.filename=Z,F(null,G.size)})}},{key:"close",value:function(F){var Y=this;this._stream&&this._stream.end(function(){F&&F(),Y.emit("flush"),Y.emit("closed")})}},{key:"_needsNewFile",value:function(F){return F=F||this._size,this.maxsize&&F>=this.maxsize}},{key:"_onError",value:function(F){this.emit("error",F)}},{key:"_setupStream",value:function(F){return F.on("error",this._onError),F}},{key:"_cleanupStream",value:function(F){return F.removeListener("error",this._onError),F.destroy(),F}},{key:"_rotateFile",value:function(){var F=this;this._incFile(function(){return F.open()})}},{key:"_endStream",value:function(){var F=this,Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(){};this._dest?(this._stream.unpipe(this._dest),this._dest.end(function(){F._cleanupStream(F._dest),Y()})):Y()}},{key:"_createStream",value:function(F){var Y=this,Z=p.join(this.dirname,this.filename);R("create stream start",Z,this.options);var j=_.createWriteStream(Z,this.options).on("error",function(D){return R(D)}).on("close",function(){return R("close",j.path,j.bytesWritten)}).on("open",function(){R("file open ok",Z),Y.emit("open",Z),F.pipe(j),Y.rotatedWhileOpening&&(Y._stream=new O,Y._stream.setMaxListeners(30),Y._rotateFile(),Y.rotatedWhileOpening=!1,Y._cleanupStream(j),F.end())});return R("create stream ok",Z),j}},{key:"_incFile",value:function(F){R("_incFile",this.filename);var Y=p.extname(this._basename),Z=p.basename(this._basename,Y),j=[];this.zippedArchive&&j.push((function(D){var G=this._created>0&&!this.tailable?this._created:"";this._compressFile(p.join(this.dirname,"".concat(Z).concat(G).concat(Y)),p.join(this.dirname,"".concat(Z).concat(G).concat(Y,".gz")),D)}).bind(this)),j.push((function(D){this.tailable?this._checkMaxFilesTailable(Y,Z,D):(this._created+=1,this._checkMaxFilesIncrementing(Y,Z,D))}).bind(this)),b(j,F)}},{key:"_getFile",value:function(){var F=p.extname(this._basename),Y=p.basename(this._basename,F),Z=this.rotationFormat?this.rotationFormat():this._created;return!this.tailable&&this._created?"".concat(Y).concat(Z).concat(F):"".concat(Y).concat(F)}},{key:"_checkMaxFilesIncrementing",value:function(F,Y,Z){if(!this.maxFiles||this._created<this.maxFiles)return setImmediate(Z);var j=this._created-this.maxFiles,D=j!==0?j:"",G=this.zippedArchive?".gz":"",U="".concat(Y).concat(D).concat(F).concat(G),H=p.join(this.dirname,U);_.unlink(H,Z)}},{key:"_checkMaxFilesTailable",value:function(F,Y,Z){var j=this,D=[];if(this.maxFiles){for(var G=this.zippedArchive?".gz":"",U=this.maxFiles-1;U>1;U--)D.push((function(H,J){var X=this,ae="".concat(Y).concat(H-1).concat(F).concat(G),Q=p.join(this.dirname,ae);_.exists(Q,function(ee){if(!ee)return J(null);ae="".concat(Y).concat(H).concat(F).concat(G),_.rename(Q,p.join(X.dirname,ae),J)})}).bind(this,U));b(D,function(){_.rename(p.join(j.dirname,"".concat(Y).concat(F).concat(G)),p.join(j.dirname,"".concat(Y,"1").concat(F).concat(G)),Z)})}}},{key:"_compressFile",value:function(F,Y,Z){_.access(F,_.F_OK,function(j){if(j)return Z();var D=w.createGzip(),G=_.createReadStream(F),U=_.createWriteStream(Y);U.on("finish",function(){_.unlink(F,Z)}),G.pipe(D).pipe(U)})}},{key:"_createLogDirIfNotExist",value:function(F){_.existsSync(F)||_.mkdirSync(F,{recursive:!0})}}])})(C),Ga}var Va,Tl;function Up(){if(Tl)return Va;Tl=1;function n(R){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(I){return typeof I}:function(I){return I&&typeof Symbol=="function"&&I.constructor===Symbol&&I!==Symbol.prototype?"symbol":typeof I},n(R)}function e(R,I){var $=Object.keys(R);if(Object.getOwnPropertySymbols){var M=Object.getOwnPropertySymbols(R);I&&(M=M.filter(function(z){return Object.getOwnPropertyDescriptor(R,z).enumerable})),$.push.apply($,M)}return $}function t(R){for(var I=1;I<arguments.length;I++){var $=arguments[I]!=null?arguments[I]:{};I%2?e(Object($),!0).forEach(function(M){r(R,M,$[M])}):Object.getOwnPropertyDescriptors?Object.defineProperties(R,Object.getOwnPropertyDescriptors($)):e(Object($)).forEach(function(M){Object.defineProperty(R,M,Object.getOwnPropertyDescriptor($,M))})}return R}function r(R,I,$){return(I=o(I))in R?Object.defineProperty(R,I,{value:$,enumerable:!0,configurable:!0,writable:!0}):R[I]=$,R}function i(R,I){if(!(R instanceof I))throw new TypeError("Cannot call a class as a function")}function a(R,I){for(var $=0;$<I.length;$++){var M=I[$];M.enumerable=M.enumerable||!1,M.configurable=!0,"value"in M&&(M.writable=!0),Object.defineProperty(R,o(M.key),M)}}function s(R,I,$){return I&&a(R.prototype,I),Object.defineProperty(R,"prototype",{writable:!1}),R}function o(R){var I=u(R,"string");return n(I)=="symbol"?I:I+""}function u(R,I){if(n(R)!="object"||!R)return R;var $=R[Symbol.toPrimitive];if($!==void 0){var M=$.call(R,I);if(n(M)!="object")return M;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(R)}function l(R,I,$){return I=_(I),c(R,f()?Reflect.construct(I,$||[],_(R).constructor):I.apply(R,$))}function c(R,I){if(I&&(n(I)=="object"||typeof I=="function"))return I;if(I!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return h(R)}function h(R){if(R===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return R}function f(){try{var R=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(f=function(){return!!R})()}function _(R){return _=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(I){return I.__proto__||Object.getPrototypeOf(I)},_(R)}function p(R,I){if(typeof I!="function"&&I!==null)throw new TypeError("Super expression must either be null or a function");R.prototype=Object.create(I&&I.prototype,{constructor:{value:R,writable:!0,configurable:!0}}),Object.defineProperty(R,"prototype",{writable:!1}),I&&b(R,I)}function b(R,I){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function($,M){return $.__proto__=M,$},b(R,I)}var w=ut,m=ut,g=Ar(),v=g.Stream,E=hn(),O=fn(),C=O.configure;return Va=(function(R){function I(){var $,M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return i(this,I),$=l(this,I,[M]),$.options=M,$.name=M.name||"http",$.ssl=!!M.ssl,$.host=M.host||"localhost",$.port=M.port,$.auth=M.auth,$.path=M.path||"",$.maximumDepth=M.maximumDepth,$.agent=M.agent,$.headers=M.headers||{},$.headers["content-type"]="application/json",$.batch=M.batch||!1,$.batchInterval=M.batchInterval||5e3,$.batchCount=M.batchCount||10,$.batchOptions=[],$.batchTimeoutID=-1,$.batchCallback={},$.port||($.port=$.ssl?443:80),$}return p(I,R),s(I,[{key:"log",value:function(M,z){var B=this;this._request(M,null,null,function(F,Y){Y&&Y.statusCode!==200&&(F=new Error("Invalid HTTP Status Code: ".concat(Y.statusCode))),F?B.emit("warn",F):B.emit("logged",M)}),z&&setImmediate(z)}},{key:"query",value:function(M,z){typeof M=="function"&&(z=M,M={}),M={method:"query",params:this.normalizeQuery(M)};var B=M.params.auth||null;delete M.params.auth;var F=M.params.path||null;delete M.params.path,this._request(M,B,F,function(Y,Z,j){if(Z&&Z.statusCode!==200&&(Y=new Error("Invalid HTTP Status Code: ".concat(Z.statusCode))),Y)return z(Y);if(typeof j=="string")try{j=JSON.parse(j)}catch(D){return z(D)}z(null,j)})}},{key:"stream",value:function(){var M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},z=new v;M={method:"stream",params:M};var B=M.params.path||null;delete M.params.path;var F=M.params.auth||null;delete M.params.auth;var Y="",Z=this._request(M,F,B);return z.destroy=function(){return Z.destroy()},Z.on("data",function(j){j=(Y+j).split(/\n+/);for(var D=j.length-1,G=0;G<D;G++)try{z.emit("log",JSON.parse(j[G]))}catch(U){z.emit("error",U)}Y=j[D]}),Z.on("error",function(j){return z.emit("error",j)}),z}},{key:"_request",value:function(M,z,B,F){M=M||{},z=z||this.auth,B=B||this.path||"",this.batch?this._doBatch(M,F,z,B):this._doRequest(M,F,z,B)}},{key:"_doBatch",value:function(M,z,B,F){if(this.batchOptions.push(M),this.batchOptions.length===1){var Y=this;this.batchCallback=z,this.batchTimeoutID=setTimeout(function(){Y.batchTimeoutID=-1,Y._doBatchRequest(Y.batchCallback,B,F)},this.batchInterval)}this.batchOptions.length===this.batchCount&&this._doBatchRequest(this.batchCallback,B,F)}},{key:"_doBatchRequest",value:function(M,z,B){this.batchTimeoutID>0&&(clearTimeout(this.batchTimeoutID),this.batchTimeoutID=-1);var F=this.batchOptions.slice();this.batchOptions=[],this._doRequest(F,M,z,B)}},{key:"_doRequest",value:function(M,z,B,F){var Y=Object.assign({},this.headers);B&&B.bearer&&(Y.Authorization="Bearer ".concat(B.bearer));var Z=(this.ssl?m:w).request(t(t({},this.options),{},{method:"POST",host:this.host,port:this.port,path:"/".concat(F.replace(/^\//,"")),headers:Y,auth:B&&B.username&&B.password?"".concat(B.username,":").concat(B.password):"",agent:this.agent}));Z.on("error",z),Z.on("response",function(D){return D.on("end",function(){return z(null,D)}).resume()});var j=C(t({},this.maximumDepth&&{maximumDepth:this.maximumDepth}));Z.end(Buffer.from(j(M,this.options.replacer),"utf8"))}}])})(E),Va}var Wa,Pl;function Hf(){if(Pl)return Wa;Pl=1;const n=e=>e!==null&&typeof e=="object"&&typeof e.pipe=="function";return n.writable=e=>n(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object",n.readable=e=>n(e)&&e.readable!==!1&&typeof e._read=="function"&&typeof e._readableState=="object",n.duplex=e=>n.writable(e)&&n.readable(e),n.transform=e=>n.duplex(e)&&typeof e._transform=="function",Wa=n,Wa}var Ja,xl;function Bp(){if(xl)return Ja;xl=1;function n(g){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(v){return typeof v}:function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v},n(g)}function e(g,v){if(!(g instanceof v))throw new TypeError("Cannot call a class as a function")}function t(g,v){for(var E=0;E<v.length;E++){var O=v[E];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(g,i(O.key),O)}}function r(g,v,E){return v&&t(g.prototype,v),Object.defineProperty(g,"prototype",{writable:!1}),g}function i(g){var v=a(g,"string");return n(v)=="symbol"?v:v+""}function a(g,v){if(n(g)!="object"||!g)return g;var E=g[Symbol.toPrimitive];if(E!==void 0){var O=E.call(g,v);if(n(O)!="object")return O;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}function s(g,v,E){return v=c(v),o(g,l()?Reflect.construct(v,E||[],c(g).constructor):v.apply(g,E))}function o(g,v){if(v&&(n(v)=="object"||typeof v=="function"))return v;if(v!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return u(g)}function u(g){if(g===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g}function l(){try{var g=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(l=function(){return!!g})()}function c(g){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(v){return v.__proto__||Object.getPrototypeOf(v)},c(g)}function h(g,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function");g.prototype=Object.create(v&&v.prototype,{constructor:{value:g,writable:!0,configurable:!0}}),Object.defineProperty(g,"prototype",{writable:!1}),v&&f(g,v)}function f(g,v){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,O){return E.__proto__=O,E},f(g,v)}var _=Hf(),p=xe(),b=p.MESSAGE,w=ut,m=hn();return Ja=(function(g){function v(){var E,O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(e(this,v),E=s(this,v,[O]),!O.stream||!_(O.stream))throw new Error("options.stream is required.");return E._stream=O.stream,E._stream.setMaxListeners(1/0),E.isObjectMode=O.stream._writableState.objectMode,E.eol=typeof O.eol=="string"?O.eol:w.EOL,E}return h(v,g),r(v,[{key:"log",value:function(O,C){var R=this;if(setImmediate(function(){return R.emit("logged",O)}),this.isObjectMode){this._stream.write(O),C&&C();return}this._stream.write("".concat(O[b]).concat(this.eol)),C&&C()}}])})(m),Ja}var Al;function qp(){return Al||(Al=1,(function(n){Object.defineProperty(n,"Console",{configurable:!0,enumerable:!0,get:function(){return wp()}}),Object.defineProperty(n,"File",{configurable:!0,enumerable:!0,get:function(){return Dp()}}),Object.defineProperty(n,"Http",{configurable:!0,enumerable:!0,get:function(){return Up()}}),Object.defineProperty(n,"Stream",{configurable:!0,enumerable:!0,get:function(){return Bp()}})})(va)),va}var Gt={},Rl;function co(){if(Rl)return Gt;Rl=1;var n=Pf(),e=xe(),t=e.configs;return Gt.cli=n.levels(t.cli),Gt.npm=n.levels(t.npm),Gt.syslog=n.levels(t.syslog),Gt.addColors=n.levels,Gt}var Wn={exports:{}},Jn={exports:{}},Il;function zp(){return Il||(Il=1,(function(n,e){Object.defineProperty(e,"__esModule",{value:!0});var t=uo(),r=w(t),i=lo(),a=w(i),s=qf(),o=w(s),u=Uf(),l=w(u),c=Bf(),h=w(c),f=xr(),_=w(f),p=pn(),b=w(p);function w(E){return E&&E.__esModule?E:{default:E}}function m(E,O,C){C=(0,l.default)(C);var R=0,I=0,{length:$}=E,M=!1;$===0&&C(null);function z(B,F){B===!1&&(M=!0),M!==!0&&(B?C(B):(++I===$||F===a.default)&&C(null))}for(;R<$;R++)O(E[R],R,(0,h.default)(z))}function g(E,O,C){return(0,o.default)(E,1/0,O,C)}function v(E,O,C){var R=(0,r.default)(E)?m:g;return R(E,(0,_.default)(O),C)}e.default=(0,b.default)(v,3),n.exports=e.default})(Jn,Jn.exports)),Jn.exports}var Kn={exports:{}},Cl;function Hp(){return Cl||(Cl=1,(function(n,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(r){return(i,a,s)=>r(i,s)}n.exports=e.default})(Kn,Kn.exports)),Kn.exports}var $l;function fo(){return $l||($l=1,(function(n,e){Object.defineProperty(e,"__esModule",{value:!0});var t=zp(),r=c(t),i=Hp(),a=c(i),s=xr(),o=c(s),u=pn(),l=c(u);function c(f){return f&&f.__esModule?f:{default:f}}function h(f,_,p){return(0,r.default)(f,(0,a.default)((0,o.default)(_)),p)}e.default=(0,l.default)(h,3),n.exports=e.default})(Wn,Wn.exports)),Wn.exports}var Ka,jl;function Gp(){if(jl)return Ka;jl=1;var n=Object.prototype.toString;return Ka=function(t){if(typeof t.displayName=="string"&&t.constructor.name)return t.displayName;if(typeof t.name=="string"&&t.name)return t.name;if(typeof t=="object"&&t.constructor&&typeof t.constructor.name=="string")return t.constructor.name;var r=t.toString(),i=n.call(t).slice(8,-1);return i==="Function"?r=r.substring(r.indexOf("(")+1,r.indexOf(")")):r=i,r||"anonymous"},Ka}var Ya,Ml;function Gf(){if(Ml)return Ya;Ml=1;var n=Gp();return Ya=function(t){var r=0,i;function a(){return r||(r=1,i=t.apply(this,arguments),t=null),i}return a.displayName=n(t),a},Ya}var Qa={},kl;function Vf(){return kl||(kl=1,(function(n){n.get=function(i){var a=Error.stackTraceLimit;Error.stackTraceLimit=1/0;var s={},o=Error.prepareStackTrace;Error.prepareStackTrace=function(l,c){return c},Error.captureStackTrace(s,i||n.get);var u=s.stack;return Error.prepareStackTrace=o,Error.stackTraceLimit=a,u},n.parse=function(i){if(!i.stack)return[];var a=this,s=i.stack.split(`
|
|
35
|
+
`).slice(1);return s.map(function(o){if(o.match(/^\s*[-]{4,}$/))return a._createParsedCallSite({fileName:o,lineNumber:null,functionName:null,typeName:null,methodName:null,columnNumber:null,native:null});var u=o.match(/at (?:(.+)\s+\()?(?:(.+?):(\d+)(?::(\d+))?|([^)]+))\)?/);if(u){var l=null,c=null,h=null,f=null,_=null,p=u[5]==="native";if(u[1]){h=u[1];var b=h.lastIndexOf(".");if(h[b-1]=="."&&b--,b>0){l=h.substr(0,b),c=h.substr(b+1);var w=l.indexOf(".Module");w>0&&(h=h.substr(w+1),l=l.substr(0,w))}f=null}c&&(f=l,_=c),c==="<anonymous>"&&(_=null,h=null);var m={fileName:u[2]||null,lineNumber:parseInt(u[3],10)||null,functionName:h,typeName:f,methodName:_,columnNumber:parseInt(u[4],10)||null,native:p};return a._createParsedCallSite(m)}}).filter(function(o){return!!o})};function e(i){for(var a in i)this[a]=i[a]}var t=["this","typeName","functionName","methodName","fileName","lineNumber","columnNumber","function","evalOrigin"],r=["topLevel","eval","native","constructor"];t.forEach(function(i){e.prototype[i]=null,e.prototype["get"+i[0].toUpperCase()+i.substr(1)]=function(){return this[i]}}),r.forEach(function(i){e.prototype[i]=!1,e.prototype["is"+i[0].toUpperCase()+i.substr(1)]=function(){return this[i]}}),n._createParsedCallSite=function(i){return new e(i)}})(Qa)),Qa}var Za,Nl;function Vp(){if(Nl)return Za;Nl=1;function n(b){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(w){return typeof w}:function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},n(b)}function e(b,w){if(!(b instanceof w))throw new TypeError("Cannot call a class as a function")}function t(b,w){for(var m=0;m<w.length;m++){var g=w[m];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(b,i(g.key),g)}}function r(b,w,m){return w&&t(b.prototype,w),Object.defineProperty(b,"prototype",{writable:!1}),b}function i(b){var w=a(b,"string");return n(w)=="symbol"?w:w+""}function a(b,w){if(n(b)!="object"||!b)return b;var m=b[Symbol.toPrimitive];if(m!==void 0){var g=m.call(b,w);if(n(g)!="object")return g;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(b)}function s(b,w,m){return w=c(w),o(b,l()?Reflect.construct(w,m||[],c(b).constructor):w.apply(b,m))}function o(b,w){if(w&&(n(w)=="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return u(b)}function u(b){if(b===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b}function l(){try{var b=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(l=function(){return!!b})()}function c(b){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(w){return w.__proto__||Object.getPrototypeOf(w)},c(b)}function h(b,w){if(typeof w!="function"&&w!==null)throw new TypeError("Super expression must either be null or a function");b.prototype=Object.create(w&&w.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),Object.defineProperty(b,"prototype",{writable:!1}),w&&f(b,w)}function f(b,w){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(m,g){return m.__proto__=g,m},f(b,w)}var _=Ar(),p=_.Writable;return Za=(function(b){function w(m){var g;if(e(this,w),g=s(this,w,[{objectMode:!0}]),!m)throw new Error("ExceptionStream requires a TransportStream instance.");return g.handleExceptions=!0,g.transport=m,g}return h(w,b),r(w,[{key:"_write",value:function(g,v,E){return g.exception?this.transport.log(g,E):(E(),!0)}}])})(p),Za}var Xa,Ll;function Wf(){if(Ll)return Xa;Ll=1;function n(f){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(_){return typeof _}:function(_){return _&&typeof Symbol=="function"&&_.constructor===Symbol&&_!==Symbol.prototype?"symbol":typeof _},n(f)}function e(f,_){if(!(f instanceof _))throw new TypeError("Cannot call a class as a function")}function t(f,_){for(var p=0;p<_.length;p++){var b=_[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(f,i(b.key),b)}}function r(f,_,p){return _&&t(f.prototype,_),Object.defineProperty(f,"prototype",{writable:!1}),f}function i(f){var _=a(f,"string");return n(_)=="symbol"?_:_+""}function a(f,_){if(n(f)!="object"||!f)return f;var p=f[Symbol.toPrimitive];if(p!==void 0){var b=p.call(f,_);if(n(b)!="object")return b;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(f)}var s=ut,o=fo(),u=Ii()("winston:exception"),l=Gf(),c=Vf(),h=Vp();return Xa=(function(){function f(_){if(e(this,f),!_)throw new Error("Logger is required to handle exceptions");this.logger=_,this.handlers=new Map}return r(f,[{key:"handle",value:function(){for(var p=this,b=arguments.length,w=new Array(b),m=0;m<b;m++)w[m]=arguments[m];w.forEach(function(g){if(Array.isArray(g))return g.forEach(function(v){return p._addHandler(v)});p._addHandler(g)}),this.catcher||(this.catcher=this._uncaughtException.bind(this),process.on("uncaughtException",this.catcher))}},{key:"unhandle",value:function(){var p=this;this.catcher&&(process.removeListener("uncaughtException",this.catcher),this.catcher=!1,Array.from(this.handlers.values()).forEach(function(b){return p.logger.unpipe(b)}))}},{key:"getAllInfo",value:function(p){var b=null;return p&&(b=typeof p=="string"?p:p.message),{error:p,level:"error",message:["uncaughtException: ".concat(b||"(no error message)"),p&&p.stack||" No stack trace"].join(`
|
|
36
|
+
`),stack:p&&p.stack,exception:!0,date:new Date().toString(),process:this.getProcessInfo(),os:this.getOsInfo(),trace:this.getTrace(p)}}},{key:"getProcessInfo",value:function(){return{pid:process.pid,uid:process.getuid?process.getuid():null,gid:process.getgid?process.getgid():null,cwd:process.cwd(),execPath:process.execPath,version:process.version,argv:process.argv,memoryUsage:process.memoryUsage()}}},{key:"getOsInfo",value:function(){return{loadavg:s.loadavg(),uptime:s.uptime()}}},{key:"getTrace",value:function(p){var b=p?c.parse(p):c.get();return b.map(function(w){return{column:w.getColumnNumber(),file:w.getFileName(),function:w.getFunctionName(),line:w.getLineNumber(),method:w.getMethodName(),native:w.isNative()}})}},{key:"_addHandler",value:function(p){if(!this.handlers.has(p)){p.handleExceptions=!0;var b=new h(p);this.handlers.set(p,b),this.logger.pipe(b)}}},{key:"_uncaughtException",value:function(p){var b=this.getAllInfo(p),w=this._getExceptionHandlers(),m=typeof this.logger.exitOnError=="function"?this.logger.exitOnError(p):this.logger.exitOnError,g;!w.length&&m&&(console.warn("winston: exitOnError cannot be true with no exception handlers."),console.warn("winston: not exiting process."),m=!1);function v(){u("doExit",m),u("process._exiting",process._exiting),m&&!process._exiting&&(g&&clearTimeout(g),process.exit(1))}if(!w||w.length===0)return process.nextTick(v);o(w,function(E,O){var C=l(O),R=E.transport||E;function I($){return function(){u($),C()}}R._ending=!0,R.once("finish",I("finished")),R.once("error",I("error"))},function(){return m&&v()}),this.logger.log(b),m&&(g=setTimeout(v,3e3))}},{key:"_getExceptionHandlers",value:function(){return this.logger.transports.filter(function(p){var b=p.transport||p;return b.handleExceptions})}}])})(),Xa}var es,Fl;function Wp(){if(Fl)return es;Fl=1;function n(b){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(w){return typeof w}:function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},n(b)}function e(b,w){if(!(b instanceof w))throw new TypeError("Cannot call a class as a function")}function t(b,w){for(var m=0;m<w.length;m++){var g=w[m];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(b,i(g.key),g)}}function r(b,w,m){return w&&t(b.prototype,w),Object.defineProperty(b,"prototype",{writable:!1}),b}function i(b){var w=a(b,"string");return n(w)=="symbol"?w:w+""}function a(b,w){if(n(b)!="object"||!b)return b;var m=b[Symbol.toPrimitive];if(m!==void 0){var g=m.call(b,w);if(n(g)!="object")return g;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(b)}function s(b,w,m){return w=c(w),o(b,l()?Reflect.construct(w,m||[],c(b).constructor):w.apply(b,m))}function o(b,w){if(w&&(n(w)=="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return u(b)}function u(b){if(b===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b}function l(){try{var b=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(l=function(){return!!b})()}function c(b){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(w){return w.__proto__||Object.getPrototypeOf(w)},c(b)}function h(b,w){if(typeof w!="function"&&w!==null)throw new TypeError("Super expression must either be null or a function");b.prototype=Object.create(w&&w.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),Object.defineProperty(b,"prototype",{writable:!1}),w&&f(b,w)}function f(b,w){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(m,g){return m.__proto__=g,m},f(b,w)}var _=Ar(),p=_.Writable;return es=(function(b){function w(m){var g;if(e(this,w),g=s(this,w,[{objectMode:!0}]),!m)throw new Error("RejectionStream requires a TransportStream instance.");return g.handleRejections=!0,g.transport=m,g}return h(w,b),r(w,[{key:"_write",value:function(g,v,E){return g.rejection?this.transport.log(g,E):(E(),!0)}}])})(p),es}var ts,Dl;function Jf(){if(Dl)return ts;Dl=1;function n(f){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(_){return typeof _}:function(_){return _&&typeof Symbol=="function"&&_.constructor===Symbol&&_!==Symbol.prototype?"symbol":typeof _},n(f)}function e(f,_){if(!(f instanceof _))throw new TypeError("Cannot call a class as a function")}function t(f,_){for(var p=0;p<_.length;p++){var b=_[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(f,i(b.key),b)}}function r(f,_,p){return _&&t(f.prototype,_),Object.defineProperty(f,"prototype",{writable:!1}),f}function i(f){var _=a(f,"string");return n(_)=="symbol"?_:_+""}function a(f,_){if(n(f)!="object"||!f)return f;var p=f[Symbol.toPrimitive];if(p!==void 0){var b=p.call(f,_);if(n(b)!="object")return b;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(f)}var s=ut,o=fo(),u=Ii()("winston:rejection"),l=Gf(),c=Vf(),h=Wp();return ts=(function(){function f(_){if(e(this,f),!_)throw new Error("Logger is required to handle rejections");this.logger=_,this.handlers=new Map}return r(f,[{key:"handle",value:function(){for(var p=this,b=arguments.length,w=new Array(b),m=0;m<b;m++)w[m]=arguments[m];w.forEach(function(g){if(Array.isArray(g))return g.forEach(function(v){return p._addHandler(v)});p._addHandler(g)}),this.catcher||(this.catcher=this._unhandledRejection.bind(this),process.on("unhandledRejection",this.catcher))}},{key:"unhandle",value:function(){var p=this;this.catcher&&(process.removeListener("unhandledRejection",this.catcher),this.catcher=!1,Array.from(this.handlers.values()).forEach(function(b){return p.logger.unpipe(b)}))}},{key:"getAllInfo",value:function(p){var b=null;return p&&(b=typeof p=="string"?p:p.message),{error:p,level:"error",message:["unhandledRejection: ".concat(b||"(no error message)"),p&&p.stack||" No stack trace"].join(`
|
|
37
|
+
`),stack:p&&p.stack,rejection:!0,date:new Date().toString(),process:this.getProcessInfo(),os:this.getOsInfo(),trace:this.getTrace(p)}}},{key:"getProcessInfo",value:function(){return{pid:process.pid,uid:process.getuid?process.getuid():null,gid:process.getgid?process.getgid():null,cwd:process.cwd(),execPath:process.execPath,version:process.version,argv:process.argv,memoryUsage:process.memoryUsage()}}},{key:"getOsInfo",value:function(){return{loadavg:s.loadavg(),uptime:s.uptime()}}},{key:"getTrace",value:function(p){var b=p?c.parse(p):c.get();return b.map(function(w){return{column:w.getColumnNumber(),file:w.getFileName(),function:w.getFunctionName(),line:w.getLineNumber(),method:w.getMethodName(),native:w.isNative()}})}},{key:"_addHandler",value:function(p){if(!this.handlers.has(p)){p.handleRejections=!0;var b=new h(p);this.handlers.set(p,b),this.logger.pipe(b)}}},{key:"_unhandledRejection",value:function(p){var b=this.getAllInfo(p),w=this._getRejectionHandlers(),m=typeof this.logger.exitOnError=="function"?this.logger.exitOnError(p):this.logger.exitOnError,g;!w.length&&m&&(console.warn("winston: exitOnError cannot be true with no rejection handlers."),console.warn("winston: not exiting process."),m=!1);function v(){u("doExit",m),u("process._exiting",process._exiting),m&&!process._exiting&&(g&&clearTimeout(g),process.exit(1))}if(!w||w.length===0)return process.nextTick(v);o(w,function(E,O){var C=l(O),R=E.transport||E;function I($){return function(){u($),C()}}R._ending=!0,R.once("finish",I("finished")),R.once("error",I("error"))},function(){return m&&v()}),this.logger.log(b),m&&(g=setTimeout(v,3e3))}},{key:"_getRejectionHandlers",value:function(){return this.logger.transports.filter(function(p){var b=p.transport||p;return b.handleRejections})}}])})(),ts}var rs={exports:{}},ns={exports:{}},Ul;function Jp(){if(Ul)return ns.exports;Ul=1;const n=ft,e=Ri(),{LEVEL:t}=xe(),r=ns.exports=function(a={}){e.call(this,{objectMode:!0,highWaterMark:a.highWaterMark}),this.format=a.format,this.level=a.level,this.handleExceptions=a.handleExceptions,this.handleRejections=a.handleRejections,this.silent=a.silent,a.log&&(this.log=a.log),a.logv&&(this.logv=a.logv),a.close&&(this.close=a.close),this.once("pipe",s=>{this.levels=s.levels,this.parent=s}),this.once("unpipe",s=>{s===this.parent&&(this.parent=null,this.close&&this.close())})};return n.inherits(r,e),r.prototype._write=function(a,s,o){if(this.silent||a.exception===!0&&!this.handleExceptions)return o(null);const u=this.level||this.parent&&this.parent.level;if(!u||this.levels[u]>=this.levels[a[t]]){if(a&&!this.format)return this.log(a,o);let l,c;try{c=this.format.transform(Object.assign({},a),this.format.options)}catch(h){l=h}if(l||!c){if(o(),l)throw l;return}return this.log(c,o)}return this._writableState.sync=!1,o(null)},r.prototype._writev=function(a,s){if(this.logv){const o=a.filter(this._accept,this);return o.length?this.logv(o,s):s(null)}for(let o=0;o<a.length;o++){if(!this._accept(a[o]))continue;if(a[o].chunk&&!this.format){this.log(a[o].chunk,a[o].callback);continue}let u,l;try{l=this.format.transform(Object.assign({},a[o].chunk),this.format.options)}catch(c){u=c}if(u||!l){if(a[o].callback(),u)throw s(null),u}else this.log(l,a[o].callback)}return s(null)},r.prototype._accept=function(a){const s=a.chunk;if(this.silent)return!1;const o=this.level||this.parent&&this.parent.level;return!!((s.exception===!0||!o||this.levels[o]>=this.levels[s[t]])&&(this.handleExceptions||s.exception!==!0))},r.prototype._nop=function(){},ns.exports}var Bl;function Kp(){if(Bl)return rs.exports;Bl=1;const n=ft,{LEVEL:e}=xe(),t=Jp(),r=rs.exports=function(a={}){if(t.call(this,a),!a.transport||typeof a.transport.log!="function")throw new Error("Invalid transport, must be an object with a log method.");this.transport=a.transport,this.level=this.level||a.transport.level,this.handleExceptions=this.handleExceptions||a.transport.handleExceptions,this._deprecated();function s(o){this.emit("error",o,this.transport)}this.transport.__winstonError||(this.transport.__winstonError=s.bind(this),this.transport.on("error",this.transport.__winstonError))};return n.inherits(r,t),r.prototype._write=function(a,s,o){if(this.silent||a.exception===!0&&!this.handleExceptions)return o(null);(!this.level||this.levels[this.level]>=this.levels[a[e]])&&this.transport.log(a[e],a.message,a,this._nop),o(null)},r.prototype._writev=function(a,s){for(let o=0;o<a.length;o++)this._accept(a[o])&&(this.transport.log(a[o].chunk[e],a[o].chunk.message,a[o].chunk,this._nop),a[o].callback());return s(null)},r.prototype._deprecated=function(){console.error([`${this.transport.name} is a legacy winston transport. Consider upgrading: `,"- Upgrade docs: https://github.com/winstonjs/winston/blob/master/UPGRADE-3.0.md"].join(`
|
|
38
|
+
`))},r.prototype.close=function(){this.transport.close&&this.transport.close(),this.transport.__winstonError&&(this.transport.removeListener("error",this.transport.__winstonError),this.transport.__winstonError=null)},rs.exports}var is,ql;function Yp(){if(ql)return is;ql=1;function n(o){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(u){return typeof u}:function(u){return u&&typeof Symbol=="function"&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},n(o)}function e(o,u){if(!(o instanceof u))throw new TypeError("Cannot call a class as a function")}function t(o,u){for(var l=0;l<u.length;l++){var c=u[l];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(o,i(c.key),c)}}function r(o,u,l){return u&&t(o.prototype,u),Object.defineProperty(o,"prototype",{writable:!1}),o}function i(o){var u=a(o,"string");return n(u)=="symbol"?u:u+""}function a(o,u){if(n(o)!="object"||!o)return o;var l=o[Symbol.toPrimitive];if(l!==void 0){var c=l.call(o,u);if(n(c)!="object")return c;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(o)}var s=(function(){function o(u){e(this,o);var l=ho();if(n(u)!=="object"||Array.isArray(u)||!(u instanceof l))throw new Error("Logger is required for profiling");this.logger=u,this.start=Date.now()}return r(o,[{key:"done",value:function(){for(var l=arguments.length,c=new Array(l),h=0;h<l;h++)c[h]=arguments[h];typeof c[c.length-1]=="function"&&(console.warn("Callback function no longer supported as of winston@3.0.0"),c.pop());var f=n(c[c.length-1])==="object"?c.pop():{};return f.level=f.level||"info",f.durationMs=Date.now()-this.start,this.logger.write(f)}}])})();return is=s,is}var as,zl;function Qp(){if(zl)return as;zl=1;class n extends Error{constructor(t){super(`Format functions must be synchronous taking a two arguments: (info, opts)
|
|
39
|
+
Found: ${t.toString().split(`
|
|
40
|
+
`)[0]}
|
|
41
|
+
`),Error.captureStackTrace(this,n)}}return as=e=>{if(e.length>2)throw new n(e);function t(i={}){this.options=i}t.prototype.transform=e;function r(i){return new t(i)}return r.Format=t,r},as}var ss,Hl;function Zp(){if(Hl)return ss;Hl=1;const n=Qp(),{MESSAGE:e}=xe(),t=fn();function r(i,a){return typeof a=="bigint"?a.toString():a}return ss=n((i,a)=>{const s=t.configure(a);return i[e]=s(i,a.replacer||r,a.space),i}),ss}var os,Gl;function ho(){if(Gl)return os;Gl=1;function n(j,D,G){return(D=a(D))in j?Object.defineProperty(j,D,{value:G,enumerable:!0,configurable:!0,writable:!0}):j[D]=G,j}function e(j){"@babel/helpers - typeof";return e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(D){return typeof D}:function(D){return D&&typeof Symbol=="function"&&D.constructor===Symbol&&D!==Symbol.prototype?"symbol":typeof D},e(j)}function t(j,D){if(!(j instanceof D))throw new TypeError("Cannot call a class as a function")}function r(j,D){for(var G=0;G<D.length;G++){var U=D[G];U.enumerable=U.enumerable||!1,U.configurable=!0,"value"in U&&(U.writable=!0),Object.defineProperty(j,a(U.key),U)}}function i(j,D,G){return D&&r(j.prototype,D),Object.defineProperty(j,"prototype",{writable:!1}),j}function a(j){var D=s(j,"string");return e(D)=="symbol"?D:D+""}function s(j,D){if(e(j)!="object"||!j)return j;var G=j[Symbol.toPrimitive];if(G!==void 0){var U=G.call(j,D);if(e(U)!="object")return U;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(j)}function o(j,D,G){return D=h(D),u(j,c()?Reflect.construct(D,G||[],h(j).constructor):D.apply(j,G))}function u(j,D){if(D&&(e(D)=="object"||typeof D=="function"))return D;if(D!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return l(j)}function l(j){if(j===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j}function c(){try{var j=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(c=function(){return!!j})()}function h(j){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(D){return D.__proto__||Object.getPrototypeOf(D)},h(j)}function f(j,D){if(typeof D!="function"&&D!==null)throw new TypeError("Super expression must either be null or a function");j.prototype=Object.create(D&&D.prototype,{constructor:{value:j,writable:!0,configurable:!0}}),Object.defineProperty(j,"prototype",{writable:!1}),D&&_(j,D)}function _(j,D){return _=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(G,U){return G.__proto__=U,G},_(j,D)}var p=Ar(),b=p.Stream,w=p.Transform,m=fo(),g=xe(),v=g.LEVEL,E=g.SPLAT,O=Hf(),C=Wf(),R=Jf(),I=Kp(),$=Yp(),M=xf(),z=M.warn,B=co(),F=/%[scdjifoO%]/g,Y=(function(j){function D(G){var U;return t(this,D),U=o(this,D,[{objectMode:!0}]),U.configure(G),U}return f(D,j),i(D,[{key:"child",value:function(U){var H=this;return Object.create(H,{write:{value:function(X){var ae=Object.assign({},U,X);X instanceof Error&&(ae.stack=X.stack,ae.message=X.message),H.write(ae)}}})}},{key:"configure",value:function(){var U=this,H=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},J=H.silent,X=H.format,ae=H.defaultMeta,Q=H.levels,ee=H.level,N=ee===void 0?"info":ee,k=H.exitOnError,V=k===void 0?!0:k,se=H.transports,oe=H.colors,T=H.emitErrs,x=H.formatters,W=H.padLevels,re=H.rewriters,_e=H.stripColors,he=H.exceptionHandlers,ye=H.rejectionHandlers;if(this.transports.length&&this.clear(),this.silent=J,this.format=X||this.format||Zp()(),this.defaultMeta=ae||null,this.levels=Q||this.levels||B.npm.levels,this.level=N,this.exceptions&&this.exceptions.unhandle(),this.rejections&&this.rejections.unhandle(),this.exceptions=new C(this),this.rejections=new R(this),this.profilers={},this.exitOnError=V,se&&(se=Array.isArray(se)?se:[se],se.forEach(function(ke){return U.add(ke)})),oe||T||x||W||re||_e)throw new Error(["{ colors, emitErrs, formatters, padLevels, rewriters, stripColors } were removed in winston@3.0.0.","Use a custom winston.format(function) instead.","See: https://github.com/winstonjs/winston/tree/master/UPGRADE-3.0.md"].join(`
|
|
42
|
+
`));he&&this.exceptions.handle(he),ye&&this.rejections.handle(ye)}},{key:"getHighestLogLevel",value:function(){var U=this,H=Z(this.levels,this.level);return!this.transports||this.transports.length===0?H:this.transports.reduce(function(J,X){var ae=Z(U.levels,X.level);return ae!==null&&ae>J?ae:J},H)}},{key:"isLevelEnabled",value:function(U){var H=this,J=Z(this.levels,U);if(J===null)return!1;var X=Z(this.levels,this.level);if(X===null)return!1;if(!this.transports||this.transports.length===0)return X>=J;var ae=this.transports.findIndex(function(Q){var ee=Z(H.levels,Q.level);return ee===null&&(ee=X),ee>=J});return ae!==-1}},{key:"log",value:function(U,H){for(var J=arguments.length,X=new Array(J>2?J-2:0),ae=2;ae<J;ae++)X[ae-2]=arguments[ae];if(arguments.length===1)return U[v]=U.level,this._addDefaultMeta(U),this.write(U),this;if(arguments.length===2)return H&&e(H)==="object"?(H[v]=H.level=U,this._addDefaultMeta(H),this.write(H),this):(H=n(n(n({},v,U),"level",U),"message",H),this._addDefaultMeta(H),this.write(H),this);var Q=X[0];if(e(Q)==="object"&&Q!==null){var ee=H&&H.match&&H.match(F);if(!ee){var N=Object.assign({},this.defaultMeta,Q,n(n(n(n({},v,U),E,X),"level",U),"message",H));return Q.message&&(N.message="".concat(N.message," ").concat(Q.message)),Q.stack&&(N.stack=Q.stack),Q.cause&&(N.cause=Q.cause),this.write(N),this}}return this.write(Object.assign({},this.defaultMeta,n(n(n(n({},v,U),E,X),"level",U),"message",H))),this}},{key:"_transform",value:function(U,H,J){if(this.silent)return J();U[v]||(U[v]=U.level),!this.levels[U[v]]&&this.levels[U[v]]!==0&&console.error("[winston] Unknown logger level: %s",U[v]),this._readableState.pipes||console.error("[winston] Attempt to write logs with no transports, which can increase memory usage: %j",U);try{this.push(this.format.transform(U,this.format.options))}finally{this._writableState.sync=!1,J()}}},{key:"_final",value:function(U){var H=this.transports.slice();m(H,function(J,X){if(!J||J.finished)return setImmediate(X);J.once("finish",X),J.end()},U)}},{key:"add",value:function(U){var H=!O(U)||U.log.length>2?new I({transport:U}):U;if(!H._writableState||!H._writableState.objectMode)throw new Error("Transports must WritableStreams in objectMode. Set { objectMode: true }.");return this._onEvent("error",H),this._onEvent("warn",H),this.pipe(H),U.handleExceptions&&this.exceptions.handle(),U.handleRejections&&this.rejections.handle(),this}},{key:"remove",value:function(U){if(!U)return this;var H=U;return(!O(U)||U.log.length>2)&&(H=this.transports.filter(function(J){return J.transport===U})[0]),H&&this.unpipe(H),this}},{key:"clear",value:function(){return this.unpipe(),this}},{key:"close",value:function(){return this.exceptions.unhandle(),this.rejections.unhandle(),this.clear(),this.emit("close"),this}},{key:"setLevels",value:function(){z.deprecated("setLevels")}},{key:"query",value:function(U,H){typeof U=="function"&&(H=U,U={}),U=U||{};var J={},X=Object.assign({},U.query||{});function ae(ee,N){U.query&&typeof ee.formatQuery=="function"&&(U.query=ee.formatQuery(X)),ee.query(U,function(k,V){if(k)return N(k);typeof ee.formatResults=="function"&&(V=ee.formatResults(V,U.format)),N(null,V)})}function Q(ee,N){ae(ee,function(k,V){N&&(V=k||V,V&&(J[ee.name]=V),N()),N=null})}m(this.transports.filter(function(ee){return!!ee.query}),Q,function(){return H(null,J)})}},{key:"stream",value:function(){var U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},H=new b,J=[];return H._streams=J,H.destroy=function(){for(var X=J.length;X--;)J[X].destroy()},this.transports.filter(function(X){return!!X.stream}).forEach(function(X){var ae=X.stream(U);ae&&(J.push(ae),ae.on("log",function(Q){Q.transport=Q.transport||[],Q.transport.push(X.name),H.emit("log",Q)}),ae.on("error",function(Q){Q.transport=Q.transport||[],Q.transport.push(X.name),H.emit("error",Q)}))}),H}},{key:"startTimer",value:function(){return new $(this)}},{key:"profile",value:function(U){var H=Date.now();if(this.profilers[U]){var J=this.profilers[U];delete this.profilers[U];for(var X=arguments.length,ae=new Array(X>1?X-1:0),Q=1;Q<X;Q++)ae[Q-1]=arguments[Q];typeof ae[ae.length-2]=="function"&&(console.warn("Callback function no longer supported as of winston@3.0.0"),ae.pop());var ee=e(ae[ae.length-1])==="object"?ae.pop():{};return ee.level=ee.level||"info",ee.durationMs=H-J,ee.message=ee.message||U,this.write(ee)}return this.profilers[U]=H,this}},{key:"handleExceptions",value:function(){var U;console.warn("Deprecated: .handleExceptions() will be removed in winston@4. Use .exceptions.handle()"),(U=this.exceptions).handle.apply(U,arguments)}},{key:"unhandleExceptions",value:function(){var U;console.warn("Deprecated: .unhandleExceptions() will be removed in winston@4. Use .exceptions.unhandle()"),(U=this.exceptions).unhandle.apply(U,arguments)}},{key:"cli",value:function(){throw new Error(["Logger.cli() was removed in winston@3.0.0","Use a custom winston.formats.cli() instead.","See: https://github.com/winstonjs/winston/tree/master/UPGRADE-3.0.md"].join(`
|
|
43
|
+
`))}},{key:"_onEvent",value:function(U,H){function J(X){U==="error"&&!this.transports.includes(H)&&this.add(H),this.emit(U,X,H)}H["__winston"+U]||(H["__winston"+U]=J.bind(this),H.on(U,H["__winston"+U]))}},{key:"_addDefaultMeta",value:function(U){this.defaultMeta&&Object.assign(U,this.defaultMeta)}}])})(w);function Z(j,D){var G=j[D];return!G&&G!==0?null:G}return Object.defineProperty(Y.prototype,"transports",{configurable:!1,enumerable:!0,get:function(){var D=this._readableState.pipes;return Array.isArray(D)?D:[D].filter(Boolean)}}),os=Y,os}var us,Vl;function Kf(){if(Vl)return us;Vl=1;function n(w){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},n(w)}function e(w,m,g){return Object.defineProperty(w,"prototype",{writable:!1}),w}function t(w,m){if(!(w instanceof m))throw new TypeError("Cannot call a class as a function")}function r(w,m,g){return m=o(m),i(w,s()?Reflect.construct(m,g||[],o(w).constructor):m.apply(w,g))}function i(w,m){if(m&&(n(m)=="object"||typeof m=="function"))return m;if(m!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return a(w)}function a(w){if(w===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return w}function s(){try{var w=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(s=function(){return!!w})()}function o(w){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(m){return m.__proto__||Object.getPrototypeOf(m)},o(w)}function u(w,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function");w.prototype=Object.create(m&&m.prototype,{constructor:{value:w,writable:!0,configurable:!0}}),Object.defineProperty(w,"prototype",{writable:!1}),m&&l(w,m)}function l(w,m){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,v){return g.__proto__=v,g},l(w,m)}var c=xe(),h=c.LEVEL,f=co(),_=ho(),p=Ii()("winston:create-logger");function b(w){return"is"+w.charAt(0).toUpperCase()+w.slice(1)+"Enabled"}return us=function(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};w.levels=w.levels||f.npm.levels;var m=(function(v){function E(O){return t(this,E),r(this,E,[O])}return u(E,v),e(E)})(_),g=new m(w);return Object.keys(w.levels).forEach(function(v){if(p('Define prototype method for "%s"',v),v==="log"){console.warn('Level "log" not defined: conflicts with the method "log". Use a different level name.');return}m.prototype[v]=function(){for(var E=this||g,O=arguments.length,C=new Array(O),R=0;R<O;R++)C[R]=arguments[R];if(C.length===1){var I=C[0],$=I&&I.message&&I||{message:I};return $.level=$[h]=v,E._addDefaultMeta($),E.write($),this||g}return C.length===0?(E.log(v,""),E):E.log.apply(E,[v].concat(C))},m.prototype[b(v)]=function(){return(this||g).isLevelEnabled(v)}}),g},us}var ls,Wl;function Xp(){if(Wl)return ls;Wl=1;function n(o){"@babel/helpers - typeof";return n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(u){return typeof u}:function(u){return u&&typeof Symbol=="function"&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},n(o)}function e(o,u){if(!(o instanceof u))throw new TypeError("Cannot call a class as a function")}function t(o,u){for(var l=0;l<u.length;l++){var c=u[l];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(o,i(c.key),c)}}function r(o,u,l){return u&&t(o.prototype,u),Object.defineProperty(o,"prototype",{writable:!1}),o}function i(o){var u=a(o,"string");return n(u)=="symbol"?u:u+""}function a(o,u){if(n(o)!="object"||!o)return o;var l=o[Symbol.toPrimitive];if(l!==void 0){var c=l.call(o,u);if(n(c)!="object")return c;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(o)}var s=Kf();return ls=(function(){function o(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e(this,o),this.loggers=new Map,this.options=u}return r(o,[{key:"add",value:function(l,c){var h=this;if(!this.loggers.has(l)){c=Object.assign({},c||this.options);var f=c.transports||this.options.transports;f?c.transports=Array.isArray(f)?f.slice():[f]:c.transports=[];var _=s(c);_.on("close",function(){return h._delete(l)}),this.loggers.set(l,_)}return this.loggers.get(l)}},{key:"get",value:function(l,c){return this.add(l,c)}},{key:"has",value:function(l){return!!this.loggers.has(l)}},{key:"close",value:function(l){var c=this;if(l)return this._removeLogger(l);this.loggers.forEach(function(h,f){return c._removeLogger(f)})}},{key:"_removeLogger",value:function(l){if(this.loggers.has(l)){var c=this.loggers.get(l);c.close(),this._delete(l)}}},{key:"_delete",value:function(l){this.loggers.delete(l)}}])})(),ls}var Jl;function em(){return Jl||(Jl=1,(function(n){var e=Pf(),t=xf(),r=t.warn;n.version=hp.version,n.transports=qp(),n.config=co(),n.addColors=e.levels,n.format=e.format,n.createLogger=Kf(),n.Logger=ho(),n.ExceptionHandler=Wf(),n.RejectionHandler=Jf(),n.Container=Xp(),n.Transport=hn(),n.loggers=new n.Container;var i=n.createLogger();Object.keys(n.config.npm.levels).concat(["log","query","stream","add","remove","clear","profile","startTimer","handleExceptions","unhandleExceptions","handleRejections","unhandleRejections","configure","child"]).forEach(function(a){return n[a]=function(){return i[a].apply(i,arguments)}}),Object.defineProperty(n,"level",{get:function(){return i.level},set:function(s){i.level=s}}),Object.defineProperty(n,"exceptions",{get:function(){return i.exceptions}}),Object.defineProperty(n,"rejections",{get:function(){return i.rejections}}),["exitOnError"].forEach(function(a){Object.defineProperty(n,a,{get:function(){return i[a]},set:function(o){i[a]=o}})}),Object.defineProperty(n,"default",{get:function(){return{exceptionHandlers:i.exceptionHandlers,rejectionHandlers:i.rejectionHandlers,transports:i.transports}}}),r.deprecated(n,"setLevels"),r.forFunctions(n,"useFormat",["cli"]),r.forProperties(n,"useFormat",["padLevels","stripColors"]),r.forFunctions(n,"deprecated",["addRewriter","addFilter","clone","extend"]),r.forProperties(n,"deprecated",["emitErrs","levelLength"])})(Hi)),Hi}var zr=em(),Pe={};async function Yf(){if(typeof process<"u")try{const n=await Me(()=>Promise.resolve().then(()=>Xr),void 0),e=await Me(()=>Promise.resolve().then(()=>Df),void 0);return{fs:n.default,path:e.default}}catch{return{fs:null,path:null}}return{fs:null,path:null}}le(Yf,"getNodeModules");var{combine:Kl,timestamp:Yl,label:Ql,printf:po,colorize:Zl,splat:Xl}=zr.format,Is="mcp-use";function ci(){try{if(typeof navigator<"u"&&navigator.userAgent?.includes("Cloudflare-Workers")||typeof globalThis.EdgeRuntime<"u"||typeof globalThis.Deno<"u")return!1;const n=typeof process<"u"&&!0&&typeof __dirname<"u",e=typeof zr.createLogger=="function";return n&&e}catch{return!1}}le(ci,"isNodeJSEnvironment");var Kt,tm=(Kt=class{_level;name;constructor(e=Is,t="info"){this.name=e,this._level=t}shouldLog(e){const t=["error","warn","info","http","verbose","debug","silly"],r=t.indexOf(this._level);return t.indexOf(e)<=r}formatMessage(e,t){return`${new Date().toLocaleTimeString("en-US",{hour12:!1})} [${this.name}] ${e}: ${t}`}error(e){this.shouldLog("error")&&console.error(this.formatMessage("error",e))}warn(e){this.shouldLog("warn")&&console.warn(this.formatMessage("warn",e))}info(e){this.shouldLog("info")&&console.info(this.formatMessage("info",e))}debug(e){this.shouldLog("debug")&&console.debug(this.formatMessage("debug",e))}http(e){this.shouldLog("http")&&console.log(this.formatMessage("http",e))}verbose(e){this.shouldLog("verbose")&&console.log(this.formatMessage("verbose",e))}silly(e){this.shouldLog("silly")&&console.log(this.formatMessage("silly",e))}get level(){return this._level}set level(e){this._level=e}},le(Kt,"SimpleConsoleLogger"),Kt);function ri(n){switch((typeof process<"u"&&Pe?n:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}le(ri,"resolveLevel");var ec=po(({level:n,message:e,label:t,timestamp:r})=>`${r} [${t}] ${n}: ${e}`),rm=po(({level:n,message:e,label:t,timestamp:r})=>`${r} [${t}] ${n.toUpperCase()}: ${e}`),nm=po(({level:n,message:e,label:t,timestamp:r})=>`${r} [${t}] ${n.toUpperCase()}: ${e}`),ht,fi=(ht=class{static get(e=Is){if(!ci()){if(!this.simpleInstances[e]){const t=typeof process<"u"&&Pe?.DEBUG||void 0;this.simpleInstances[e]=new tm(e,ri(t))}return this.simpleInstances[e]}return this.instances[e]||(this.instances[e]=zr.createLogger({level:ri(Pe.DEBUG),format:Kl(Zl(),Xl(),Ql({label:e}),Yl({format:"HH:mm:ss"}),this.getFormatter()),transports:[]})),this.instances[e]}static getFormatter(){switch(this.currentFormat){case"minimal":return ec;case"detailed":return rm;case"emoji":return nm;default:return ec}}static async configure(e={}){const{level:t,console:r=!0,file:i,format:a="minimal"}=e,s=typeof process<"u"&&Pe?.DEBUG||void 0,o=t??ri(s);this.currentFormat=a;const u=this.get();u.level=o;const l=u;if(!ci()){Object.values(this.simpleInstances).forEach(c=>{c.level=o});return}if(l.clear(),r&&l.add(new zr.transports.Console),i){const{fs:c,path:h}=await Yf();if(c&&h){const f=h.dirname(h.resolve(i));c.existsSync(f)||c.mkdirSync(f,{recursive:!0}),l.add(new zr.transports.File({filename:i}))}}Object.values(this.instances).forEach(c=>{c&&"format"in c&&(c.level=o,c.format=Kl(Zl(),Xl(),Ql({label:Is}),Yl({format:"HH:mm:ss"}),this.getFormatter()))})}static setDebug(e){let t;e===2||e===!0?t="debug":t="info",Object.values(this.simpleInstances).forEach(r=>{r.level=t}),Object.values(this.instances).forEach(r=>{r&&(r.level=t)}),typeof process<"u"&&Pe&&(Pe.DEBUG=e?e===!0?"2":String(e):"0")}static setFormat(e){this.currentFormat=e,this.configure({format:e})}},le(ht,"Logger"),jr(ht,"instances",{}),jr(ht,"simpleInstances",{}),jr(ht,"currentFormat","minimal"),ht);ci()?fi.configure():fi.configure({console:!0});var A=fi.get(),im=Pe.MCP_USE_LANGFUSE?.toLowerCase()==="false",en={handler:null,client:null,initPromise:null};async function mo(n,e,t,r){try{const i=await Me(()=>import("./index-Boe6IUZP.js"),__vite__mapDeps([0,1,2,3,4,5,6])).catch(()=>null);if(!i){A.debug("Langfuse package not installed - tracing disabled. Install with: npm install langfuse-langchain");return}const{CallbackHandler:a}=i,u=class u extends a{agentId;metadata;metadataProvider;tagsProvider;verbose;constructor(c,h,f,_,p){super(c),this.agentId=h,this.metadata=f,this.metadataProvider=_,this.tagsProvider=p,this.verbose=c?.verbose??!1}async handleChainStart(c,h,f,_,p,b,w,m){A.debug("Langfuse: Chain start intercepted");const g=this.getCustomTags(),v=this.getMetadata(),E=[...p||[],...g],O={...b||{},...v};return this.verbose&&(A.debug(`Langfuse: Chain start with custom tags: ${JSON.stringify(E)}`),A.debug(`Langfuse: Chain start with metadata: ${JSON.stringify(O)}`)),super.handleChainStart(c,h,f,_,E,O,w,m)}getCustomTags(){const c=[],h=this.getEnvironmentTag();if(h&&c.push(`env:${h}`),this.agentId&&c.push(`agent_id:${this.agentId}`),this.tagsProvider){const f=this.tagsProvider();f&&f.length>0&&c.push(...f)}return c}getMetadata(){const c={},h=this.getEnvironmentTag();if(h&&(c.env=h),this.agentId&&(c.agent_id=this.agentId),this.metadata&&Object.assign(c,this.metadata),this.metadataProvider){const f=this.metadataProvider();f&&Object.assign(c,f)}return c}getEnvironmentTag(){const c=Pe.MCP_USE_AGENT_ENV;if(!c)return"unknown";const h=c.toLowerCase();return h==="local"||h==="development"?"local":h==="production"||h==="prod"?"production":h==="staging"||h==="stage"?"staging":h==="hosted"||h==="cloud"?"hosted":h.replace(/[^a-z0-9_-]/g,"_")}async handleLLMStart(...c){return A.debug("Langfuse: LLM start intercepted"),this.verbose&&A.debug(`Langfuse: LLM start args: ${JSON.stringify(c)}`),super.handleLLMStart(...c)}async handleToolStart(...c){return A.debug("Langfuse: Tool start intercepted"),this.verbose&&A.debug(`Langfuse: Tool start args: ${JSON.stringify(c)}`),super.handleToolStart(...c)}async handleRetrieverStart(...c){return A.debug("Langfuse: Retriever start intercepted"),this.verbose&&A.debug(`Langfuse: Retriever start args: ${JSON.stringify(c)}`),super.handleRetrieverStart(...c)}async handleAgentAction(...c){return A.debug("Langfuse: Agent action intercepted"),this.verbose&&A.debug(`Langfuse: Agent action args: ${JSON.stringify(c)}`),super.handleAgentAction(...c)}async handleAgentEnd(...c){return A.debug("Langfuse: Agent end intercepted"),this.verbose&&A.debug(`Langfuse: Agent end args: ${JSON.stringify(c)}`),super.handleAgentEnd(...c)}};le(u,"LoggingCallbackHandler");let s=u;const o={publicKey:Pe.LANGFUSE_PUBLIC_KEY,secretKey:Pe.LANGFUSE_SECRET_KEY,baseUrl:Pe.LANGFUSE_HOST||Pe.LANGFUSE_BASEURL||"https://cloud.langfuse.com",flushAt:Number.parseInt(Pe.LANGFUSE_FLUSH_AT||"15"),flushInterval:Number.parseInt(Pe.LANGFUSE_FLUSH_INTERVAL||"10000"),release:Pe.LANGFUSE_RELEASE,requestTimeout:Number.parseInt(Pe.LANGFUSE_REQUEST_TIMEOUT||"10000"),enabled:Pe.LANGFUSE_ENABLED!=="false"};en.handler=new s(o,n,e,t,r),A.debug("Langfuse observability initialized successfully with logging enabled");try{const l=await Me(()=>import("./index-BtU-sGqa.js"),__vite__mapDeps([1,2,3,4,5,6])).catch(()=>null);if(l){const{Langfuse:c}=l;en.client=new c({publicKey:Pe.LANGFUSE_PUBLIC_KEY,secretKey:Pe.LANGFUSE_SECRET_KEY,baseUrl:Pe.LANGFUSE_HOST||"https://cloud.langfuse.com"}),A.debug("Langfuse client initialized")}}catch(l){A.debug(`Langfuse client initialization failed: ${l}`)}}catch(i){A.debug(`Langfuse initialization error: ${i}`)}}le(mo,"initializeLangfuse");im?A.debug("Langfuse tracing disabled via MCP_USE_LANGFUSE environment variable"):!Pe.LANGFUSE_PUBLIC_KEY||!Pe.LANGFUSE_SECRET_KEY?A.debug("Langfuse API keys not found - tracing disabled. Set LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY to enable"):en.initPromise=mo();var am=le(()=>en.handler,"langfuseHandler"),sm=le(()=>en.initPromise,"langfuseInitPromise");class om{static convert(e){return this.parseSchema(e)}static matchesCondition(e,t){if(!t.properties)return!0;if(typeof e!="object"||e===null||Array.isArray(e))return!1;const r=e;for(const[i,a]of Object.entries(t.properties)){if(!(i in r)){if("const"in a)return!1;continue}const s=r[i];if("const"in a&&s!==a.const||"minimum"in a&&typeof s=="number"&&s<a.minimum||"maximum"in a&&typeof s=="number"&&s>a.maximum)return!1}return!0}static validateConditionalSchema(e,t,r){this.validateRequiredProperties(e,t,r),this.validatePropertyPatterns(e,t,r),this.validateNestedConditions(e,t,r)}static validateRequiredProperties(e,t,r){if(t.required){if(typeof e!="object"||e===null){for(const i of t.required)r.addIssue({code:Bi.custom,message:`Required property '${i}' is missing`,path:[i]});return}for(const i of t.required)i in e||r.addIssue({code:Bi.custom,message:`Required property '${i}' is missing`,path:[i]})}}static validatePropertyPatterns(e,t,r){if(!t.properties||typeof e!="object"||e===null||Array.isArray(e))return;const i=e;for(const[a,s]of Object.entries(t.properties)){if(!(a in i))continue;const o=i[a];s.pattern&&typeof o=="string"&&(new RegExp(s.pattern).test(o)||r.addIssue({code:Bi.custom,message:`String '${o}' does not match pattern '${s.pattern}'`,path:[a]}))}}static validateNestedConditions(e,t,r){if(!t.if||!t.then)return;this.matchesCondition(e,t.if)?this.validateConditionalSchema(e,t.then,r):t.else&&this.validateConditionalSchema(e,t.else,r)}static parseSchema(e){return Array.isArray(e.type)?this.handleTypeArray(e):e.oneOf||e.anyOf||e.allOf?this.parseCombinator(e):e.if&&e.then?this.parseObject(e):e.properties&&(!e.type||e.type==="object")?this.parseObject(e):this.handleSingleType(e)}static handleTypeArray(e){if(!Array.isArray(e.type))throw new Error("Expected schema.type to be an array");return e.type.includes("null")?this.handleNullableType(e):this.createUnionFromTypes(e.type,e)}static handleNullableType(e){if(!Array.isArray(e.type))throw new Error("Expected schema.type to be an array");const t={...e};return t.type=e.type.filter(i=>i!=="null"),t.type.length===1?this.handleSingleType({...e,type:t.type[0]}).nullable():this.parseSchema(t).nullable()}static createUnionFromTypes(e,t){const r=e.map(i=>{const a={...t,type:i};return this.parseSchema(a)});return qi(r)}static handleSingleType(e){if(e.type===void 0)return e.oneOf||e.anyOf||e.allOf?this.parseCombinator(e):e.properties?this.parseObject(e):pt();switch(e.type){case"string":return this.parseString(e);case"number":case"integer":return this.parseNumberSchema(e);case"boolean":return sh();case"array":return this.parseArray(e);case"object":return this.parseObject(e);default:throw new Error("Unsupported schema type")}}static parseNumberSchema(e){let t=oh(),r=t;return r=this.applyNumberBounds(t,e),r=this.applyNumberMultipleOf(t,e),r=this.applyNumberEnum(t,e),r=this.applyIntegerConstraint(t,e),r}static applyNumberBounds(e,t){let r=e;return t.minimum!==void 0&&(r=t.exclusiveMinimum?r.gt(t.minimum):r.gte(t.minimum)),t.maximum!==void 0&&(r=t.exclusiveMaximum?r.lt(t.maximum):r.lte(t.maximum)),r}static applyNumberMultipleOf(e,t){return t.multipleOf===void 0?e:e.refine(r=>r%t.multipleOf===0,{message:`Number must be a multiple of ${t.multipleOf}`})}static applyNumberEnum(e,t){if(!t.enum)return e;const r=t.enum.filter(i=>typeof i=="number");return r.length===0?e:e.refine(i=>r.includes(i),{message:`Number must be one of: ${r.join(", ")}`})}static applyIntegerConstraint(e,t){return t.type!=="integer"?e:e.refine(r=>Number.isInteger(r),{message:"Number must be an integer"})}static parseString(e){let t=cn(),r=t;return e.format?this.applyStringFormat(t,e):(r=this.applyStringPattern(t,e),r=this.applyStringLength(t,e),r=this.applyStringEnum(t,e),r)}static applyStringFormat(e,t){if(!t.format)return e;switch(t.format){case"email":return e.email();case"date-time":return e.datetime();case"uri":return e.url();case"uuid":return e.uuid();case"date":return e.date();default:return e}}static applyStringPattern(e,t){if(!t.pattern)return e;const r=new RegExp(t.pattern);return e.regex(r,{message:`String must match pattern: ${t.pattern}`})}static applyStringLength(e,t){let r=e;return t.minLength!==void 0&&(e=e.min(t.minLength)),t.maxLength!==void 0&&(e=e.max(t.maxLength)),r}static applyStringEnum(e,t){return t.enum?e.refine(r=>t.enum?.includes(r),{message:`Value must be one of: ${t.enum?.join(", ")}`}):e}static parseArray(e){if(Array.isArray(e.items)){const a=e.items.map(s=>this.parseSchema(s));return qi(a)}const t=e.items?this.parseSchema(e.items):pt();let r=uh(t),i=r;return i=this.applyArrayConstraints(r,e),i}static applyArrayConstraints(e,t){return t.minItems!==void 0&&(e=e.min(t.minItems)),t.maxItems!==void 0&&(e=e.max(t.maxItems)),t.uniqueItems?e.refine(r=>new Set(r).size===r.length,{message:"Array items must be unique"}):e}static parseObject(e){if(e.if&&e.then)return this.parseConditional(e);const t={};return this.processObjectProperties(e,t),this.processAdditionalProperties(e,lt(t))}static processObjectProperties(e,t){const r=new Set(e.required||[]);if(e.properties)for(const[i,a]of Object.entries(e.properties)){const s=this.parseSchema(a);t[i]=r.has(i)?s:s.optional()}}static processAdditionalProperties(e,t){if(e.additionalProperties===!0)return t.passthrough();if(e.additionalProperties&&typeof e.additionalProperties=="object"){const r=this.parseSchema(e.additionalProperties);return t.catchall(r)}else return t.strict()}static parseConditional(e){const t=this.createBaseObjectSchema(e),r=e.if,i=e.then,a=e.else;return t.superRefine((s,o)=>{const u=this.applyDefaultValues(s,e);this.matchesCondition(u,r)?this.validateConditionalSchema(u,i,o):a&&this.validateConditionalSchema(u,a,o)})}static createBaseObjectSchema(e){const t={},r=new Set(e.required||[]);for(const[a,s]of Object.entries(e.properties||{})){const o=this.parseSchema(s);t[a]=r.has(a)?o:o.optional()}const i=lt(t);return this.processAdditionalProperties(e,i)}static applyDefaultValues(e,t){if(typeof e!="object"||e===null||Array.isArray(e))return e;const i={...e};if(!t.properties)return i;for(const[a,s]of Object.entries(t.properties))!(a in i)&&"default"in s&&(i[a]=s.default);return i}static parseCombinator(e){if(e.oneOf)return this.parseOneOf(e.oneOf);if(e.anyOf)return this.parseAnyOf(e.anyOf);if(e.allOf)return this.parseAllOf(e.allOf);throw new Error("Unsupported schema type")}static parseOneOf(e){return this.createUnionFromSchemas(e)}static parseAnyOf(e){return this.createUnionFromSchemas(e)}static createUnionFromSchemas(e){if(e.length===0)return pt();if(e.length===1)return this.parseSchema(e[0]);const t=[];for(const r of e)r.type==="null"?t.push(lh()):t.push(this.parseSchema(r));return t.length>=2?qi(t):t.length===1?t[0]:pt()}static parseAllOf(e){if(e.length===0)return pt();if(e.length===1)return this.parseSchema(e[0]);const t=e.reduce((r,i)=>this.mergeSchemas(r,i));return this.parseSchema(t)}static mergeSchemas(e,t){const r={...e,...t};if(e.properties&&t.properties){const i={...e.properties,...t.properties};r.properties=i}if(e.required&&t.required){const i=[...new Set([...e.required,...t.required])];r.required=i}return r}}function Ze(n){return encodeURI(um(n))}function um(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}const lm={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},cm={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},fm={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};let dm=typeof self<"u"&&self.location&&self.location.origin!=="null"?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function Ur(n,e=Object.create(null),t=dm,r=""){if(n&&typeof n=="object"&&!Array.isArray(n)){const a=n.$id||n.id;if(a){const s=new URL(a,t.href);s.hash.length>1?e[s.href]=n:(s.hash="",r===""?t=s:Ur(n,e,t))}}else if(n!==!0&&n!==!1)return e;const i=t.href+(r?"#"+r:"");if(e[i]!==void 0)throw new Error(`Duplicate schema URI "${i}".`);if(e[i]=n,n===!0||n===!1)return e;if(n.__absolute_uri__===void 0&&Object.defineProperty(n,"__absolute_uri__",{enumerable:!1,value:i}),n.$ref&&n.__absolute_ref__===void 0){const a=new URL(n.$ref,t.href);a.hash=a.hash,Object.defineProperty(n,"__absolute_ref__",{enumerable:!1,value:a.href})}if(n.$recursiveRef&&n.__absolute_recursive_ref__===void 0){const a=new URL(n.$recursiveRef,t.href);a.hash=a.hash,Object.defineProperty(n,"__absolute_recursive_ref__",{enumerable:!1,value:a.href})}if(n.$anchor){const a=new URL("#"+n.$anchor,t.href);e[a.href]=n}for(let a in n){if(fm[a])continue;const s=`${r}/${Ze(a)}`,o=n[a];if(Array.isArray(o)){if(lm[a]){const u=o.length;for(let l=0;l<u;l++)Ur(o[l],e,t,`${s}/${l}`)}}else if(cm[a])for(let u in o)Ur(o[u],e,t,`${s}/${Ze(u)}`);else Ur(o,e,t,s)}return e}const hm=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,pm=[0,31,28,31,30,31,30,31,31,30,31,30,31],mm=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,gm=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ym=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,bm=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,_m=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,vm=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,wm=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Em=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,Sm=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,Om=n=>{if(n[0]==='"')return!1;const[e,t,...r]=n.split("@");return!e||!t||r.length!==0||e.length>64||t.length>253||e[0]==="."||e.endsWith(".")||e.includes("..")||!/^[a-z0-9.-]+$/i.test(t)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(e)?!1:t.split(".").every(i=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(i))},Tm=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,Pm=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,xm=n=>n.length>1&&n.length<80&&(/^P\d+([.,]\d+)?W$/.test(n)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(n)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(n));function at(n){return n.test.bind(n)}const tc={date:Qf,time:Zf.bind(void 0,!1),"date-time":Im,duration:xm,uri:jm,"uri-reference":at(ym),"uri-template":at(bm),url:at(_m),email:Om,hostname:at(gm),ipv4:at(Tm),ipv6:at(Pm),regex:km,uuid:at(vm),"json-pointer":at(wm),"json-pointer-uri-fragment":at(Em),"relative-json-pointer":at(Sm)};function Am(n){return n%4===0&&(n%100!==0||n%400===0)}function Qf(n){const e=n.match(hm);if(!e)return!1;const t=+e[1],r=+e[2],i=+e[3];return r>=1&&r<=12&&i>=1&&i<=(r==2&&Am(t)?29:pm[r])}function Zf(n,e){const t=e.match(mm);if(!t)return!1;const r=+t[1],i=+t[2],a=+t[3],s=!!t[5];return(r<=23&&i<=59&&a<=59||r==23&&i==59&&a==60)&&(!n||s)}const Rm=/t|\s/i;function Im(n){const e=n.split(Rm);return e.length==2&&Qf(e[0])&&Zf(!0,e[1])}const Cm=/\/|:/,$m=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function jm(n){return Cm.test(n)&&$m.test(n)}const Mm=/[^\\]\\Z/;function km(n){if(Mm.test(n))return!1;try{return new RegExp(n,"u"),!0}catch{return!1}}function Nm(n){let e=0,t=n.length,r=0,i;for(;r<t;)e++,i=n.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=n.charCodeAt(r),(i&64512)==56320&&r++);return e}function Se(n,e,t="2019-09",r=Ur(e),i=!0,a=null,s="#",o="#",u=Object.create(null)){if(e===!0)return{valid:!0,errors:[]};if(e===!1)return{valid:!1,errors:[{instanceLocation:s,keyword:"false",keywordLocation:s,error:"False boolean schema."}]};const l=typeof n;let c;switch(l){case"boolean":case"number":case"string":c=l;break;case"object":n===null?c="null":Array.isArray(n)?c="array":c="object";break;default:throw new Error(`Instances of "${l}" type are not supported.`)}const{$ref:h,$recursiveRef:f,$recursiveAnchor:_,type:p,const:b,enum:w,required:m,not:g,anyOf:v,allOf:E,oneOf:O,if:C,then:R,else:I,format:$,properties:M,patternProperties:z,additionalProperties:B,unevaluatedProperties:F,minProperties:Y,maxProperties:Z,propertyNames:j,dependentRequired:D,dependentSchemas:G,dependencies:U,prefixItems:H,items:J,additionalItems:X,unevaluatedItems:ae,contains:Q,minContains:ee,maxContains:N,minItems:k,maxItems:V,uniqueItems:se,minimum:oe,maximum:T,exclusiveMinimum:x,exclusiveMaximum:W,multipleOf:re,minLength:_e,maxLength:he,pattern:ye,__absolute_ref__:ke,__absolute_recursive_ref__:Et}=e,ie=[];if(_===!0&&a===null&&(a=e),f==="#"){const ce=a===null?r[Et]:a,ue=`${o}/$recursiveRef`,de=Se(n,a===null?e:a,t,r,i,ce,s,ue,u);de.valid||ie.push({instanceLocation:s,keyword:"$recursiveRef",keywordLocation:ue,error:"A subschema had errors."},...de.errors)}if(h!==void 0){const ue=r[ke||h];if(ue===void 0){let te=`Unresolved $ref "${h}".`;throw ke&&ke!==h&&(te+=` Absolute URI "${ke}".`),te+=`
|
|
44
|
+
Known schemas:
|
|
45
|
+
- ${Object.keys(r).join(`
|
|
46
|
+
- `)}`,new Error(te)}const de=`${o}/$ref`,ne=Se(n,ue,t,r,i,a,s,de,u);if(ne.valid||ie.push({instanceLocation:s,keyword:"$ref",keywordLocation:de,error:"A subschema had errors."},...ne.errors),t==="4"||t==="7")return{valid:ie.length===0,errors:ie}}if(Array.isArray(p)){let ce=p.length,ue=!1;for(let de=0;de<ce;de++)if(c===p[de]||p[de]==="integer"&&c==="number"&&n%1===0&&n===n){ue=!0;break}ue||ie.push({instanceLocation:s,keyword:"type",keywordLocation:`${o}/type`,error:`Instance type "${c}" is invalid. Expected "${p.join('", "')}".`})}else p==="integer"?(c!=="number"||n%1||n!==n)&&ie.push({instanceLocation:s,keyword:"type",keywordLocation:`${o}/type`,error:`Instance type "${c}" is invalid. Expected "${p}".`}):p!==void 0&&c!==p&&ie.push({instanceLocation:s,keyword:"type",keywordLocation:`${o}/type`,error:`Instance type "${c}" is invalid. Expected "${p}".`});if(b!==void 0&&(c==="object"||c==="array"?zi(n,b)||ie.push({instanceLocation:s,keyword:"const",keywordLocation:`${o}/const`,error:`Instance does not match ${JSON.stringify(b)}.`}):n!==b&&ie.push({instanceLocation:s,keyword:"const",keywordLocation:`${o}/const`,error:`Instance does not match ${JSON.stringify(b)}.`})),w!==void 0&&(c==="object"||c==="array"?w.some(ce=>zi(n,ce))||ie.push({instanceLocation:s,keyword:"enum",keywordLocation:`${o}/enum`,error:`Instance does not match any of ${JSON.stringify(w)}.`}):w.some(ce=>n===ce)||ie.push({instanceLocation:s,keyword:"enum",keywordLocation:`${o}/enum`,error:`Instance does not match any of ${JSON.stringify(w)}.`})),g!==void 0){const ce=`${o}/not`;Se(n,g,t,r,i,a,s,ce).valid&&ie.push({instanceLocation:s,keyword:"not",keywordLocation:ce,error:'Instance matched "not" schema.'})}let Ye=[];if(v!==void 0){const ce=`${o}/anyOf`,ue=ie.length;let de=!1;for(let ne=0;ne<v.length;ne++){const te=v[ne],S=Object.create(u),d=Se(n,te,t,r,i,_===!0?a:null,s,`${ce}/${ne}`,S);ie.push(...d.errors),de=de||d.valid,d.valid&&Ye.push(S)}de?ie.length=ue:ie.splice(ue,0,{instanceLocation:s,keyword:"anyOf",keywordLocation:ce,error:"Instance does not match any subschemas."})}if(E!==void 0){const ce=`${o}/allOf`,ue=ie.length;let de=!0;for(let ne=0;ne<E.length;ne++){const te=E[ne],S=Object.create(u),d=Se(n,te,t,r,i,_===!0?a:null,s,`${ce}/${ne}`,S);ie.push(...d.errors),de=de&&d.valid,d.valid&&Ye.push(S)}de?ie.length=ue:ie.splice(ue,0,{instanceLocation:s,keyword:"allOf",keywordLocation:ce,error:"Instance does not match every subschema."})}if(O!==void 0){const ce=`${o}/oneOf`,ue=ie.length,de=O.filter((ne,te)=>{const S=Object.create(u),d=Se(n,ne,t,r,i,_===!0?a:null,s,`${ce}/${te}`,S);return ie.push(...d.errors),d.valid&&Ye.push(S),d.valid}).length;de===1?ie.length=ue:ie.splice(ue,0,{instanceLocation:s,keyword:"oneOf",keywordLocation:ce,error:`Instance does not match exactly one subschema (${de} matches).`})}if((c==="object"||c==="array")&&Object.assign(u,...Ye),C!==void 0){const ce=`${o}/if`;if(Se(n,C,t,r,i,a,s,ce,u).valid){if(R!==void 0){const de=Se(n,R,t,r,i,a,s,`${o}/then`,u);de.valid||ie.push({instanceLocation:s,keyword:"if",keywordLocation:ce,error:'Instance does not match "then" schema.'},...de.errors)}}else if(I!==void 0){const de=Se(n,I,t,r,i,a,s,`${o}/else`,u);de.valid||ie.push({instanceLocation:s,keyword:"if",keywordLocation:ce,error:'Instance does not match "else" schema.'},...de.errors)}}if(c==="object"){if(m!==void 0)for(const ne of m)ne in n||ie.push({instanceLocation:s,keyword:"required",keywordLocation:`${o}/required`,error:`Instance does not have required property "${ne}".`});const ce=Object.keys(n);if(Y!==void 0&&ce.length<Y&&ie.push({instanceLocation:s,keyword:"minProperties",keywordLocation:`${o}/minProperties`,error:`Instance does not have at least ${Y} properties.`}),Z!==void 0&&ce.length>Z&&ie.push({instanceLocation:s,keyword:"maxProperties",keywordLocation:`${o}/maxProperties`,error:`Instance does not have at least ${Z} properties.`}),j!==void 0){const ne=`${o}/propertyNames`;for(const te in n){const S=`${s}/${Ze(te)}`,d=Se(te,j,t,r,i,a,S,ne);d.valid||ie.push({instanceLocation:s,keyword:"propertyNames",keywordLocation:ne,error:`Property name "${te}" does not match schema.`},...d.errors)}}if(D!==void 0){const ne=`${o}/dependantRequired`;for(const te in D)if(te in n){const S=D[te];for(const d of S)d in n||ie.push({instanceLocation:s,keyword:"dependentRequired",keywordLocation:ne,error:`Instance has "${te}" but does not have "${d}".`})}}if(G!==void 0)for(const ne in G){const te=`${o}/dependentSchemas`;if(ne in n){const S=Se(n,G[ne],t,r,i,a,s,`${te}/${Ze(ne)}`,u);S.valid||ie.push({instanceLocation:s,keyword:"dependentSchemas",keywordLocation:te,error:`Instance has "${ne}" but does not match dependant schema.`},...S.errors)}}if(U!==void 0){const ne=`${o}/dependencies`;for(const te in U)if(te in n){const S=U[te];if(Array.isArray(S))for(const d of S)d in n||ie.push({instanceLocation:s,keyword:"dependencies",keywordLocation:ne,error:`Instance has "${te}" but does not have "${d}".`});else{const d=Se(n,S,t,r,i,a,s,`${ne}/${Ze(te)}`);d.valid||ie.push({instanceLocation:s,keyword:"dependencies",keywordLocation:ne,error:`Instance has "${te}" but does not match dependant schema.`},...d.errors)}}}const ue=Object.create(null);let de=!1;if(M!==void 0){const ne=`${o}/properties`;for(const te in M){if(!(te in n))continue;const S=`${s}/${Ze(te)}`,d=Se(n[te],M[te],t,r,i,a,S,`${ne}/${Ze(te)}`);if(d.valid)u[te]=ue[te]=!0;else if(de=i,ie.push({instanceLocation:s,keyword:"properties",keywordLocation:ne,error:`Property "${te}" does not match schema.`},...d.errors),de)break}}if(!de&&z!==void 0){const ne=`${o}/patternProperties`;for(const te in z){const S=new RegExp(te,"u"),d=z[te];for(const y in n){if(!S.test(y))continue;const P=`${s}/${Ze(y)}`,L=Se(n[y],d,t,r,i,a,P,`${ne}/${Ze(te)}`);L.valid?u[y]=ue[y]=!0:(de=i,ie.push({instanceLocation:s,keyword:"patternProperties",keywordLocation:ne,error:`Property "${y}" matches pattern "${te}" but does not match associated schema.`},...L.errors))}}}if(!de&&B!==void 0){const ne=`${o}/additionalProperties`;for(const te in n){if(ue[te])continue;const S=`${s}/${Ze(te)}`,d=Se(n[te],B,t,r,i,a,S,ne);d.valid?u[te]=!0:(de=i,ie.push({instanceLocation:s,keyword:"additionalProperties",keywordLocation:ne,error:`Property "${te}" does not match additional properties schema.`},...d.errors))}}else if(!de&&F!==void 0){const ne=`${o}/unevaluatedProperties`;for(const te in n)if(!u[te]){const S=`${s}/${Ze(te)}`,d=Se(n[te],F,t,r,i,a,S,ne);d.valid?u[te]=!0:ie.push({instanceLocation:s,keyword:"unevaluatedProperties",keywordLocation:ne,error:`Property "${te}" does not match unevaluated properties schema.`},...d.errors)}}}else if(c==="array"){V!==void 0&&n.length>V&&ie.push({instanceLocation:s,keyword:"maxItems",keywordLocation:`${o}/maxItems`,error:`Array has too many items (${n.length} > ${V}).`}),k!==void 0&&n.length<k&&ie.push({instanceLocation:s,keyword:"minItems",keywordLocation:`${o}/minItems`,error:`Array has too few items (${n.length} < ${k}).`});const ce=n.length;let ue=0,de=!1;if(H!==void 0){const ne=`${o}/prefixItems`,te=Math.min(H.length,ce);for(;ue<te;ue++){const S=Se(n[ue],H[ue],t,r,i,a,`${s}/${ue}`,`${ne}/${ue}`);if(u[ue]=!0,!S.valid&&(de=i,ie.push({instanceLocation:s,keyword:"prefixItems",keywordLocation:ne,error:"Items did not match schema."},...S.errors),de))break}}if(J!==void 0){const ne=`${o}/items`;if(Array.isArray(J)){const te=Math.min(J.length,ce);for(;ue<te;ue++){const S=Se(n[ue],J[ue],t,r,i,a,`${s}/${ue}`,`${ne}/${ue}`);if(u[ue]=!0,!S.valid&&(de=i,ie.push({instanceLocation:s,keyword:"items",keywordLocation:ne,error:"Items did not match schema."},...S.errors),de))break}}else for(;ue<ce;ue++){const te=Se(n[ue],J,t,r,i,a,`${s}/${ue}`,ne);if(u[ue]=!0,!te.valid&&(de=i,ie.push({instanceLocation:s,keyword:"items",keywordLocation:ne,error:"Items did not match schema."},...te.errors),de))break}if(!de&&X!==void 0){const te=`${o}/additionalItems`;for(;ue<ce;ue++){const S=Se(n[ue],X,t,r,i,a,`${s}/${ue}`,te);u[ue]=!0,S.valid||(de=i,ie.push({instanceLocation:s,keyword:"additionalItems",keywordLocation:te,error:"Items did not match additional items schema."},...S.errors))}}}if(Q!==void 0)if(ce===0&&ee===void 0)ie.push({instanceLocation:s,keyword:"contains",keywordLocation:`${o}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(ee!==void 0&&ce<ee)ie.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${o}/minContains`,error:`Array has less items (${ce}) than minContains (${ee}).`});else{const ne=`${o}/contains`,te=ie.length;let S=0;for(let d=0;d<ce;d++){const y=Se(n[d],Q,t,r,i,a,`${s}/${d}`,ne);y.valid?(u[d]=!0,S++):ie.push(...y.errors)}S>=(ee||0)&&(ie.length=te),ee===void 0&&N===void 0&&S===0?ie.splice(te,0,{instanceLocation:s,keyword:"contains",keywordLocation:ne,error:"Array does not contain item matching schema."}):ee!==void 0&&S<ee?ie.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${o}/minContains`,error:`Array must contain at least ${ee} items matching schema. Only ${S} items were found.`}):N!==void 0&&S>N&&ie.push({instanceLocation:s,keyword:"maxContains",keywordLocation:`${o}/maxContains`,error:`Array may contain at most ${N} items matching schema. ${S} items were found.`})}if(!de&&ae!==void 0){const ne=`${o}/unevaluatedItems`;for(ue;ue<ce;ue++){if(u[ue])continue;const te=Se(n[ue],ae,t,r,i,a,`${s}/${ue}`,ne);u[ue]=!0,te.valid||ie.push({instanceLocation:s,keyword:"unevaluatedItems",keywordLocation:ne,error:"Items did not match unevaluated items schema."},...te.errors)}}if(se)for(let ne=0;ne<ce;ne++){const te=n[ne],S=typeof te=="object"&&te!==null;for(let d=0;d<ce;d++){if(ne===d)continue;const y=n[d];(te===y||S&&(typeof y=="object"&&y!==null)&&zi(te,y))&&(ie.push({instanceLocation:s,keyword:"uniqueItems",keywordLocation:`${o}/uniqueItems`,error:`Duplicate items at indexes ${ne} and ${d}.`}),ne=Number.MAX_SAFE_INTEGER,d=Number.MAX_SAFE_INTEGER)}}}else if(c==="number"){if(t==="4"?(oe!==void 0&&(x===!0&&n<=oe||n<oe)&&ie.push({instanceLocation:s,keyword:"minimum",keywordLocation:`${o}/minimum`,error:`${n} is less than ${x?"or equal to ":""} ${oe}.`}),T!==void 0&&(W===!0&&n>=T||n>T)&&ie.push({instanceLocation:s,keyword:"maximum",keywordLocation:`${o}/maximum`,error:`${n} is greater than ${W?"or equal to ":""} ${T}.`})):(oe!==void 0&&n<oe&&ie.push({instanceLocation:s,keyword:"minimum",keywordLocation:`${o}/minimum`,error:`${n} is less than ${oe}.`}),T!==void 0&&n>T&&ie.push({instanceLocation:s,keyword:"maximum",keywordLocation:`${o}/maximum`,error:`${n} is greater than ${T}.`}),x!==void 0&&n<=x&&ie.push({instanceLocation:s,keyword:"exclusiveMinimum",keywordLocation:`${o}/exclusiveMinimum`,error:`${n} is less than ${x}.`}),W!==void 0&&n>=W&&ie.push({instanceLocation:s,keyword:"exclusiveMaximum",keywordLocation:`${o}/exclusiveMaximum`,error:`${n} is greater than or equal to ${W}.`})),re!==void 0){const ce=n%re;Math.abs(0-ce)>=11920929e-14&&Math.abs(re-ce)>=11920929e-14&&ie.push({instanceLocation:s,keyword:"multipleOf",keywordLocation:`${o}/multipleOf`,error:`${n} is not a multiple of ${re}.`})}}else if(c==="string"){const ce=_e===void 0&&he===void 0?0:Nm(n);_e!==void 0&&ce<_e&&ie.push({instanceLocation:s,keyword:"minLength",keywordLocation:`${o}/minLength`,error:`String is too short (${ce} < ${_e}).`}),he!==void 0&&ce>he&&ie.push({instanceLocation:s,keyword:"maxLength",keywordLocation:`${o}/maxLength`,error:`String is too long (${ce} > ${he}).`}),ye!==void 0&&!new RegExp(ye,"u").test(n)&&ie.push({instanceLocation:s,keyword:"pattern",keywordLocation:`${o}/pattern`,error:"String does not match pattern."}),$!==void 0&&tc[$]&&!tc[$](n)&&ie.push({instanceLocation:s,keyword:"format",keywordLocation:`${o}/format`,error:`String does not match format "${$}".`})}return{valid:ie.length===0,errors:ie}}function Lm(n,e){return e?.[n]||yh(n)}function Fm(n,e,t){const r={};for(const i in n)Object.hasOwn(n,i)&&(r[e(i,t)]=n[i]);return r}function rc(n){return Array.isArray(n)?[...n]:{...n}}function Dm(n,e){const t=rc(n);for(const[r,i]of Object.entries(e)){const[a,...s]=r.split(".").reverse();let o=t;for(const u of s.reverse()){if(o[u]===void 0)break;o[u]=rc(o[u]),o=o[u]}o[a]!==void 0&&(o[a]={lc:1,type:"secret",id:[i]})}return t}function Xf(n){const e=Object.getPrototypeOf(n);return typeof n.lc_name=="function"&&(typeof e.lc_name!="function"||n.lc_name()!==e.lc_name())?n.lc_name():n.name}class bt{static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,Xf(this.constructor)]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}constructor(e,...t){Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"lc_kwargs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.lc_serializable_keys!==void 0?this.lc_kwargs=Object.fromEntries(Object.entries(e||{}).filter(([r])=>this.lc_serializable_keys?.includes(r))):this.lc_kwargs=e??{}}toJSON(){if(!this.lc_serializable)return this.toJSONNotImplemented();if(this.lc_kwargs instanceof bt||typeof this.lc_kwargs!="object"||Array.isArray(this.lc_kwargs))return this.toJSONNotImplemented();const e={},t={},r=Object.keys(this.lc_kwargs).reduce((i,a)=>(i[a]=a in this?this[a]:this.lc_kwargs[a],i),{});for(let i=Object.getPrototypeOf(this);i;i=Object.getPrototypeOf(i))Object.assign(e,Reflect.get(i,"lc_aliases",this)),Object.assign(t,Reflect.get(i,"lc_secrets",this)),Object.assign(r,Reflect.get(i,"lc_attributes",this));return Object.keys(t).forEach(i=>{let a=this,s=r;const[o,...u]=i.split(".").reverse();for(const l of u.reverse()){if(!(l in a)||a[l]===void 0)return;(!(l in s)||s[l]===void 0)&&(typeof a[l]=="object"&&a[l]!=null?s[l]={}:Array.isArray(a[l])&&(s[l]=[])),a=a[l],s=s[l]}o in a&&a[o]!==void 0&&(s[o]=s[o]||a[o])}),{lc:1,type:"constructor",id:this.lc_id,kwargs:Fm(Object.keys(t).length?Dm(r,t):r,Lm,e)}}toJSONNotImplemented(){return{lc:1,type:"not_implemented",id:this.lc_id}}}var Um={};const Bm=()=>typeof window<"u"&&typeof window.document<"u",qm=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",zm=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),go=()=>typeof Deno<"u",Hm=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!go(),Gm=()=>{let n;return Bm()?n="browser":Hm()?n="node":qm()?n="webworker":zm()?n="jsdom":go()?n="deno":n="other",n};let cs;function Vm(){return cs===void 0&&(cs={library:"langchain-js",runtime:Gm()}),cs}function Jt(n){try{return typeof process<"u"?Um?.[n]:go()?Deno?.env.get(n):void 0}catch{return}}class Wm{}class mn extends Wm{get lc_namespace(){return["langchain_core","callbacks",this.name]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,Xf(this.constructor)]}constructor(e){super(),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"lc_kwargs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ignoreLLM",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"ignoreChain",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"ignoreAgent",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"ignoreRetriever",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"ignoreCustomEvent",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"raiseError",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"awaitHandlers",{enumerable:!0,configurable:!0,writable:!0,value:Jt("LANGCHAIN_CALLBACKS_BACKGROUND")==="false"}),this.lc_kwargs=e||{},e&&(this.ignoreLLM=e.ignoreLLM??this.ignoreLLM,this.ignoreChain=e.ignoreChain??this.ignoreChain,this.ignoreAgent=e.ignoreAgent??this.ignoreAgent,this.ignoreRetriever=e.ignoreRetriever??this.ignoreRetriever,this.ignoreCustomEvent=e.ignoreCustomEvent??this.ignoreCustomEvent,this.raiseError=e.raiseError??this.raiseError,this.awaitHandlers=this.raiseError||(e._awaitHandler??this.awaitHandlers))}copy(){return new this.constructor(this)}toJSON(){return bt.prototype.toJSON.call(this)}toJSONNotImplemented(){return bt.prototype.toJSONNotImplemented.call(this)}static fromMethods(e){class t extends mn{constructor(){super(),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:Le()}),Object.assign(this,e)}}return new t}}const Jm=n=>{const e=n;return e!==void 0&&typeof e.copy=="function"&&typeof e.name=="string"&&typeof e.awaitHandlers=="boolean"},Km="gen_ai.operation.name",Ym="gen_ai.system",nc="gen_ai.request.model",Qm="gen_ai.response.model",ic="gen_ai.usage.input_tokens",ac="gen_ai.usage.output_tokens",sc="gen_ai.usage.total_tokens",Zm="gen_ai.request.max_tokens",Xm="gen_ai.request.temperature",eg="gen_ai.request.top_p",tg="gen_ai.request.frequency_penalty",rg="gen_ai.request.presence_penalty",ng="gen_ai.response.finish_reasons",ig="gen_ai.prompt",ag="gen_ai.completion",sg="gen_ai.request.extra_query",og="gen_ai.request.extra_body",ug="gen_ai.serialized.name",lg="gen_ai.serialized.signature",cg="gen_ai.serialized.doc",fg="gen_ai.response.id",dg="gen_ai.response.service_tier",hg="gen_ai.response.system_fingerprint",pg="gen_ai.usage.input_token_details",mg="gen_ai.usage.output_token_details",gg="langsmith.trace.session_id",yg="langsmith.trace.session_name",bg="langsmith.span.kind",_g="langsmith.trace.name",vg="langsmith.metadata",oc="langsmith.span.tags",wg="langsmith.request.streaming",Eg="langsmith.request.headers",Sg=(...n)=>fetch(...n),ed=Symbol.for("ls:fetch_implementation"),Og=()=>{const n=globalThis[ed];return n?typeof n=="function"&&"Headers"in n&&"Request"in n&&"Response"in n:!1},Tg=n=>async(...e)=>{if(n||ze("DEBUG")==="true"){const[r,i]=e;console.log(`→ ${i?.method||"GET"} ${r}`)}const t=await(globalThis[ed]??Sg)(...e);return(n||ze("DEBUG")==="true")&&console.log(`← ${t.status} ${t.statusText} ${t.url}`),t},td=()=>ze("PROJECT")??ct("LANGCHAIN_SESSION")??"default",rd="0.3.73";var Cs={};let st;const Pg=()=>typeof window<"u"&&typeof window.document<"u",xg=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",Ag=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),nd=()=>typeof Deno<"u",Rg=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!nd(),id=()=>st||(typeof Bun<"u"?st="bun":Pg()?st="browser":Rg()?st="node":xg()?st="webworker":Ag()?st="jsdom":nd()?st="deno":st="other",st);let fs;function ad(){if(fs===void 0){const n=id(),e=Cg();fs={library:"langsmith",runtime:n,sdk:"langsmith-js",sdk_version:rd,...e}}return fs}function sd(){const n=Ig(),e={},t=["LANGCHAIN_API_KEY","LANGCHAIN_ENDPOINT","LANGCHAIN_TRACING_V2","LANGCHAIN_PROJECT","LANGCHAIN_SESSION","LANGSMITH_API_KEY","LANGSMITH_ENDPOINT","LANGSMITH_TRACING_V2","LANGSMITH_PROJECT","LANGSMITH_SESSION"];for(const[r,i]of Object.entries(n))typeof i=="string"&&!t.includes(r)&&!r.toLowerCase().includes("key")&&!r.toLowerCase().includes("secret")&&!r.toLowerCase().includes("token")&&(r==="LANGCHAIN_REVISION_ID"?e.revision_id=i:e[r]=i);return e}function Ig(){const n={};try{if(typeof process<"u"&&Cs)for(const[e,t]of Object.entries(Cs))(e.startsWith("LANGCHAIN_")||e.startsWith("LANGSMITH_"))&&t!=null&&((e.toLowerCase().includes("key")||e.toLowerCase().includes("secret")||e.toLowerCase().includes("token"))&&typeof t=="string"?n[e]=t.slice(0,2)+"*".repeat(t.length-4)+t.slice(-2):n[e]=t)}catch{}return n}function ct(n){try{return typeof process<"u"?Cs?.[n]:void 0}catch{return}}function ze(n){return ct(`LANGSMITH_${n}`)||ct(`LANGCHAIN_${n}`)}let ds;function Cg(){if(ds!==void 0)return ds;const n=["VERCEL_GIT_COMMIT_SHA","NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA","COMMIT_REF","RENDER_GIT_COMMIT","CI_COMMIT_SHA","CIRCLE_SHA1","CF_PAGES_COMMIT_SHA","REACT_APP_GIT_SHA","SOURCE_VERSION","GITHUB_SHA","TRAVIS_COMMIT","GIT_COMMIT","BUILD_VCS_NUMBER","bamboo_planRepository_revision","Build.SourceVersion","BITBUCKET_COMMIT","DRONE_COMMIT_SHA","SEMAPHORE_GIT_SHA","BUILDKITE_COMMIT"],e={};for(const t of n){const r=ct(t);r!==void 0&&(e[t]=r)}return ds=e,e}function od(){return ct("OTEL_ENABLED")==="true"||ze("OTEL_ENABLED")==="true"}class $g{constructor(){Object.defineProperty(this,"hasWarned",{enumerable:!0,configurable:!0,writable:!0,value:!1})}startActiveSpan(e,...t){!this.hasWarned&&od()&&(console.warn('You have enabled OTEL export via the `OTEL_ENABLED` or `LANGSMITH_OTEL_ENABLED` environment variable, but have not initialized the required OTEL instances. Please add:\n```\nimport { initializeOTEL } from "langsmith/experimental/otel/setup";\ninitializeOTEL();\n```\nat the beginning of your code.'),this.hasWarned=!0);let r;if(t.length===1&&typeof t[0]=="function"?r=t[0]:t.length===2&&typeof t[1]=="function"?r=t[1]:t.length===3&&typeof t[2]=="function"&&(r=t[2]),typeof r=="function")return r()}}class jg{constructor(){Object.defineProperty(this,"mockTracer",{enumerable:!0,configurable:!0,writable:!0,value:new $g})}getTracer(e,t){return this.mockTracer}getActiveSpan(){}setSpan(e,t){return e}getSpan(e){}setSpanContext(e,t){return e}getTracerProvider(){}setGlobalTracerProvider(e){return!1}}class Mg{active(){return{}}with(e,t){return t()}}const hs=Symbol.for("ls:otel_trace"),ps=Symbol.for("ls:otel_context"),uc=Symbol.for("ls:otel_get_default_otlp_tracer_provider"),kg=new jg,Ng=new Mg;class Lg{getTraceInstance(){return globalThis[hs]??kg}getContextInstance(){return globalThis[ps]??Ng}initializeGlobalInstances(e){globalThis[hs]===void 0&&(globalThis[hs]=e.trace),globalThis[ps]===void 0&&(globalThis[ps]=e.context)}setDefaultOTLPTracerComponents(e){globalThis[uc]=e}getDefaultOTLPTracerComponents(){return globalThis[uc]??void 0}}const yo=new Lg;function ud(){return yo.getTraceInstance()}function Fg(){return yo.getContextInstance()}function Dg(){return yo.getDefaultOTLPTracerComponents()}const Ug={llm:"chat",tool:"execute_tool",retriever:"embeddings",embedding:"embeddings",prompt:"chat"};function Bg(n){return Ug[n]||n}class qg{constructor(){Object.defineProperty(this,"spans",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}exportBatch(e,t){for(const r of e)try{if(!r.run)continue;if(r.operation==="post"){const i=this.createSpanForRun(r,r.run,t.get(r.id));i&&!r.run.end_time&&this.spans.set(r.id,i)}else this.updateSpanForRun(r,r.run)}catch(i){console.error(`Error processing operation ${r.id}:`,i)}}createSpanForRun(e,t,r){const i=r&&ud().getSpan(r);if(i)try{return this.finishSpanSetup(i,t,e)}catch(a){console.error(`Failed to create span for run ${e.id}:`,a);return}}finishSpanSetup(e,t,r){return this.setSpanAttributes(e,t,r),t.error?(e.setStatus({code:2}),e.recordException(new Error(t.error))):e.setStatus({code:1}),t.end_time&&e.end(new Date(t.end_time)),e}updateSpanForRun(e,t){try{const r=this.spans.get(e.id);if(!r){console.debug(`No span found for run ${e.id} during update`);return}this.setSpanAttributes(r,t,e),t.error?(r.setStatus({code:2}),r.recordException(new Error(t.error))):r.setStatus({code:1});const i=t.end_time;i&&(r.end(new Date(i)),this.spans.delete(e.id))}catch(r){console.error(`Failed to update span for run ${e.id}:`,r)}}extractModelName(e){if(e.extra?.metadata){const t=e.extra.metadata;if(t.ls_model_name)return t.ls_model_name;if(t.invocation_params){const r=t.invocation_params;if(r.model)return r.model;if(r.model_name)return r.model_name}}}setSpanAttributes(e,t,r){if("run_type"in t&&t.run_type){e.setAttribute(bg,t.run_type);const o=Bg(t.run_type||"chain");e.setAttribute(Km,o)}"name"in t&&t.name&&e.setAttribute(_g,t.name),"session_id"in t&&t.session_id&&e.setAttribute(gg,t.session_id),"session_name"in t&&t.session_name&&e.setAttribute(yg,t.session_name),this.setGenAiSystem(e,t);const i=this.extractModelName(t);i&&e.setAttribute(nc,i),"prompt_tokens"in t&&typeof t.prompt_tokens=="number"&&e.setAttribute(ic,t.prompt_tokens),"completion_tokens"in t&&typeof t.completion_tokens=="number"&&e.setAttribute(ac,t.completion_tokens),"total_tokens"in t&&typeof t.total_tokens=="number"&&e.setAttribute(sc,t.total_tokens),this.setInvocationParameters(e,t);const a=t.extra?.metadata||{};for(const[o,u]of Object.entries(a))u!=null&&e.setAttribute(`${vg}.${o}`,String(u));const s=t.tags;if(s&&Array.isArray(s)?e.setAttribute(oc,s.join(", ")):s&&e.setAttribute(oc,String(s)),"serialized"in t&&typeof t.serialized=="object"){const o=t.serialized;o.name&&e.setAttribute(ug,String(o.name)),o.signature&&e.setAttribute(lg,String(o.signature)),o.doc&&e.setAttribute(cg,String(o.doc))}this.setIOAttributes(e,r)}setGenAiSystem(e,t){let r="langchain";const i=this.extractModelName(t);if(i){const a=i.toLowerCase();a.includes("anthropic")||a.startsWith("claude")?r="anthropic":a.includes("bedrock")?r="aws.bedrock":a.includes("azure")&&a.includes("openai")?r="az.ai.openai":a.includes("azure")&&a.includes("inference")?r="az.ai.inference":a.includes("cohere")?r="cohere":a.includes("deepseek")?r="deepseek":a.includes("gemini")?r="gemini":a.includes("groq")?r="groq":a.includes("watson")||a.includes("ibm")?r="ibm.watsonx.ai":a.includes("mistral")?r="mistral_ai":a.includes("gpt")||a.includes("openai")?r="openai":a.includes("perplexity")||a.includes("sonar")?r="perplexity":a.includes("vertex")?r="vertex_ai":(a.includes("xai")||a.includes("grok"))&&(r="xai")}e.setAttribute(Ym,r)}setInvocationParameters(e,t){if(!t.extra?.metadata?.invocation_params)return;const r=t.extra.metadata.invocation_params;r.max_tokens!==void 0&&e.setAttribute(Zm,r.max_tokens),r.temperature!==void 0&&e.setAttribute(Xm,r.temperature),r.top_p!==void 0&&e.setAttribute(eg,r.top_p),r.frequency_penalty!==void 0&&e.setAttribute(tg,r.frequency_penalty),r.presence_penalty!==void 0&&e.setAttribute(rg,r.presence_penalty)}setIOAttributes(e,t){if(t.run.inputs)try{const r=t.run.inputs;typeof r=="object"&&r!==null&&(r.model&&Array.isArray(r.messages)&&e.setAttribute(nc,r.model),r.stream!==void 0&&e.setAttribute(wg,r.stream),r.extra_headers&&e.setAttribute(Eg,JSON.stringify(r.extra_headers)),r.extra_query&&e.setAttribute(sg,JSON.stringify(r.extra_query)),r.extra_body&&e.setAttribute(og,JSON.stringify(r.extra_body))),e.setAttribute(ig,JSON.stringify(r))}catch(r){console.debug(`Failed to process inputs for run ${t.id}`,r)}if(t.run.outputs)try{const r=t.run.outputs,i=this.getUnifiedRunTokens(r);if(i&&(e.setAttribute(ic,i[0]),e.setAttribute(ac,i[1]),e.setAttribute(sc,i[0]+i[1])),r&&typeof r=="object"){if(r.model&&e.setAttribute(Qm,String(r.model)),r.id&&e.setAttribute(fg,r.id),r.choices&&Array.isArray(r.choices)){const a=r.choices.map(s=>s.finish_reason).filter(s=>s).map(String);a.length>0&&e.setAttribute(ng,a.join(", "))}if(r.service_tier&&e.setAttribute(dg,r.service_tier),r.system_fingerprint&&e.setAttribute(hg,r.system_fingerprint),r.usage_metadata&&typeof r.usage_metadata=="object"){const a=r.usage_metadata;a.input_token_details&&e.setAttribute(pg,JSON.stringify(a.input_token_details)),a.output_token_details&&e.setAttribute(mg,JSON.stringify(a.output_token_details))}}e.setAttribute(ag,JSON.stringify(r))}catch(r){console.debug(`Failed to process outputs for run ${t.id}`,r)}}getUnifiedRunTokens(e){if(!e)return null;let t=this.extractUnifiedRunTokens(e.usage_metadata);if(t)return t;const r=Object.keys(e);for(const s of r){const o=e[s];if(!(!o||typeof o!="object")&&(t=this.extractUnifiedRunTokens(o.usage_metadata),t||o.lc===1&&o.kwargs&&typeof o.kwargs=="object"&&(t=this.extractUnifiedRunTokens(o.kwargs.usage_metadata),t)))return t}const i=e.generations||[];if(!Array.isArray(i))return null;const a=Array.isArray(i[0])?i.flat():i;for(const s of a)if(typeof s=="object"&&s.message&&typeof s.message=="object"&&s.message.kwargs&&typeof s.message.kwargs=="object"&&(t=this.extractUnifiedRunTokens(s.message.kwargs.usage_metadata),t))return t;return null}extractUnifiedRunTokens(e){return!e||typeof e!="object"||typeof e.input_tokens!="number"||typeof e.output_tokens!="number"?null:[e.input_tokens,e.output_tokens]}}const zg=[429,500,502,503,504];let lc=class{constructor(e){Object.defineProperty(this,"maxConcurrency",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxRetries",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"queue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFailedResponseHook",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxConcurrency=e.maxConcurrency??1/0,this.maxRetries=e.maxRetries??6,"default"in gt?this.queue=new gt.default({concurrency:this.maxConcurrency}):this.queue=new gt({concurrency:this.maxConcurrency}),this.onFailedResponseHook=e?.onFailedResponseHook}call(e,...t){const r=this.onFailedResponseHook;return this.queue.add(()=>ai(()=>e(...t).catch(i=>{throw i instanceof Error?i:new Error(i)}),{async onFailedAttempt(i){if(i.message.startsWith("Cancel")||i.message.startsWith("TimeoutError")||i.name==="TimeoutError"||i.message.startsWith("AbortError")||i?.code==="ECONNABORTED")throw i;const a=i?.response;if(r&&await r(a))return;const s=a?.status??i?.status;if(s&&!zg.includes(+s))throw i},retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0})}callWithOptions(e,t,...r){return e.signal?Promise.race([this.call(t,...r),new Promise((i,a)=>{e.signal?.addEventListener("abort",()=>{a(new Error("AbortError"))})})]):this.call(t,...r)}};function cc(n){return typeof n?._getType=="function"}function fc(n){const e={type:n._getType(),data:{content:n.content}};return n?.additional_kwargs&&Object.keys(n.additional_kwargs).length>0&&(e.data.additional_kwargs={...n.additional_kwargs}),e}const Hg=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function pe(n,e){if(!Hg.test(n)){const t=e!==void 0?`Invalid UUID for ${e}: ${n}`:`Invalid UUID: ${n}`;throw new Error(t)}return n}const dc={};function ld(n){dc[n]||(console.warn(n),dc[n]=!0)}function Ot(n){if(!n||n.split("/").length>2||n.startsWith("/")||n.endsWith("/")||n.split(":").length>2)throw new Error(`Invalid identifier format: ${n}`);const[e,t]=n.split(":"),r=t||"latest";if(e.includes("/")){const[i,a]=e.split("/",2);if(!i||!a)throw new Error(`Invalid identifier format: ${n}`);return[i,a,r]}else{if(!e)throw new Error(`Invalid identifier format: ${n}`);return["-",e,r]}}class Gg extends Error{constructor(e){super(e),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="LangSmithConflictError",this.status=409}}async function fe(n,e,t){let r;if(n.ok){t&&(r=await n.text());return}if(n.status===403)try{(await n.json())?.error==="org_scoped_key_requires_workspace"&&(r="This API key is org-scoped and requires workspace specification. Please provide 'workspaceId' parameter, or set LANGSMITH_WORKSPACE_ID environment variable.")}catch{const o=new Error(`${n.status} ${n.statusText}`);throw o.status=n?.status,o}if(r===void 0)try{r=await n.text()}catch{r=""}const i=`Failed to ${e}. Received status [${n.status}]: ${n.statusText}. Message: ${r}`;if(n.status===409)throw new Gg(i);const a=new Error(i);throw a.status=n.status,a}const cd="ERR_CONFLICTING_ENDPOINTS";class Vg extends Error{constructor(){super("You cannot provide both LANGSMITH_ENDPOINT / LANGCHAIN_ENDPOINT and LANGSMITH_RUNS_ENDPOINTS."),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:cd}),this.name="ConflictingEndpointsError"}}function Wg(n){return typeof n=="object"&&n!==null&&n.code===cd}var hc="[...]",Jg={result:"[Circular]"},di=[],Vt=[];const Kg=new TextEncoder;function Yg(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function Yn(n){return Kg.encode(n)}function fd(n){if(n&&typeof n=="object"&&n!==null){if(n instanceof Map)return Object.fromEntries(n);if(n instanceof Set)return Array.from(n);if(n instanceof Date)return n.toISOString();if(n instanceof RegExp)return n.toString();if(n instanceof Error)return{name:n.name,message:n.message}}else if(typeof n=="bigint")return n.toString();return n}function Qg(n){return function(e,t){return fd(t)}}function Ge(n,e,t,r,i){try{const a=JSON.stringify(n,Qg(t),r);return Yn(a)}catch(a){if(!a.message?.includes("Converting circular structure to JSON"))return console.warn(`[WARNING]: LangSmith received unserializable value.${e?`
|
|
47
|
+
Context: ${e}`:""}`),Yn("[Unserializable]");ze("SUPPRESS_CIRCULAR_JSON_WARNINGS")!=="true"&&console.warn(`[WARNING]: LangSmith received circular JSON. This will decrease tracer performance. ${e?`
|
|
48
|
+
Context: ${e}`:""}`),typeof i>"u"&&(i=Yg()),$s(n,"",0,[],void 0,0,i);let s;try{Vt.length===0?s=JSON.stringify(n,t,r):s=JSON.stringify(n,Zg(t),r)}catch{return Yn("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;di.length!==0;){const o=di.pop();o.length===4?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return Yn(s)}}function ms(n,e,t,r){var i=Object.getOwnPropertyDescriptor(r,t);i.get!==void 0?i.configurable?(Object.defineProperty(r,t,{value:n}),di.push([r,t,e,i])):Vt.push([e,t,n]):(r[t]=n,di.push([r,t,e]))}function $s(n,e,t,r,i,a,s){a+=1;var o;if(typeof n=="object"&&n!==null){for(o=0;o<r.length;o++)if(r[o]===n){ms(Jg,n,e,i);return}if(typeof s.depthLimit<"u"&&a>s.depthLimit){ms(hc,n,e,i);return}if(typeof s.edgesLimit<"u"&&t+1>s.edgesLimit){ms(hc,n,e,i);return}if(r.push(n),Array.isArray(n))for(o=0;o<n.length;o++)$s(n[o],o,o,r,n,a,s);else{n=fd(n);var u=Object.keys(n);for(o=0;o<u.length;o++){var l=u[o];$s(n[l],l,o,r,n,a,s)}}r.pop()}}function Zg(n){return n=typeof n<"u"?n:function(e,t){return t},function(e,t){if(Vt.length>0)for(var r=0;r<Vt.length;r++){var i=Vt[r];if(i[1]===e&&i[0]===t){t=i[2],Vt.splice(r,1);break}}return n.call(this,e,t)}}function pc(n,e){const t=ad(),r=e??sd(),i=n.extra??{},a=i.metadata;return n.extra={...i,runtime:{...t,...i?.runtime},metadata:{...r,...r.revision_id||"revision_id"in n&&n.revision_id?{revision_id:("revision_id"in n?n.revision_id:void 0)??r.revision_id}:{},...a}},n}const Xg=n=>{const e=n?.toString()??ze("TRACING_SAMPLING_RATE");if(e===void 0)return;const t=parseFloat(e);if(t<0||t>1)throw new Error(`LANGSMITH_TRACING_SAMPLING_RATE must be between 0 and 1 if set. Got: ${t}`);return t},ey=n=>{const t=n.replace("http://","").replace("https://","").split("/")[0].split(":")[0];return t==="localhost"||t==="127.0.0.1"||t==="::1"};async function ty(n){const e=[];for await(const t of n)e.push(t);return e}function Qn(n){if(n!==void 0)return n.trim().replace(/^"(.*)"$/,"$1").replace(/^'(.*)'$/,"$1")}const ry=async n=>{if(n?.status===429){const e=parseInt(n.headers.get("retry-after")??"10",10)*1e3;if(e>0)return await new Promise(t=>setTimeout(t,e)),!0}return!1};function mc(n){return typeof n=="number"?Number(n.toFixed(4)):n}class ny{constructor(){Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"sizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:0})}peek(){return this.items[0]}push(e){let t;const r=new Promise(a=>{t=a}),i=Ge(e.item,`Serializing run with id: ${e.item.id}`).length;return this.items.push({action:e.action,payload:e.item,otelContext:e.otelContext,apiKey:e.apiKey,apiUrl:e.apiUrl,itemPromiseResolve:t,itemPromise:r,size:i}),this.sizeBytes+=i,r}pop({upToSizeBytes:e,upToSize:t}){if(e<1)throw new Error("Number of bytes to pop off may not be less than 1.");const r=[];let i=0;for(;i+(this.peek()?.size??0)<e&&this.items.length>0&&r.length<t;){const a=this.items.shift();a&&(r.push(a),i+=a.size,this.sizeBytes-=a.size)}if(r.length===0&&this.items.length>0){const a=this.items.shift();r.push(a),i+=a.size,this.sizeBytes-=a.size}return[r.map(a=>({action:a.action,item:a.payload,otelContext:a.otelContext,apiKey:a.apiKey,apiUrl:a.apiUrl})),()=>r.forEach(a=>a.itemPromiseResolve())]}}const iy=24*1024*1024,ay=1e4,sy=100,gc="https://api.smith.langchain.com";class tn{get _fetch(){return this.fetchImplementation||Tg(this.debug)}constructor(e={}){Object.defineProperty(this,"apiKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"apiUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"webUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"workspaceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"caller",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"batchIngestCaller",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"timeout_ms",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_tenantId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"hideInputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideOutputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tracingSampleRate",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"filteredPostUuids",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"autoBatchTracing",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"autoBatchQueue",{enumerable:!0,configurable:!0,writable:!0,value:new ny}),Object.defineProperty(this,"autoBatchTimeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"autoBatchAggregationDelayMs",{enumerable:!0,configurable:!0,writable:!0,value:250}),Object.defineProperty(this,"batchSizeBytesLimit",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"batchSizeLimit",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"fetchOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"settings",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"blockOnRootRunFinalization",{enumerable:!0,configurable:!0,writable:!0,value:ct("LANGSMITH_TRACING_BACKGROUND")==="false"}),Object.defineProperty(this,"traceBatchConcurrency",{enumerable:!0,configurable:!0,writable:!0,value:5}),Object.defineProperty(this,"_serverInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_getServerInfoPromise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"manualFlushMode",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"langSmithToOTELTranslator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"fetchImplementation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cachedLSEnvVarsForMetadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"multipartStreamingDisabled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"debug",{enumerable:!0,configurable:!0,writable:!0,value:ct("LANGSMITH_DEBUG")==="true"});const t=tn.getDefaultClientConfig();if(this.tracingSampleRate=Xg(e.tracingSamplingRate),this.apiUrl=Qn(e.apiUrl??t.apiUrl)??"",this.apiUrl.endsWith("/")&&(this.apiUrl=this.apiUrl.slice(0,-1)),this.apiKey=Qn(e.apiKey??t.apiKey),this.webUrl=Qn(e.webUrl??t.webUrl),this.webUrl?.endsWith("/")&&(this.webUrl=this.webUrl.slice(0,-1)),this.workspaceId=Qn(e.workspaceId??ze("WORKSPACE_ID")),this.timeout_ms=e.timeout_ms??9e4,this.caller=new lc({...e.callerOptions??{},maxRetries:4,debug:e.debug??this.debug}),this.traceBatchConcurrency=e.traceBatchConcurrency??this.traceBatchConcurrency,this.traceBatchConcurrency<1)throw new Error("Trace batch concurrency must be positive.");this.debug=e.debug??this.debug,this.fetchImplementation=e.fetchImplementation,this.batchIngestCaller=new lc({maxRetries:2,maxConcurrency:this.traceBatchConcurrency,...e.callerOptions??{},onFailedResponseHook:ry,debug:e.debug??this.debug}),this.hideInputs=e.hideInputs??e.anonymizer??t.hideInputs,this.hideOutputs=e.hideOutputs??e.anonymizer??t.hideOutputs,this.autoBatchTracing=e.autoBatchTracing??this.autoBatchTracing,this.blockOnRootRunFinalization=e.blockOnRootRunFinalization??this.blockOnRootRunFinalization,this.batchSizeBytesLimit=e.batchSizeBytesLimit,this.batchSizeLimit=e.batchSizeLimit,this.fetchOptions=e.fetchOptions||{},this.manualFlushMode=e.manualFlushMode??this.manualFlushMode,od()&&(this.langSmithToOTELTranslator=new qg),this.cachedLSEnvVarsForMetadata=sd()}static getDefaultClientConfig(){const e=ze("API_KEY"),t=ze("ENDPOINT")??gc,r=ze("HIDE_INPUTS")==="true",i=ze("HIDE_OUTPUTS")==="true";return{apiUrl:t,apiKey:e,webUrl:void 0,hideInputs:r,hideOutputs:i}}getHostUrl(){return this.webUrl?this.webUrl:ey(this.apiUrl)?(this.webUrl="http://localhost:3000",this.webUrl):this.apiUrl.endsWith("/api/v1")?(this.webUrl=this.apiUrl.replace("/api/v1",""),this.webUrl):this.apiUrl.includes("/api")&&!this.apiUrl.split(".",1)[0].endsWith("api")?(this.webUrl=this.apiUrl.replace("/api",""),this.webUrl):this.apiUrl.split(".",1)[0].includes("dev")?(this.webUrl="https://dev.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("eu")?(this.webUrl="https://eu.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("beta")?(this.webUrl="https://beta.smith.langchain.com",this.webUrl):(this.webUrl="https://smith.langchain.com",this.webUrl)}get headers(){const e={"User-Agent":`langsmith-js/${rd}`};return this.apiKey&&(e["x-api-key"]=`${this.apiKey}`),this.workspaceId&&(e["x-tenant-id"]=this.workspaceId),e}_getPlatformEndpointPath(e){return this.apiUrl.slice(-3)!=="/v1"&&this.apiUrl.slice(-4)!=="/v1/"?`/v1/platform/${e}`:`/platform/${e}`}async processInputs(e){return this.hideInputs===!1?e:this.hideInputs===!0?{}:typeof this.hideInputs=="function"?this.hideInputs(e):e}async processOutputs(e){return this.hideOutputs===!1?e:this.hideOutputs===!0?{}:typeof this.hideOutputs=="function"?this.hideOutputs(e):e}async prepareRunCreateOrUpdateInputs(e){const t={...e};return t.inputs!==void 0&&(t.inputs=await this.processInputs(t.inputs)),t.outputs!==void 0&&(t.outputs=await this.processOutputs(t.outputs)),t}async _getResponse(e,t){const r=t?.toString()??"",i=`${this.apiUrl}${e}?${r}`;return await this.caller.call(async()=>{const s=await this._fetch(i,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(s,`fetch ${e}`),s})}async _get(e,t){return(await this._getResponse(e,t)).json()}async*_getPaginated(e,t=new URLSearchParams,r){let i=Number(t.get("offset"))||0;const a=Number(t.get("limit"))||100;for(;;){t.set("offset",String(i)),t.set("limit",String(a));const s=`${this.apiUrl}${e}?${t}`,o=await this.caller.call(async()=>{const l=await this._fetch(s,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(l,`fetch ${e}`),l}),u=r?r(await o.json()):await o.json();if(u.length===0||(yield u,u.length<a))break;i+=u.length}}async*_getCursorPaginatedList(e,t=null,r="POST",i="runs"){const a=t?{...t}:{};for(;;){const s=JSON.stringify(a),u=await(await this.caller.call(async()=>{const c=await this._fetch(`${this.apiUrl}${e}`,{method:r,headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await fe(c,`fetch ${e}`),c})).json();if(!u||!u[i])break;yield u[i];const l=u.cursors;if(!l||!l.next)break;a.cursor=l.next}}_shouldSample(){return this.tracingSampleRate===void 0?!0:Math.random()<this.tracingSampleRate}_filterForSampling(e,t=!1){if(this.tracingSampleRate===void 0)return e;if(t){const r=[];for(const i of e)this.filteredPostUuids.has(i.trace_id)?i.id===i.trace_id&&this.filteredPostUuids.delete(i.trace_id):r.push(i);return r}else{const r=[];for(const i of e){const a=i.trace_id??i.id;this.filteredPostUuids.has(a)||(i.id===a?this._shouldSample()?r.push(i):this.filteredPostUuids.add(a):r.push(i))}return r}}async _getBatchSizeLimitBytes(){const e=await this._ensureServerInfo();return this.batchSizeBytesLimit??e.batch_ingest_config?.size_limit_bytes??iy}async _getBatchSizeLimit(){const e=await this._ensureServerInfo();return this.batchSizeLimit??e.batch_ingest_config?.size_limit??sy}async _getDatasetExamplesMultiPartSupport(){return(await this._ensureServerInfo()).instance_flags?.dataset_examples_multipart_enabled??!1}drainAutoBatchQueue({batchSizeLimitBytes:e,batchSizeLimit:t}){const r=[];for(;this.autoBatchQueue.items.length>0;){const[i,a]=this.autoBatchQueue.pop({upToSizeBytes:e,upToSize:t});if(!i.length){a();break}const s=i.reduce((l,c)=>{const h=c.apiUrl??this.apiUrl,f=c.apiKey??this.apiKey,p=c.apiKey===this.apiKey&&c.apiUrl===this.apiUrl?"default":`${h}|${f}`;return l[p]||(l[p]=[]),l[p].push(c),l},{}),o=[];for(const[l,c]of Object.entries(s)){const h=this._processBatch(c,{apiUrl:l==="default"?void 0:l.split("|")[0],apiKey:l==="default"?void 0:l.split("|")[1]});o.push(h)}const u=Promise.all(o).finally(a);r.push(u)}return Promise.all(r)}async _processBatch(e,t){if(e.length)try{if(this.langSmithToOTELTranslator!==void 0)this._sendBatchToOTELTranslator(e);else{const r={runCreates:e.filter(a=>a.action==="create").map(a=>a.item),runUpdates:e.filter(a=>a.action==="update").map(a=>a.item)},i=await this._ensureServerInfo();if(i?.batch_ingest_config?.use_multipart_endpoint){const a=i?.instance_flags?.gzip_body_enabled;await this.multipartIngestRuns(r,{...t,useGzip:a})}else await this.batchIngestRuns(r,t)}}catch(r){console.error("Error exporting batch:",r)}}_sendBatchToOTELTranslator(e){if(this.langSmithToOTELTranslator!==void 0){const t=new Map,r=[];for(const i of e)i.item.id&&i.otelContext&&(t.set(i.item.id,i.otelContext),i.action==="create"?r.push({operation:"post",id:i.item.id,trace_id:i.item.trace_id??i.item.id,run:i.item}):r.push({operation:"patch",id:i.item.id,trace_id:i.item.trace_id??i.item.id,run:i.item}));this.langSmithToOTELTranslator.exportBatch(r,t)}}async processRunOperation(e){clearTimeout(this.autoBatchTimeout),this.autoBatchTimeout=void 0,e.item=pc(e.item,this.cachedLSEnvVarsForMetadata);const t=this.autoBatchQueue.push(e);if(this.manualFlushMode)return t;const r=await this._getBatchSizeLimitBytes(),i=await this._getBatchSizeLimit();return(this.autoBatchQueue.sizeBytes>r||this.autoBatchQueue.items.length>i)&&this.drainAutoBatchQueue({batchSizeLimitBytes:r,batchSizeLimit:i}),this.autoBatchQueue.items.length>0&&(this.autoBatchTimeout=setTimeout(()=>{this.autoBatchTimeout=void 0,this.drainAutoBatchQueue({batchSizeLimitBytes:r,batchSizeLimit:i})},this.autoBatchAggregationDelayMs)),t}async _getServerInfo(){const t=await(await this.caller.call(async()=>{const r=await this._fetch(`${this.apiUrl}/info`,{method:"GET",headers:{Accept:"application/json"},signal:AbortSignal.timeout(ay),...this.fetchOptions});return await fe(r,"get server info"),r})).json();return this.debug&&console.log(`
|
|
49
|
+
=== LangSmith Server Configuration ===
|
|
50
|
+
`+JSON.stringify(t,null,2)+`
|
|
51
|
+
`),t}async _ensureServerInfo(){return this._getServerInfoPromise===void 0&&(this._getServerInfoPromise=(async()=>{if(this._serverInfo===void 0)try{this._serverInfo=await this._getServerInfo()}catch(e){console.warn(`[LANGSMITH]: Failed to fetch info on supported operations. Falling back to batch operations and default limits. Info: ${e.status??"Unspecified status code"} ${e.message}`)}return this._serverInfo??{}})()),this._getServerInfoPromise.then(e=>(this._serverInfo===void 0&&(this._getServerInfoPromise=void 0),e))}async _getSettings(){return this.settings||(this.settings=this._get("/settings")),await this.settings}async flush(){const e=await this._getBatchSizeLimitBytes(),t=await this._getBatchSizeLimit();await this.drainAutoBatchQueue({batchSizeLimitBytes:e,batchSizeLimit:t})}_cloneCurrentOTELContext(){const e=ud(),t=Fg();if(this.langSmithToOTELTranslator!==void 0){const r=e.getActiveSpan();if(r)return e.setSpan(t.active(),r)}}async createRun(e,t){if(!this._filterForSampling([e]).length)return;const r={...this.headers,"Content-Type":"application/json"},i=e.project_name;delete e.project_name;const a=await this.prepareRunCreateOrUpdateInputs({session_name:i,...e,start_time:e.start_time??Date.now()});if(this.autoBatchTracing&&a.trace_id!==void 0&&a.dotted_order!==void 0){const u=this._cloneCurrentOTELContext();this.processRunOperation({action:"create",item:a,otelContext:u,apiKey:t?.apiKey,apiUrl:t?.apiUrl}).catch(console.error);return}const s=pc(a,this.cachedLSEnvVarsForMetadata);t?.apiKey!==void 0&&(r["x-api-key"]=t.apiKey),t?.workspaceId!==void 0&&(r["x-tenant-id"]=t.workspaceId);const o=Ge(s,`Creating run with id: ${s.id}`);await this.caller.call(async()=>{const u=await this._fetch(`${t?.apiUrl??this.apiUrl}/runs`,{method:"POST",headers:r,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await fe(u,"create run",!0),u})}async batchIngestRuns({runCreates:e,runUpdates:t},r){if(e===void 0&&t===void 0)return;let i=await Promise.all(e?.map(u=>this.prepareRunCreateOrUpdateInputs(u))??[]),a=await Promise.all(t?.map(u=>this.prepareRunCreateOrUpdateInputs(u))??[]);if(i.length>0&&a.length>0){const u=i.reduce((c,h)=>(h.id&&(c[h.id]=h),c),{}),l=[];for(const c of a)c.id!==void 0&&u[c.id]?u[c.id]={...u[c.id],...c}:l.push(c);i=Object.values(u),a=l}const s={post:i,patch:a};if(!s.post.length&&!s.patch.length)return;const o={post:[],patch:[]};for(const u of["post","patch"]){const l=u,c=s[l].reverse();let h=c.pop();for(;h!==void 0;)o[l].push(h),h=c.pop()}if(o.post.length>0||o.patch.length>0){const u=o.post.map(l=>l.id).concat(o.patch.map(l=>l.id)).join(",");await this._postBatchIngestRuns(Ge(o,`Ingesting runs with ids: ${u}`),r)}}async _postBatchIngestRuns(e,t){const r={...this.headers,"Content-Type":"application/json",Accept:"application/json"};t?.apiKey!==void 0&&(r["x-api-key"]=t.apiKey),await this.batchIngestCaller.call(async()=>{const i=await this._fetch(`${t?.apiUrl??this.apiUrl}/runs/batch`,{method:"POST",headers:r,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:e});return await fe(i,"batch create run",!0),i})}async multipartIngestRuns({runCreates:e,runUpdates:t},r){if(e===void 0&&t===void 0)return;const i={};let a=[];for(const h of e??[]){const f=await this.prepareRunCreateOrUpdateInputs(h);f.id!==void 0&&f.attachments!==void 0&&(i[f.id]=f.attachments),delete f.attachments,a.push(f)}let s=[];for(const h of t??[])s.push(await this.prepareRunCreateOrUpdateInputs(h));if(a.find(h=>h.trace_id===void 0||h.dotted_order===void 0)!==void 0)throw new Error('Multipart ingest requires "trace_id" and "dotted_order" to be set when creating a run');if(s.find(h=>h.trace_id===void 0||h.dotted_order===void 0)!==void 0)throw new Error('Multipart ingest requires "trace_id" and "dotted_order" to be set when updating a run');if(a.length>0&&s.length>0){const h=a.reduce((_,p)=>(p.id&&(_[p.id]=p),_),{}),f=[];for(const _ of s)_.id!==void 0&&h[_.id]?h[_.id]={...h[_.id],..._}:f.push(_);a=Object.values(h),s=f}if(a.length===0&&s.length===0)return;const l=[],c=[];for(const[h,f]of[["post",a],["patch",s]])for(const _ of f){const{inputs:p,outputs:b,events:w,extra:m,error:g,serialized:v,attachments:E,...O}=_,C={inputs:p,outputs:b,events:w,extra:m,error:g,serialized:v},R=Ge(O,`Serializing for multipart ingestion of run with id: ${O.id}`);c.push({name:`${h}.${O.id}`,payload:new Blob([R],{type:`application/json; length=${R.length}`})});for(const[I,$]of Object.entries(C)){if($===void 0)continue;const M=Ge($,`Serializing ${I} for multipart ingestion of run with id: ${O.id}`);c.push({name:`${h}.${O.id}.${I}`,payload:new Blob([M],{type:`application/json; length=${M.length}`})})}if(O.id!==void 0){const I=i[O.id];if(I){delete i[O.id];for(const[$,M]of Object.entries(I)){let z,B;if(Array.isArray(M)?[z,B]=M:(z=M.mimeType,B=M.data),$.includes(".")){console.warn(`Skipping attachment '${$}' for run ${O.id}: Invalid attachment name. Attachment names must not contain periods ('.'). Please rename the attachment and try again.`);continue}c.push({name:`attachment.${O.id}.${$}`,payload:new Blob([B],{type:`${z}; length=${B.byteLength}`})})}}}l.push(`trace=${O.trace_id},id=${O.id}`)}await this._sendMultipartRequest(c,l.join("; "),r)}async _createNodeFetchBody(e,t){const r=[];for(const s of e)r.push(new Blob([`--${t}\r
|
|
52
|
+
`])),r.push(new Blob([`Content-Disposition: form-data; name="${s.name}"\r
|
|
53
|
+
`,`Content-Type: ${s.payload.type}\r
|
|
54
|
+
\r
|
|
55
|
+
`])),r.push(s.payload),r.push(new Blob([`\r
|
|
56
|
+
`]));return r.push(new Blob([`--${t}--\r
|
|
57
|
+
`])),await new Blob(r).arrayBuffer()}async _createMultipartStream(e,t){const r=new TextEncoder;return new ReadableStream({async start(a){const s=async o=>{typeof o=="string"?a.enqueue(r.encode(o)):a.enqueue(o)};for(const o of e){await s(`--${t}\r
|
|
58
|
+
`),await s(`Content-Disposition: form-data; name="${o.name}"\r
|
|
59
|
+
`),await s(`Content-Type: ${o.payload.type}\r
|
|
60
|
+
\r
|
|
61
|
+
`);const l=o.payload.stream().getReader();try{let c;for(;!(c=await l.read()).done;)a.enqueue(c.value)}finally{l.releaseLock()}await s(`\r
|
|
62
|
+
`)}await s(`--${t}--\r
|
|
63
|
+
`),a.close()}})}async _sendMultipartRequest(e,t,r){const i="----LangSmithFormBoundary"+Math.random().toString(36).slice(2),a=Og(),s=()=>this._createNodeFetchBody(e,i),o=()=>this._createMultipartStream(e,i),u=async l=>this.batchIngestCaller.call(async()=>{const c=await l(),h={...this.headers,"Content-Type":`multipart/form-data; boundary=${i}`};r?.apiKey!==void 0&&(h["x-api-key"]=r.apiKey);let f=c;r?.useGzip&&typeof c=="object"&&"pipeThrough"in c&&(f=c.pipeThrough(new CompressionStream("gzip")),h["Content-Encoding"]="gzip");const _=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs/multipart`,{method:"POST",headers:h,body:f,duplex:"half",signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(_,"Failed to send multipart request",!0),_});try{let l,c=!1;!a&&!this.multipartStreamingDisabled&&id()!=="bun"?(c=!0,l=await u(o)):l=await u(s),(!this.multipartStreamingDisabled||c)&&l.status===422&&(r?.apiUrl??this.apiUrl)!==gc&&(console.warn(`Streaming multipart upload to ${r?.apiUrl??this.apiUrl}/runs/multipart failed. This usually means the host does not support chunked uploads. Retrying with a buffered upload for operation "${t}".`),this.multipartStreamingDisabled=!0,l=await u(s))}catch(l){console.warn(`${l.message.trim()}
|
|
64
|
+
|
|
65
|
+
Context: ${t}`)}}async updateRun(e,t,r){pe(e),t.inputs&&(t.inputs=await this.processInputs(t.inputs)),t.outputs&&(t.outputs=await this.processOutputs(t.outputs));const i={...t,id:e};if(!this._filterForSampling([i],!0).length)return;if(this.autoBatchTracing&&i.trace_id!==void 0&&i.dotted_order!==void 0){const o=this._cloneCurrentOTELContext();if(t.end_time!==void 0&&i.parent_run_id===void 0&&this.blockOnRootRunFinalization&&!this.manualFlushMode){await this.processRunOperation({action:"update",item:i,otelContext:o,apiKey:r?.apiKey,apiUrl:r?.apiUrl}).catch(console.error);return}else this.processRunOperation({action:"update",item:i,otelContext:o,apiKey:r?.apiKey,apiUrl:r?.apiUrl}).catch(console.error);return}const a={...this.headers,"Content-Type":"application/json"};r?.apiKey!==void 0&&(a["x-api-key"]=r.apiKey),r?.workspaceId!==void 0&&(a["x-tenant-id"]=r.workspaceId);const s=Ge(t,`Serializing payload to update run with id: ${e}`);await this.caller.call(async()=>{const o=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs/${e}`,{method:"PATCH",headers:a,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await fe(o,"update run",!0),o})}async readRun(e,{loadChildRuns:t}={loadChildRuns:!1}){pe(e);let r=await this._get(`/runs/${e}`);return t&&(r=await this._loadChildRuns(r)),r}async getRunUrl({runId:e,run:t,projectOpts:r}){if(t!==void 0){let i;t.session_id?i=t.session_id:r?.projectName?i=(await this.readProject({projectName:r?.projectName})).id:r?.projectId?i=r?.projectId:i=(await this.readProject({projectName:ze("PROJECT")||"default"})).id;const a=await this._getTenantId();return`${this.getHostUrl()}/o/${a}/projects/p/${i}/r/${t.id}?poll=true`}else if(e!==void 0){const i=await this.readRun(e);if(!i.app_path)throw new Error(`Run ${e} has no app_path`);return`${this.getHostUrl()}${i.app_path}`}else throw new Error("Must provide either runId or run")}async _loadChildRuns(e){const t=await ty(this.listRuns({isRoot:!1,projectId:e.session_id,traceId:e.trace_id})),r={},i={};t.sort((a,s)=>(a?.dotted_order??"").localeCompare(s?.dotted_order??""));for(const a of t){if(a.parent_run_id===null||a.parent_run_id===void 0)throw new Error(`Child run ${a.id} has no parent`);a.dotted_order?.startsWith(e.dotted_order??"")&&a.id!==e.id&&(a.parent_run_id in r||(r[a.parent_run_id]=[]),r[a.parent_run_id].push(a),i[a.id]=a)}e.child_runs=r[e.id]||[];for(const a in r)a!==e.id&&(i[a].child_runs=r[a]);return e}async*listRuns(e){const{projectId:t,projectName:r,parentRunId:i,traceId:a,referenceExampleId:s,startTime:o,executionOrder:u,isRoot:l,runType:c,error:h,id:f,query:_,filter:p,traceFilter:b,treeFilter:w,limit:m,select:g,order:v}=e;let E=[];if(t&&(E=Array.isArray(t)?t:[t]),r){const I=Array.isArray(r)?r:[r],$=await Promise.all(I.map(M=>this.readProject({projectName:M}).then(z=>z.id)));E.push(...$)}const O=["app_path","completion_cost","completion_tokens","dotted_order","end_time","error","events","extra","feedback_stats","first_token_time","id","inputs","name","outputs","parent_run_id","parent_run_ids","prompt_cost","prompt_tokens","reference_example_id","run_type","session_id","start_time","status","tags","total_cost","total_tokens","trace_id"],C={session:E.length?E:null,run_type:c,reference_example:s,query:_,filter:p,trace_filter:b,tree_filter:w,execution_order:u,parent_run:i,start_time:o?o.toISOString():null,error:h,id:f,limit:m,trace:a,select:g||O,is_root:l,order:v};let R=0;for await(const I of this._getCursorPaginatedList("/runs/query",C))if(m){if(R>=m)break;if(I.length+R>m){yield*I.slice(0,m-R);break}R+=I.length,yield*I}else yield*I}async*listGroupRuns(e){const{projectId:t,projectName:r,groupBy:i,filter:a,startTime:s,endTime:o,limit:u,offset:l}=e,h={session_id:t||(await this.readProject({projectName:r})).id,group_by:i,filter:a,start_time:s?s.toISOString():null,end_time:o?o.toISOString():null,limit:Number(u)||100};let f=Number(l)||0;const _="/runs/group",p=`${this.apiUrl}${_}`;for(;;){const b={...h,offset:f},w=Object.fromEntries(Object.entries(b).filter(([C,R])=>R!==void 0)),m=JSON.stringify(w),v=await(await this.caller.call(async()=>{const C=await this._fetch(p,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:m});return await fe(C,`Failed to fetch ${_}`),C})).json(),{groups:E,total:O}=v;if(E.length===0)break;for(const C of E)yield C;if(f+=E.length,f>=O)break}}async getRunStats({id:e,trace:t,parentRun:r,runType:i,projectNames:a,projectIds:s,referenceExampleIds:o,startTime:u,endTime:l,error:c,query:h,filter:f,traceFilter:_,treeFilter:p,isRoot:b,dataSourceType:w}){let m=s||[];a&&(m=[...s||[],...await Promise.all(a.map(R=>this.readProject({projectName:R}).then(I=>I.id)))]);const v=Object.fromEntries(Object.entries({id:e,trace:t,parent_run:r,run_type:i,session:m,reference_example:o,start_time:u,end_time:l,error:c,query:h,filter:f,trace_filter:_,tree_filter:p,is_root:b,data_source_type:w}).filter(([R,I])=>I!==void 0)),E=JSON.stringify(v);return await(await this.caller.call(async()=>{const R=await this._fetch(`${this.apiUrl}/runs/stats`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:E});return await fe(R,"get run stats"),R})).json()}async shareRun(e,{shareId:t}={}){const r={run_id:e,share_token:t||Le()};pe(e);const i=JSON.stringify(r),s=await(await this.caller.call(async()=>{const o=await this._fetch(`${this.apiUrl}/runs/${e}/share`,{method:"PUT",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await fe(o,"share run"),o})).json();if(s===null||!("share_token"in s))throw new Error("Invalid response from server");return`${this.getHostUrl()}/public/${s.share_token}/r`}async unshareRun(e){pe(e),await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/runs/${e}/share`,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(t,"unshare run",!0),t})}async readRunSharedLink(e){pe(e);const r=await(await this.caller.call(async()=>{const i=await this._fetch(`${this.apiUrl}/runs/${e}/share`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(i,"read run shared link"),i})).json();if(!(r===null||!("share_token"in r)))return`${this.getHostUrl()}/public/${r.share_token}/r`}async listSharedRuns(e,{runIds:t}={}){const r=new URLSearchParams({share_token:e});if(t!==void 0)for(const s of t)r.append("id",s);return pe(e),await(await this.caller.call(async()=>{const s=await this._fetch(`${this.apiUrl}/public/${e}/runs${r}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(s,"list shared runs"),s})).json()}async readDatasetSharedSchema(e,t){if(!e&&!t)throw new Error("Either datasetId or datasetName must be given");e||(e=(await this.readDataset({datasetName:t})).id),pe(e);const i=await(await this.caller.call(async()=>{const a=await this._fetch(`${this.apiUrl}/datasets/${e}/share`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(a,"read dataset shared schema"),a})).json();return i.url=`${this.getHostUrl()}/public/${i.share_token}/d`,i}async shareDataset(e,t){if(!e&&!t)throw new Error("Either datasetId or datasetName must be given");e||(e=(await this.readDataset({datasetName:t})).id);const r={dataset_id:e};pe(e);const i=JSON.stringify(r),s=await(await this.caller.call(async()=>{const o=await this._fetch(`${this.apiUrl}/datasets/${e}/share`,{method:"PUT",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await fe(o,"share dataset"),o})).json();return s.url=`${this.getHostUrl()}/public/${s.share_token}/d`,s}async unshareDataset(e){pe(e),await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/datasets/${e}/share`,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(t,"unshare dataset",!0),t})}async readSharedDataset(e){return pe(e),await(await this.caller.call(async()=>{const i=await this._fetch(`${this.apiUrl}/public/${e}/datasets`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(i,"read shared dataset"),i})).json()}async listSharedExamples(e,t){const r={};t?.exampleIds&&(r.id=t.exampleIds);const i=new URLSearchParams;Object.entries(r).forEach(([o,u])=>{Array.isArray(u)?u.forEach(l=>i.append(o,l)):i.append(o,u)});const a=await this.caller.call(async()=>{const o=await this._fetch(`${this.apiUrl}/public/${e}/examples?${i.toString()}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(o,"list shared examples"),o}),s=await a.json();if(!a.ok)throw"detail"in s?new Error(`Failed to list shared examples.
|
|
66
|
+
Status: ${a.status}
|
|
67
|
+
Message: ${Array.isArray(s.detail)?s.detail.join(`
|
|
68
|
+
`):"Unspecified error"}`):new Error(`Failed to list shared examples: ${a.status} ${a.statusText}`);return s.map(o=>({...o,_hostUrl:this.getHostUrl()}))}async createProject({projectName:e,description:t=null,metadata:r=null,upsert:i=!1,projectExtra:a=null,referenceDatasetId:s=null}){const o=i?"?upsert=true":"",u=`${this.apiUrl}/sessions${o}`,l=a||{};r&&(l.metadata=r);const c={name:e,extra:l,description:t};s!==null&&(c.reference_dataset_id=s);const h=JSON.stringify(c);return await(await this.caller.call(async()=>{const p=await this._fetch(u,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:h});return await fe(p,"create project"),p})).json()}async updateProject(e,{name:t=null,description:r=null,metadata:i=null,projectExtra:a=null,endTime:s=null}){const o=`${this.apiUrl}/sessions/${e}`;let u=a;i&&(u={...u||{},metadata:i});const l=JSON.stringify({name:t,extra:u,description:r,end_time:s?new Date(s).toISOString():null});return await(await this.caller.call(async()=>{const f=await this._fetch(o,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:l});return await fe(f,"update project"),f})).json()}async hasProject({projectId:e,projectName:t}){let r="/sessions";const i=new URLSearchParams;if(e!==void 0&&t!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(e!==void 0)pe(e),r+=`/${e}`;else if(t!==void 0)i.append("name",t);else throw new Error("Must provide projectName or projectId");const a=await this.caller.call(async()=>{const s=await this._fetch(`${this.apiUrl}${r}?${i}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(s,"has project"),s});try{const s=await a.json();return a.ok?Array.isArray(s)?s.length>0:!0:!1}catch{return!1}}async readProject({projectId:e,projectName:t,includeStats:r}){let i="/sessions";const a=new URLSearchParams;if(e!==void 0&&t!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(e!==void 0)pe(e),i+=`/${e}`;else if(t!==void 0)a.append("name",t);else throw new Error("Must provide projectName or projectId");r!==void 0&&a.append("include_stats",r.toString());const s=await this._get(i,a);let o;if(Array.isArray(s)){if(s.length===0)throw new Error(`Project[id=${e}, name=${t}] not found`);o=s[0]}else o=s;return o}async getProjectUrl({projectId:e,projectName:t}){if(e===void 0&&t===void 0)throw new Error("Must provide either projectName or projectId");const r=await this.readProject({projectId:e,projectName:t}),i=await this._getTenantId();return`${this.getHostUrl()}/o/${i}/projects/p/${r.id}`}async getDatasetUrl({datasetId:e,datasetName:t}){if(e===void 0&&t===void 0)throw new Error("Must provide either datasetName or datasetId");const r=await this.readDataset({datasetId:e,datasetName:t}),i=await this._getTenantId();return`${this.getHostUrl()}/o/${i}/datasets/${r.id}`}async _getTenantId(){if(this._tenantId!==null)return this._tenantId;const e=new URLSearchParams({limit:"1"});for await(const t of this._getPaginated("/sessions",e))return this._tenantId=t[0].tenant_id,t[0].tenant_id;throw new Error("No projects found to resolve tenant.")}async*listProjects({projectIds:e,name:t,nameContains:r,referenceDatasetId:i,referenceDatasetName:a,includeStats:s,datasetVersion:o,referenceFree:u,metadata:l}={}){const c=new URLSearchParams;if(e!==void 0)for(const h of e)c.append("id",h);if(t!==void 0&&c.append("name",t),r!==void 0&&c.append("name_contains",r),i!==void 0)c.append("reference_dataset",i);else if(a!==void 0){const h=await this.readDataset({datasetName:a});c.append("reference_dataset",h.id)}s!==void 0&&c.append("include_stats",s.toString()),o!==void 0&&c.append("dataset_version",o),u!==void 0&&c.append("reference_free",u.toString()),l!==void 0&&c.append("metadata",JSON.stringify(l));for await(const h of this._getPaginated("/sessions",c))yield*h}async deleteProject({projectId:e,projectName:t}){let r;if(e===void 0&&t===void 0)throw new Error("Must provide projectName or projectId");if(e!==void 0&&t!==void 0)throw new Error("Must provide either projectName or projectId, not both");e===void 0?r=(await this.readProject({projectName:t})).id:r=e,pe(r),await this.caller.call(async()=>{const i=await this._fetch(`${this.apiUrl}/sessions/${r}`,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(i,`delete session ${r} (${t})`,!0),i})}async uploadCsv({csvFile:e,fileName:t,inputKeys:r,outputKeys:i,description:a,dataType:s,name:o}){const u=`${this.apiUrl}/datasets/upload`,l=new FormData;return l.append("file",e,t),r.forEach(f=>{l.append("input_keys",f)}),i.forEach(f=>{l.append("output_keys",f)}),a&&l.append("description",a),s&&l.append("data_type",s),o&&l.append("name",o),await(await this.caller.call(async()=>{const f=await this._fetch(u,{method:"POST",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:l});return await fe(f,"upload CSV"),f})).json()}async createDataset(e,{description:t,dataType:r,inputsSchema:i,outputsSchema:a,metadata:s}={}){const o={name:e,description:t,extra:s?{metadata:s}:void 0};r&&(o.data_type=r),i&&(o.inputs_schema_definition=i),a&&(o.outputs_schema_definition=a);const u=JSON.stringify(o);return await(await this.caller.call(async()=>{const h=await this._fetch(`${this.apiUrl}/datasets`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await fe(h,"create dataset"),h})).json()}async readDataset({datasetId:e,datasetName:t}){let r="/datasets";const i=new URLSearchParams({limit:"1"});if(e&&t)throw new Error("Must provide either datasetName or datasetId, not both");if(e)pe(e),r+=`/${e}`;else if(t)i.append("name",t);else throw new Error("Must provide datasetName or datasetId");const a=await this._get(r,i);let s;if(Array.isArray(a)){if(a.length===0)throw new Error(`Dataset[id=${e}, name=${t}] not found`);s=a[0]}else s=a;return s}async hasDataset({datasetId:e,datasetName:t}){try{return await this.readDataset({datasetId:e,datasetName:t}),!0}catch(r){if(r instanceof Error&&r.message.toLocaleLowerCase().includes("not found"))return!1;throw r}}async diffDatasetVersions({datasetId:e,datasetName:t,fromVersion:r,toVersion:i}){let a=e;if(a===void 0&&t===void 0)throw new Error("Must provide either datasetName or datasetId");if(a!==void 0&&t!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");a===void 0&&(a=(await this.readDataset({datasetName:t})).id);const s=new URLSearchParams({from_version:typeof r=="string"?r:r.toISOString(),to_version:typeof i=="string"?i:i.toISOString()});return await this._get(`/datasets/${a}/versions/diff`,s)}async readDatasetOpenaiFinetuning({datasetId:e,datasetName:t}){const r="/datasets";if(e===void 0)if(t!==void 0)e=(await this.readDataset({datasetName:t})).id;else throw new Error("Must provide either datasetName or datasetId");return(await(await this._getResponse(`${r}/${e}/openai_ft`)).text()).trim().split(`
|
|
69
|
+
`).map(o=>JSON.parse(o))}async*listDatasets({limit:e=100,offset:t=0,datasetIds:r,datasetName:i,datasetNameContains:a,metadata:s}={}){const o="/datasets",u=new URLSearchParams({limit:e.toString(),offset:t.toString()});if(r!==void 0)for(const l of r)u.append("id",l);i!==void 0&&u.append("name",i),a!==void 0&&u.append("name_contains",a),s!==void 0&&u.append("metadata",JSON.stringify(s));for await(const l of this._getPaginated(o,u))yield*l}async updateDataset(e){const{datasetId:t,datasetName:r,...i}=e;if(!t&&!r)throw new Error("Must provide either datasetName or datasetId");const a=t??(await this.readDataset({datasetName:r})).id;pe(a);const s=JSON.stringify(i);return await(await this.caller.call(async()=>{const u=await this._fetch(`${this.apiUrl}/datasets/${a}`,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await fe(u,"update dataset"),u})).json()}async updateDatasetTag(e){const{datasetId:t,datasetName:r,asOf:i,tag:a}=e;if(!t&&!r)throw new Error("Must provide either datasetName or datasetId");const s=t??(await this.readDataset({datasetName:r})).id;pe(s);const o=JSON.stringify({as_of:typeof i=="string"?i:i.toISOString(),tag:a});await this.caller.call(async()=>{const u=await this._fetch(`${this.apiUrl}/datasets/${s}/tags`,{method:"PUT",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await fe(u,"update dataset tags",!0),u})}async deleteDataset({datasetId:e,datasetName:t}){let r="/datasets",i=e;if(e!==void 0&&t!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(t!==void 0&&(i=(await this.readDataset({datasetName:t})).id),i!==void 0)pe(i),r+=`/${i}`;else throw new Error("Must provide datasetName or datasetId");await this.caller.call(async()=>{const a=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(a,`delete ${r}`,!0),a})}async indexDataset({datasetId:e,datasetName:t,tag:r}){let i=e;if(!i&&!t)throw new Error("Must provide either datasetName or datasetId");if(i&&t)throw new Error("Must provide either datasetName or datasetId, not both");i||(i=(await this.readDataset({datasetName:t})).id),pe(i);const s=JSON.stringify({tag:r});await(await this.caller.call(async()=>{const u=await this._fetch(`${this.apiUrl}/datasets/${i}/index`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await fe(u,"index dataset"),u})).json()}async similarExamples(e,t,r,{filter:i}={}){const a={limit:r,inputs:e};i!==void 0&&(a.filter=i),pe(t);const s=JSON.stringify(a);return(await(await this.caller.call(async()=>{const l=await this._fetch(`${this.apiUrl}/datasets/${t}/search`,{headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,method:"POST",body:s});return await fe(l,"fetch similar examples"),l})).json()).examples}async createExample(e,t,r){if(yc(e)&&(t!==void 0||r!==void 0))throw new Error("Cannot provide outputs or options when using ExampleCreate object");let i=t?r?.datasetId:e.dataset_id;const a=t?r?.datasetName:e.dataset_name;if(i===void 0&&a===void 0)throw new Error("Must provide either datasetName or datasetId");if(i!==void 0&&a!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");i===void 0&&(i=(await this.readDataset({datasetName:a})).id);const s=(t?r?.createdAt:e.created_at)||new Date;let o;yc(e)?o=e:o={inputs:e,outputs:t,created_at:s?.toISOString(),id:r?.exampleId,metadata:r?.metadata,split:r?.split,source_run_id:r?.sourceRunId,use_source_run_io:r?.useSourceRunIO,use_source_run_attachments:r?.useSourceRunAttachments,attachments:r?.attachments};const u=await this._uploadExamplesMultipart(i,[o]);return await this.readExample(u.example_ids?.[0]??Le())}async createExamples(e){if(Array.isArray(e)){if(e.length===0)return[];const g=e;let v=g[0].dataset_id;const E=g[0].dataset_name;if(v===void 0&&E===void 0)throw new Error("Must provide either datasetName or datasetId");if(v!==void 0&&E!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");v===void 0&&(v=(await this.readDataset({datasetName:E})).id);const O=await this._uploadExamplesMultipart(v,g);return await Promise.all(O.example_ids.map(R=>this.readExample(R)))}const{inputs:t,outputs:r,metadata:i,splits:a,sourceRunIds:s,useSourceRunIOs:o,useSourceRunAttachments:u,attachments:l,exampleIds:c,datasetId:h,datasetName:f}=e;if(t===void 0)throw new Error("Must provide inputs when using legacy parameters");let _=h;const p=f;if(_===void 0&&p===void 0)throw new Error("Must provide either datasetName or datasetId");if(_!==void 0&&p!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");_===void 0&&(_=(await this.readDataset({datasetName:p})).id);const b=t.map((g,v)=>({dataset_id:_,inputs:g,outputs:r?.[v],metadata:i?.[v],split:a?.[v],id:c?.[v],attachments:l?.[v],source_run_id:s?.[v],use_source_run_io:o?.[v],use_source_run_attachments:u?.[v]})),w=await this._uploadExamplesMultipart(_,b);return await Promise.all(w.example_ids.map(g=>this.readExample(g)))}async createLLMExample(e,t,r){return this.createExample({input:e},{output:t},r)}async createChatExample(e,t,r){const i=e.map(s=>cc(s)?fc(s):s),a=cc(t)?fc(t):t;return this.createExample({input:i},{output:a},r)}async readExample(e){pe(e);const t=`/examples/${e}`,r=await this._get(t),{attachment_urls:i,...a}=r,s=a;return i&&(s.attachments=Object.entries(i).reduce((o,[u,l])=>(o[u.slice(11)]={presigned_url:l.presigned_url,mime_type:l.mime_type},o),{})),s}async*listExamples({datasetId:e,datasetName:t,exampleIds:r,asOf:i,splits:a,inlineS3Urls:s,metadata:o,limit:u,offset:l,filter:c,includeAttachments:h}={}){let f;if(e!==void 0&&t!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(e!==void 0)f=e;else if(t!==void 0)f=(await this.readDataset({datasetName:t})).id;else throw new Error("Must provide a datasetName or datasetId");const _=new URLSearchParams({dataset:f}),p=i?typeof i=="string"?i:i?.toISOString():void 0;p&&_.append("as_of",p);const b=s??!0;if(_.append("inline_s3_urls",b.toString()),r!==void 0)for(const m of r)_.append("id",m);if(a!==void 0)for(const m of a)_.append("splits",m);if(o!==void 0){const m=JSON.stringify(o);_.append("metadata",m)}u!==void 0&&_.append("limit",u.toString()),l!==void 0&&_.append("offset",l.toString()),c!==void 0&&_.append("filter",c),h===!0&&["attachment_urls","outputs","metadata"].forEach(m=>_.append("select",m));let w=0;for await(const m of this._getPaginated("/examples",_)){for(const g of m){const{attachment_urls:v,...E}=g,O=E;v&&(O.attachments=Object.entries(v).reduce((C,[R,I])=>(C[R.slice(11)]={presigned_url:I.presigned_url,mime_type:I.mime_type||void 0},C),{})),yield O,w++}if(u!==void 0&&w>=u)break}}async deleteExample(e){pe(e);const t=`/examples/${e}`;await this.caller.call(async()=>{const r=await this._fetch(this.apiUrl+t,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(r,`delete ${t}`,!0),r})}async updateExample(e,t){let r;t?r=e:r=e.id,pe(r);let i;t?i={id:r,...t}:i=e;let a;return i.dataset_id!==void 0?a=i.dataset_id:a=(await this.readExample(r)).dataset_id,this._updateExamplesMultipart(a,[i])}async updateExamples(e){let t;return e[0].dataset_id===void 0?t=(await this.readExample(e[0].id)).dataset_id:t=e[0].dataset_id,this._updateExamplesMultipart(t,e)}async readDatasetVersion({datasetId:e,datasetName:t,asOf:r,tag:i}){let a;if(e?a=e:a=(await this.readDataset({datasetName:t})).id,pe(a),r&&i||!r&&!i)throw new Error("Exactly one of asOf and tag must be specified.");const s=new URLSearchParams;return r!==void 0&&s.append("as_of",typeof r=="string"?r:r.toISOString()),i!==void 0&&s.append("tag",i),await(await this.caller.call(async()=>{const u=await this._fetch(`${this.apiUrl}/datasets/${a}/version?${s.toString()}`,{method:"GET",headers:{...this.headers},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(u,"read dataset version"),u})).json()}async listDatasetSplits({datasetId:e,datasetName:t,asOf:r}){let i;if(e===void 0&&t===void 0)throw new Error("Must provide dataset name or ID");if(e!==void 0&&t!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");e===void 0?i=(await this.readDataset({datasetName:t})).id:i=e,pe(i);const a=new URLSearchParams,s=r?typeof r=="string"?r:r?.toISOString():void 0;return s&&a.append("as_of",s),await this._get(`/datasets/${i}/splits`,a)}async updateDatasetSplits({datasetId:e,datasetName:t,splitName:r,exampleIds:i,remove:a=!1}){let s;if(e===void 0&&t===void 0)throw new Error("Must provide dataset name or ID");if(e!==void 0&&t!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");e===void 0?s=(await this.readDataset({datasetName:t})).id:s=e,pe(s);const o={split_name:r,examples:i.map(l=>(pe(l),l)),remove:a},u=JSON.stringify(o);await this.caller.call(async()=>{const l=await this._fetch(`${this.apiUrl}/datasets/${s}/splits`,{method:"PUT",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await fe(l,"update dataset splits",!0),l})}async evaluateRun(e,t,{sourceInfo:r,loadChildRuns:i,referenceExample:a}={loadChildRuns:!1}){ld("This method is deprecated and will be removed in future LangSmith versions, use `evaluate` from `langsmith/evaluation` instead.");let s;if(typeof e=="string")s=await this.readRun(e,{loadChildRuns:i});else if(typeof e=="object"&&"id"in e)s=e;else throw new Error(`Invalid run type: ${typeof e}`);s.reference_example_id!==null&&s.reference_example_id!==void 0&&(a=await this.readExample(s.reference_example_id));const o=await t.evaluateRun(s,a),[u,l]=await this._logEvaluationFeedback(o,s,r);return l[0]}async createFeedback(e,t,{score:r,value:i,correction:a,comment:s,sourceInfo:o,feedbackSourceType:u="api",sourceRunId:l,feedbackId:c,feedbackConfig:h,projectId:f,comparativeExperimentId:_}){if(!e&&!f)throw new Error("One of runId or projectId must be provided");if(e&&f)throw new Error("Only one of runId or projectId can be provided");const p={type:u??"api",metadata:o??{}};l!==void 0&&p?.metadata!==void 0&&!p.metadata.__run&&(p.metadata.__run={run_id:l}),p?.metadata!==void 0&&p.metadata.__run?.run_id!==void 0&&pe(p.metadata.__run.run_id);const b={id:c??Le(),run_id:e,key:t,score:mc(r),value:i,correction:a,comment:s,feedback_source:p,comparative_experiment_id:_,feedbackConfig:h,session_id:f},w=JSON.stringify(b),m=`${this.apiUrl}/feedback`;return await this.caller.call(async()=>{const g=await this._fetch(m,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:w});return await fe(g,"create feedback",!0),g}),b}async updateFeedback(e,{score:t,value:r,correction:i,comment:a}){const s={};t!=null&&(s.score=mc(t)),r!=null&&(s.value=r),i!=null&&(s.correction=i),a!=null&&(s.comment=a),pe(e);const o=JSON.stringify(s);await this.caller.call(async()=>{const u=await this._fetch(`${this.apiUrl}/feedback/${e}`,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await fe(u,"update feedback",!0),u})}async readFeedback(e){pe(e);const t=`/feedback/${e}`;return await this._get(t)}async deleteFeedback(e){pe(e);const t=`/feedback/${e}`;await this.caller.call(async()=>{const r=await this._fetch(this.apiUrl+t,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(r,`delete ${t}`,!0),r})}async*listFeedback({runIds:e,feedbackKeys:t,feedbackSourceTypes:r}={}){const i=new URLSearchParams;if(e)for(const a of e)pe(a),i.append("run",a);if(t)for(const a of t)i.append("key",a);if(r)for(const a of r)i.append("source",a);for await(const a of this._getPaginated("/feedback",i))yield*a}async createPresignedFeedbackToken(e,t,{expiration:r,feedbackConfig:i}={}){const a={run_id:e,feedback_key:t,feedback_config:i};r?typeof r=="string"?a.expires_at=r:(r?.hours||r?.minutes||r?.days)&&(a.expires_in=r):a.expires_in={hours:3};const s=JSON.stringify(a);return await(await this.caller.call(async()=>{const u=await this._fetch(`${this.apiUrl}/feedback/tokens`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await fe(u,"create presigned feedback token"),u})).json()}async createComparativeExperiment({name:e,experimentIds:t,referenceDatasetId:r,createdAt:i,description:a,metadata:s,id:o}){if(t.length===0)throw new Error("At least one experiment is required");if(r||(r=(await this.readProject({projectId:t[0]})).reference_dataset_id),!r==null)throw new Error("A reference dataset is required");const u={id:o,name:e,experiment_ids:t,reference_dataset_id:r,description:a,created_at:(i??new Date)?.toISOString(),extra:{}};s&&(u.extra.metadata=s);const l=JSON.stringify(u);return(await this.caller.call(async()=>{const h=await this._fetch(`${this.apiUrl}/datasets/comparative`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:l});return await fe(h,"create comparative experiment"),h})).json()}async*listPresignedFeedbackTokens(e){pe(e);const t=new URLSearchParams({run_id:e});for await(const r of this._getPaginated("/feedback/tokens",t))yield*r}_selectEvalResults(e){let t;return"results"in e?t=e.results:Array.isArray(e)?t=e:t=[e],t}async _logEvaluationFeedback(e,t,r){const i=this._selectEvalResults(e),a=[];for(const s of i){let o=r||{};s.evaluatorInfo&&(o={...s.evaluatorInfo,...o});let u=null;s.targetRunId?u=s.targetRunId:t&&(u=t.id),a.push(await this.createFeedback(u,s.key,{score:s.score,value:s.value,comment:s.comment,correction:s.correction,sourceInfo:o,sourceRunId:s.sourceRunId,feedbackConfig:s.feedbackConfig,feedbackSourceType:"model"}))}return[i,a]}async logEvaluationFeedback(e,t,r){const[i]=await this._logEvaluationFeedback(e,t,r);return i}async*listAnnotationQueues(e={}){const{queueIds:t,name:r,nameContains:i,limit:a}=e,s=new URLSearchParams;t&&t.forEach((u,l)=>{pe(u,`queueIds[${l}]`),s.append("ids",u)}),r&&s.append("name",r),i&&s.append("name_contains",i),s.append("limit",(a!==void 0?Math.min(a,100):100).toString());let o=0;for await(const u of this._getPaginated("/annotation-queues",s))if(yield*u,o++,a!==void 0&&o>=a)break}async createAnnotationQueue(e){const{name:t,description:r,queueId:i,rubricInstructions:a}=e,s={name:t,description:r,id:i||Le(),rubric_instructions:a},o=JSON.stringify(Object.fromEntries(Object.entries(s).filter(([l,c])=>c!==void 0)));return(await this.caller.call(async()=>{const l=await this._fetch(`${this.apiUrl}/annotation-queues`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await fe(l,"create annotation queue"),l})).json()}async readAnnotationQueue(e){return(await this.caller.call(async()=>{const r=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(e,"queueId")}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(r,"read annotation queue"),r})).json()}async updateAnnotationQueue(e,t){const{name:r,description:i,rubricInstructions:a}=t,s=JSON.stringify({name:r,description:i,rubric_instructions:a});await this.caller.call(async()=>{const o=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(e,"queueId")}`,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await fe(o,"update annotation queue",!0),o})}async deleteAnnotationQueue(e){await this.caller.call(async()=>{const t=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(e,"queueId")}`,{method:"DELETE",headers:{...this.headers,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(t,"delete annotation queue",!0),t})}async addRunsToAnnotationQueue(e,t){const r=JSON.stringify(t.map((i,a)=>pe(i,`runIds[${a}]`).toString()));await this.caller.call(async()=>{const i=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(e,"queueId")}/runs`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:r});return await fe(i,"add runs to annotation queue",!0),i})}async getRunFromAnnotationQueue(e,t){const r=`/annotation-queues/${pe(e,"queueId")}/run`;return(await this.caller.call(async()=>{const a=await this._fetch(`${this.apiUrl}${r}/${t}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(a,"get run from annotation queue"),a})).json()}async deleteRunFromAnnotationQueue(e,t){await this.caller.call(async()=>{const r=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(e,"queueId")}/runs/${pe(t,"queueRunId")}`,{method:"DELETE",headers:{...this.headers,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(r,"delete run from annotation queue",!0),r})}async getSizeFromAnnotationQueue(e){return(await this.caller.call(async()=>{const r=await this._fetch(`${this.apiUrl}/annotation-queues/${pe(e,"queueId")}/size`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(r,"get size from annotation queue"),r})).json()}async _currentTenantIsOwner(e){const t=await this._getSettings();return e=="-"||t.tenant_handle===e}async _ownerConflictError(e,t){const r=await this._getSettings();return new Error(`Cannot ${e} for another tenant.
|
|
70
|
+
|
|
71
|
+
Current tenant: ${r.tenant_handle}
|
|
72
|
+
|
|
73
|
+
Requested tenant: ${t}`)}async _getLatestCommitHash(e){const r=await(await this.caller.call(async()=>{const i=await this._fetch(`${this.apiUrl}/commits/${e}/?limit=1&offset=0`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(i,"get latest commit hash"),i})).json();if(r.commits.length!==0)return r.commits[0].commit_hash}async _likeOrUnlikePrompt(e,t){const[r,i,a]=Ot(e),s=JSON.stringify({like:t});return(await this.caller.call(async()=>{const u=await this._fetch(`${this.apiUrl}/likes/${r}/${i}`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await fe(u,`${t?"like":"unlike"} prompt`),u})).json()}async _getPromptUrl(e){const[t,r,i]=Ot(e);if(await this._currentTenantIsOwner(t)){const a=await this._getSettings();return i!=="latest"?`${this.getHostUrl()}/prompts/${r}/${i.substring(0,8)}?organizationId=${a.id}`:`${this.getHostUrl()}/prompts/${r}?organizationId=${a.id}`}else return i!=="latest"?`${this.getHostUrl()}/hub/${t}/${r}/${i.substring(0,8)}`:`${this.getHostUrl()}/hub/${t}/${r}`}async promptExists(e){return!!await this.getPrompt(e)}async likePrompt(e){return this._likeOrUnlikePrompt(e,!0)}async unlikePrompt(e){return this._likeOrUnlikePrompt(e,!1)}async*listCommits(e){for await(const t of this._getPaginated(`/commits/${e}/`,new URLSearchParams,r=>r.commits))yield*t}async*listPrompts(e){const t=new URLSearchParams;t.append("sort_field",e?.sortField??"updated_at"),t.append("sort_direction","desc"),t.append("is_archived",(!!e?.isArchived).toString()),e?.isPublic!==void 0&&t.append("is_public",e.isPublic.toString()),e?.query&&t.append("query",e.query);for await(const r of this._getPaginated("/repos",t,i=>i.repos))yield*r}async getPrompt(e){const[t,r,i]=Ot(e),s=await(await this.caller.call(async()=>{const o=await this._fetch(`${this.apiUrl}/repos/${t}/${r}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return o?.status===404?null:(await fe(o,"get prompt"),o)}))?.json();return s?.repo?s.repo:null}async createPrompt(e,t){const r=await this._getSettings();if(t?.isPublic&&!r.tenant_handle)throw new Error(`Cannot create a public prompt without first
|
|
74
|
+
|
|
75
|
+
creating a LangChain Hub handle.
|
|
76
|
+
You can add a handle by creating a public prompt at:
|
|
77
|
+
|
|
78
|
+
https://smith.langchain.com/prompts`);const[i,a,s]=Ot(e);if(!await this._currentTenantIsOwner(i))throw await this._ownerConflictError("create a prompt",i);const o={repo_handle:a,...t?.description&&{description:t.description},...t?.readme&&{readme:t.readme},...t?.tags&&{tags:t.tags},is_public:!!t?.isPublic},u=JSON.stringify(o),l=await this.caller.call(async()=>{const h=await this._fetch(`${this.apiUrl}/repos/`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await fe(h,"create prompt"),h}),{repo:c}=await l.json();return c}async createCommit(e,t,r){if(!await this.promptExists(e))throw new Error("Prompt does not exist, you must create it first.");const[i,a,s]=Ot(e),o=r?.parentCommitHash==="latest"||!r?.parentCommitHash?await this._getLatestCommitHash(`${i}/${a}`):r?.parentCommitHash,u={manifest:JSON.parse(JSON.stringify(t)),parent_commit:o},l=JSON.stringify(u),h=await(await this.caller.call(async()=>{const f=await this._fetch(`${this.apiUrl}/commits/${i}/${a}`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:l});return await fe(f,"create commit"),f})).json();return this._getPromptUrl(`${i}/${a}${h.commit_hash?`:${h.commit_hash}`:""}`)}async updateExamplesMultipart(e,t=[]){return this._updateExamplesMultipart(e,t)}async _updateExamplesMultipart(e,t=[]){if(!await this._getDatasetExamplesMultiPartSupport())throw new Error("Your LangSmith deployment does not allow using the multipart examples endpoint, please upgrade your deployment to the latest version.");const r=new FormData;for(const s of t){const o=s.id,u={...s.metadata&&{metadata:s.metadata},...s.split&&{split:s.split}},l=Ge(u,`Serializing body for example with id: ${o}`),c=new Blob([l],{type:"application/json"});if(r.append(o,c),s.inputs){const h=Ge(s.inputs,`Serializing inputs for example with id: ${o}`),f=new Blob([h],{type:"application/json"});r.append(`${o}.inputs`,f)}if(s.outputs){const h=Ge(s.outputs,`Serializing outputs whle updating example with id: ${o}`),f=new Blob([h],{type:"application/json"});r.append(`${o}.outputs`,f)}if(s.attachments)for(const[h,f]of Object.entries(s.attachments)){let _,p;Array.isArray(f)?[_,p]=f:(_=f.mimeType,p=f.data);const b=new Blob([p],{type:`${_}; length=${p.byteLength}`});r.append(`${o}.attachment.${h}`,b)}if(s.attachments_operations){const h=Ge(s.attachments_operations,`Serializing attachments while updating example with id: ${o}`),f=new Blob([h],{type:"application/json"});r.append(`${o}.attachments_operations`,f)}}const i=e??t[0]?.dataset_id;return(await this.caller.call(async()=>{const s=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${i}/examples`)}`,{method:"PATCH",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:r});return await fe(s,"update examples"),s})).json()}async uploadExamplesMultipart(e,t=[]){return this._uploadExamplesMultipart(e,t)}async _uploadExamplesMultipart(e,t=[]){if(!await this._getDatasetExamplesMultiPartSupport())throw new Error("Your LangSmith deployment does not allow using the multipart examples endpoint, please upgrade your deployment to the latest version.");const r=new FormData;for(const a of t){const s=(a.id??Le()).toString(),o={created_at:a.created_at,...a.metadata&&{metadata:a.metadata},...a.split&&{split:a.split},...a.source_run_id&&{source_run_id:a.source_run_id},...a.use_source_run_io&&{use_source_run_io:a.use_source_run_io},...a.use_source_run_attachments&&{use_source_run_attachments:a.use_source_run_attachments}},u=Ge(o,`Serializing body for uploaded example with id: ${s}`),l=new Blob([u],{type:"application/json"});if(r.append(s,l),a.inputs){const c=Ge(a.inputs,`Serializing inputs for uploaded example with id: ${s}`),h=new Blob([c],{type:"application/json"});r.append(`${s}.inputs`,h)}if(a.outputs){const c=Ge(a.outputs,`Serializing outputs for uploaded example with id: ${s}`),h=new Blob([c],{type:"application/json"});r.append(`${s}.outputs`,h)}if(a.attachments)for(const[c,h]of Object.entries(a.attachments)){let f,_;Array.isArray(h)?[f,_]=h:(f=h.mimeType,_=h.data);const p=new Blob([_],{type:`${f}; length=${_.byteLength}`});r.append(`${s}.attachment.${c}`,p)}}return(await this.caller.call(async()=>{const a=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${e}/examples`)}`,{method:"POST",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:r});return await fe(a,"upload examples"),a})).json()}async updatePrompt(e,t){if(!await this.promptExists(e))throw new Error("Prompt does not exist, you must create it first.");const[r,i]=Ot(e);if(!await this._currentTenantIsOwner(r))throw await this._ownerConflictError("update a prompt",r);const a={};if(t?.description!==void 0&&(a.description=t.description),t?.readme!==void 0&&(a.readme=t.readme),t?.tags!==void 0&&(a.tags=t.tags),t?.isPublic!==void 0&&(a.is_public=t.isPublic),t?.isArchived!==void 0&&(a.is_archived=t.isArchived),Object.keys(a).length===0)throw new Error("No valid update options provided");const s=JSON.stringify(a);return(await this.caller.call(async()=>{const u=await this._fetch(`${this.apiUrl}/repos/${r}/${i}`,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await fe(u,"update prompt"),u})).json()}async deletePrompt(e){if(!await this.promptExists(e))throw new Error("Prompt does not exist, you must create it first.");const[t,r,i]=Ot(e);if(!await this._currentTenantIsOwner(t))throw await this._ownerConflictError("delete a prompt",t);return(await this.caller.call(async()=>{const s=await this._fetch(`${this.apiUrl}/repos/${t}/${r}`,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(s,"delete prompt"),s})).json()}async pullPromptCommit(e,t){const[r,i,a]=Ot(e),o=await(await this.caller.call(async()=>{const u=await this._fetch(`${this.apiUrl}/commits/${r}/${i}/${a}${t?.includeModel?"?include_model=true":""}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await fe(u,"pull prompt commit"),u})).json();return{owner:r,repo:i,commit_hash:o.commit_hash,manifest:o.manifest,examples:o.examples}}async _pullPrompt(e,t){const r=await this.pullPromptCommit(e,{includeModel:t?.includeModel});return JSON.stringify(r.manifest)}async pushPrompt(e,t){return await this.promptExists(e)?t&&Object.keys(t).some(i=>i!=="object")&&await this.updatePrompt(e,{description:t?.description,readme:t?.readme,tags:t?.tags,isPublic:t?.isPublic}):await this.createPrompt(e,{description:t?.description,readme:t?.readme,tags:t?.tags,isPublic:t?.isPublic}),t?.object?await this.createCommit(e,t?.object,{parentCommitHash:t?.parentCommitHash}):await this._getPromptUrl(e)}async clonePublicDataset(e,t={}){const{sourceApiUrl:r=this.apiUrl,datasetName:i}=t,[a,s]=this.parseTokenOrUrl(e,r),o=new tn({apiUrl:a,apiKey:"placeholder"}),u=await o.readSharedDataset(s),l=i||u.name;try{if(await this.hasDataset({datasetId:l})){console.log(`Dataset ${l} already exists in your tenant. Skipping.`);return}}catch{}const c=await o.listSharedExamples(s),h=await this.createDataset(l,{description:u.description,dataType:u.data_type||"kv",inputsSchema:u.inputs_schema_definition??void 0,outputsSchema:u.outputs_schema_definition??void 0});try{await this.createExamples({inputs:c.map(f=>f.inputs),outputs:c.flatMap(f=>f.outputs?[f.outputs]:[]),datasetId:h.id})}catch(f){throw console.error(`An error occurred while creating dataset ${l}. You should delete it manually.`),f}}parseTokenOrUrl(e,t,r=2,i="dataset"){try{return pe(e),[t,e]}catch{}try{const s=new URL(e).pathname.split("/").filter(o=>o!=="");if(s.length>=r){const o=s[s.length-r];return[t,o]}else throw new Error(`Invalid public ${i} URL: ${e}`)}catch{throw new Error(`Invalid public ${i} URL or token: ${e}`)}}async awaitPendingTraceBatches(){if(this.manualFlushMode)return console.warn("[WARNING]: When tracing in manual flush mode, you must call `await client.flush()` manually to submit trace batches."),Promise.resolve();await Promise.all([...this.autoBatchQueue.items.map(({itemPromise:e})=>e),this.batchIngestCaller.queue.onIdle()]),this.langSmithToOTELTranslator!==void 0&&await Dg()?.DEFAULT_LANGSMITH_SPAN_PROCESSOR?.forceFlush()}}function yc(n){return"dataset_id"in n||"dataset_name"in n}const oy=n=>!!["TRACING_V2","TRACING"].find(t=>ze(t)==="true"),gs=Symbol.for("lc:context_variables");function uy(n){return n.replace(/[-:.]/g,"")}function dd(n,e,t=1){const r=t.toFixed(0).slice(0,3).padStart(3,"0"),i=`${new Date(n).toISOString().slice(0,-1)}${r}Z`;return{dottedOrder:uy(i)+e,microsecondPrecisionDatestring:i}}class hi{constructor(e,t,r,i){Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"project_name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"replicas",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.metadata=e,this.tags=t,this.project_name=r,this.replicas=i}static fromHeader(e){const t=e.split(",");let r={},i=[],a,s;for(const o of t){const[u,l]=o.split("="),c=decodeURIComponent(l);u==="langsmith-metadata"?r=JSON.parse(c):u==="langsmith-tags"?i=c.split(","):u==="langsmith-project"?a=c:u==="langsmith-replicas"&&(s=JSON.parse(c))}return new hi(r,i,a,s)}toHeader(){const e=[];return this.metadata&&Object.keys(this.metadata).length>0&&e.push(`langsmith-metadata=${encodeURIComponent(JSON.stringify(this.metadata))}`),this.tags&&this.tags.length>0&&e.push(`langsmith-tags=${encodeURIComponent(this.tags.join(","))}`),this.project_name&&e.push(`langsmith-project=${encodeURIComponent(this.project_name)}`),e.join(",")}}class qe{constructor(e){if(Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"run_type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"project_name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parent_run",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parent_run_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"child_runs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"start_time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"end_time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extra",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"error",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"serialized",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"inputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reference_example_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"events",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"trace_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"dotted_order",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tracingEnabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"execution_order",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"child_execution_order",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"attachments",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"replicas",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_serialized_start_time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),ly(e)){Object.assign(this,{...e});return}const t=qe.getDefaultConfig(),{metadata:r,...i}=e,a=i.client??qe.getSharedClient(),s={...r,...i?.extra?.metadata};if(i.extra={...i.extra,metadata:s},Object.assign(this,{...t,...i,client:a}),this.trace_id||(this.parent_run?this.trace_id=this.parent_run.trace_id??this.id:this.trace_id=this.id),this.replicas=py(this.replicas),this.execution_order??=1,this.child_execution_order??=1,!this.dotted_order){const{dottedOrder:o,microsecondPrecisionDatestring:u}=dd(this.start_time,this.id,this.execution_order);this.parent_run?this.dotted_order=this.parent_run.dotted_order+"."+o:this.dotted_order=o,this._serialized_start_time=u}}set metadata(e){this.extra={...this.extra,metadata:{...this.extra?.metadata,...e}}}get metadata(){return this.extra?.metadata}static getDefaultConfig(){return{id:Le(),run_type:"chain",project_name:td(),child_runs:[],api_url:ct("LANGCHAIN_ENDPOINT")??"http://localhost:1984",api_key:ct("LANGCHAIN_API_KEY"),caller_options:{},start_time:Date.now(),serialized:{},inputs:{},extra:{}}}static getSharedClient(){return qe.sharedClient||(qe.sharedClient=new tn),qe.sharedClient}createChild(e){const t=this.child_execution_order+1,r=new qe({...e,parent_run:this,project_name:this.project_name,replicas:this.replicas,client:this.client,tracingEnabled:this.tracingEnabled,execution_order:t,child_execution_order:t});gs in this&&(r[gs]=this[gs]);const i=Symbol.for("lc:child_config"),a=e.extra?.[i]??this.extra[i];if(fy(a)){const u={...a},l=cy(u.callbacks)?u.callbacks.copy?.():void 0;l&&(Object.assign(l,{_parentRunId:r.id}),l.handlers?.find(hd)?.updateFromRunTree?.(r),u.callbacks=l),r.extra[i]=u}const s=new Set;let o=this;for(;o!=null&&!s.has(o.id);)s.add(o.id),o.child_execution_order=Math.max(o.child_execution_order,t),o=o.parent_run;return this.child_runs.push(r),r}async end(e,t,r=Date.now(),i){this.outputs=this.outputs??e,this.error=this.error??t,this.end_time=this.end_time??r,i&&Object.keys(i).length>0&&(this.extra=this.extra?{...this.extra,metadata:{...this.extra.metadata,...i}}:{metadata:i})}_convertToCreate(e,t,r=!0){const i=e.extra??{};if(i?.runtime?.library===void 0&&(i.runtime||(i.runtime={}),t))for(const[o,u]of Object.entries(t))i.runtime[o]||(i.runtime[o]=u);let a,s;return r?(s=e.parent_run?.id??e.parent_run_id,a=[]):(a=e.child_runs.map(o=>this._convertToCreate(o,t,r)),s=void 0),{id:e.id,name:e.name,start_time:e._serialized_start_time??e.start_time,end_time:e.end_time,run_type:e.run_type,reference_example_id:e.reference_example_id,extra:i,serialized:e.serialized,error:e.error,inputs:e.inputs,outputs:e.outputs,session_name:e.project_name,child_runs:a,parent_run_id:s,trace_id:e.trace_id,dotted_order:e.dotted_order,tags:e.tags,attachments:e.attachments,events:e.events}}_remapForProject(e,t,r=!0){const i=this._convertToCreate(this,t,r);if(e===this.project_name)return i;const a=h=>Lo(`${h}:${e}`,Lo.DNS),s=a(i.id),o=i.trace_id?a(i.trace_id):void 0,u=i.parent_run_id?a(i.parent_run_id):void 0;let l;if(i.dotted_order){const h=dy(i.dotted_order),f=[];for(let p=0;p<h.length-1;p++){const[b,w]=h[p],m=a(w);f.push(b.toISOString().replace(/[-:]/g,"").replace(".","")+m)}const[_]=h[h.length-1];f.push(_.toISOString().replace(/[-:]/g,"").replace(".","")+s),l=f.join(".")}else l=void 0;return{...i,id:s,trace_id:o,parent_run_id:u,dotted_order:l,session_name:e}}async postRun(e=!0){try{const t=ad();if(this.replicas&&this.replicas.length>0)for(const{projectName:r,apiKey:i,apiUrl:a,workspaceId:s}of this.replicas){const o=this._remapForProject(r??this.project_name,t,!0);await this.client.createRun(o,{apiKey:i,apiUrl:a,workspaceId:s})}else{const r=this._convertToCreate(this,t,e);await this.client.createRun(r)}if(!e){ld("Posting with excludeChildRuns=false is deprecated and will be removed in a future version.");for(const r of this.child_runs)await r.postRun(!1)}}catch(t){console.error(`Error in postRun for run ${this.id}:`,t)}}async patchRun(e){if(this.replicas&&this.replicas.length>0)for(const{projectName:t,apiKey:r,apiUrl:i,workspaceId:a,updates:s}of this.replicas){const o=this._remapForProject(t??this.project_name),u={id:o.id,outputs:o.outputs,error:o.error,parent_run_id:o.parent_run_id,session_name:o.session_name,reference_example_id:o.reference_example_id,end_time:o.end_time,dotted_order:o.dotted_order,trace_id:o.trace_id,events:o.events,tags:o.tags,extra:o.extra,attachments:this.attachments,...s};e?.excludeInputs||(u.inputs=o.inputs),await this.client.updateRun(o.id,u,{apiKey:r,apiUrl:i,workspaceId:a})}else try{const t={end_time:this.end_time,error:this.error,outputs:this.outputs,parent_run_id:this.parent_run?.id??this.parent_run_id,reference_example_id:this.reference_example_id,extra:this.extra,events:this.events,dotted_order:this.dotted_order,trace_id:this.trace_id,tags:this.tags,attachments:this.attachments,session_name:this.project_name};e?.excludeInputs||(t.inputs=this.inputs),await this.client.updateRun(this.id,t)}catch(t){console.error(`Error in patchRun for run ${this.id}`,t)}}toJSON(){return this._convertToCreate(this,void 0,!1)}addEvent(e){this.events||(this.events=[]),typeof e=="string"?this.events.push({name:"event",time:new Date().toISOString(),message:e}):this.events.push({...e,time:e.time??new Date().toISOString()})}static fromRunnableConfig(e,t){const r=e?.callbacks;let i,a,s,o=oy();if(r){const l=r?.getParentRunId?.()??"",c=r?.handlers?.find(h=>h?.name=="langchain_tracer");i=c?.getRun?.(l),a=c?.projectName,s=c?.client,o=o||!!c}return i?new qe({name:i.name,id:i.id,trace_id:i.trace_id,dotted_order:i.dotted_order,client:s,tracingEnabled:o,project_name:a,tags:[...new Set((i?.tags??[]).concat(e?.tags??[]))],extra:{metadata:{...i?.extra?.metadata,...e?.metadata}}}).createChild(t):new qe({...t,client:s,tracingEnabled:o,project_name:a})}static fromDottedOrder(e){return this.fromHeaders({"langsmith-trace":e})}static fromHeaders(e,t){const r="get"in e&&typeof e.get=="function"?{"langsmith-trace":e.get("langsmith-trace"),baggage:e.get("baggage")}:e,i=r["langsmith-trace"];if(!i||typeof i!="string")return;const a=i.trim(),s=a.split(".").map(l=>{const[c,h]=l.split("Z");return{strTime:c,time:Date.parse(c+"Z"),uuid:h}}),o=s[0].uuid,u={...t,name:t?.name??"parent",run_type:t?.run_type??"chain",start_time:t?.start_time??Date.now(),id:s.at(-1)?.uuid,trace_id:o,dotted_order:a};if(r.baggage&&typeof r.baggage=="string"){const l=hi.fromHeader(r.baggage);u.metadata=l.metadata,u.tags=l.tags,u.project_name=l.project_name,u.replicas=l.replicas}return new qe(u)}toHeaders(e){const t={"langsmith-trace":this.dotted_order,baggage:new hi(this.extra?.metadata,this.tags,this.project_name,this.replicas).toHeader()};if(e)for(const[r,i]of Object.entries(t))e.set(r,i);return t}}Object.defineProperty(qe,"sharedClient",{enumerable:!0,configurable:!0,writable:!0,value:null});function ly(n){return n!=null&&typeof n.createChild=="function"&&typeof n.postRun=="function"}function hd(n){return typeof n=="object"&&n!=null&&typeof n.name=="string"&&n.name==="langchain_tracer"}function bc(n){return Array.isArray(n)&&n.some(e=>hd(e))}function cy(n){return typeof n=="object"&&n!=null&&Array.isArray(n.handlers)}function fy(n){return n!=null&&typeof n.callbacks=="object"&&(bc(n.callbacks?.handlers)||bc(n.callbacks))}function dy(n){return n.split(".").map(t=>{const r=t.slice(0,-36),i=t.slice(-36),a=parseInt(r.slice(0,4)),s=parseInt(r.slice(4,6))-1,o=parseInt(r.slice(6,8)),u=parseInt(r.slice(9,11)),l=parseInt(r.slice(11,13)),c=parseInt(r.slice(13,15)),h=parseInt(r.slice(15,21));return[new Date(a,s,o,u,l,c,h/1e3),i]})}function hy(){const n=ct("LANGSMITH_RUNS_ENDPOINTS");if(!n)return[];try{const e=JSON.parse(n);if(Array.isArray(e)){const t=[];for(const r of e){if(typeof r!="object"||r===null){console.warn(`Invalid item type in LANGSMITH_RUNS_ENDPOINTS: expected object, got ${typeof r}`);continue}if(typeof r.api_url!="string"){console.warn(`Invalid api_url type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof r.api_url}`);continue}if(typeof r.api_key!="string"){console.warn(`Invalid api_key type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof r.api_key}`);continue}t.push({apiUrl:r.api_url.replace(/\/$/,""),apiKey:r.api_key})}return t}else if(typeof e=="object"&&e!==null){my(e);const t=[];for(const[r,i]of Object.entries(e)){const a=r.replace(/\/$/,"");if(typeof i=="string")t.push({apiUrl:a,apiKey:i});else{console.warn(`Invalid value type in LANGSMITH_RUNS_ENDPOINTS for URL ${r}: expected string, got ${typeof i}`);continue}}return t}else return console.warn(`Invalid LANGSMITH_RUNS_ENDPOINTS – must be valid JSON array of objects with api_url and api_key properties, or object mapping url->apiKey, got ${typeof e}`),[]}catch(e){if(Wg(e))throw e;return console.warn("Invalid LANGSMITH_RUNS_ENDPOINTS – must be valid JSON array of objects with api_url and api_key properties, or object mapping url->apiKey"),[]}}function py(n){return n?n.map(e=>Array.isArray(e)?{projectName:e[0],updates:e[1]}:e):hy()}function my(n){if(Object.keys(n).length>0&&ze("ENDPOINT"))throw new Vg}const gy=n=>{if(n)return n.events=n.events??[],n.child_runs=n.child_runs??[],n};function js(n,e){if(n)return new qe({...n,start_time:n._serialized_start_time??n.start_time,parent_run:js(e),child_runs:n.child_runs.map(t=>js(t)).filter(t=>t!==void 0),extra:{...n.extra,runtime:Vm()},tracingEnabled:!1})}function ys(n,e){return n&&!Array.isArray(n)&&typeof n=="object"?n:{[e]:n}}function Lr(n){return typeof n._addRunToRunMap=="function"}class gn extends mn{constructor(e){super(...arguments),Object.defineProperty(this,"runMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"runTreeMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"usesRunTreeMap",{enumerable:!0,configurable:!0,writable:!0,value:!1})}copy(){return this}getRunById(e){if(e!==void 0)return this.usesRunTreeMap?gy(this.runTreeMap.get(e)):this.runMap.get(e)}stringifyError(e){return e instanceof Error?e.message+(e?.stack?`
|
|
79
|
+
|
|
80
|
+
${e.stack}`:""):typeof e=="string"?e:`${e}`}_addChildRun(e,t){e.child_runs.push(t)}_addRunToRunMap(e){const{dottedOrder:t,microsecondPrecisionDatestring:r}=dd(new Date(e.start_time).getTime(),e.id,e.execution_order),i={...e},a=this.getRunById(i.parent_run_id);if(i.parent_run_id!==void 0?a&&(this._addChildRun(a,i),a.child_execution_order=Math.max(a.child_execution_order,i.child_execution_order),i.trace_id=a.trace_id,a.dotted_order!==void 0&&(i.dotted_order=[a.dotted_order,t].join("."),i._serialized_start_time=r)):(i.trace_id=i.id,i.dotted_order=t,i._serialized_start_time=r),this.usesRunTreeMap){const s=js(i,a);s!==void 0&&this.runTreeMap.set(i.id,s)}else this.runMap.set(i.id,i);return i}async _endTrace(e){const t=e.parent_run_id!==void 0&&this.getRunById(e.parent_run_id);t?t.child_execution_order=Math.max(t.child_execution_order,e.child_execution_order):await this.persistRun(e),await this.onRunUpdate?.(e),this.usesRunTreeMap?this.runTreeMap.delete(e.id):this.runMap.delete(e.id)}_getExecutionOrder(e){const t=e!==void 0&&this.getRunById(e);return t?t.child_execution_order+1:1}_createRunForLLMStart(e,t,r,i,a,s,o,u){const l=this._getExecutionOrder(i),c=Date.now(),h=o?{...a,metadata:o}:a,f={id:r,name:u??e.id[e.id.length-1],parent_run_id:i,start_time:c,serialized:e,events:[{name:"start",time:new Date(c).toISOString()}],inputs:{prompts:t},execution_order:l,child_runs:[],child_execution_order:l,run_type:"llm",extra:h??{},tags:s||[]};return this._addRunToRunMap(f)}async handleLLMStart(e,t,r,i,a,s,o,u){const l=this.getRunById(r)??this._createRunForLLMStart(e,t,r,i,a,s,o,u);return await this.onRunCreate?.(l),await this.onLLMStart?.(l),l}_createRunForChatModelStart(e,t,r,i,a,s,o,u){const l=this._getExecutionOrder(i),c=Date.now(),h=o?{...a,metadata:o}:a,f={id:r,name:u??e.id[e.id.length-1],parent_run_id:i,start_time:c,serialized:e,events:[{name:"start",time:new Date(c).toISOString()}],inputs:{messages:t},execution_order:l,child_runs:[],child_execution_order:l,run_type:"llm",extra:h??{},tags:s||[]};return this._addRunToRunMap(f)}async handleChatModelStart(e,t,r,i,a,s,o,u){const l=this.getRunById(r)??this._createRunForChatModelStart(e,t,r,i,a,s,o,u);return await this.onRunCreate?.(l),await this.onLLMStart?.(l),l}async handleLLMEnd(e,t,r,i,a){const s=this.getRunById(t);if(!s||s?.run_type!=="llm")throw new Error("No LLM run to end.");return s.end_time=Date.now(),s.outputs=e,s.events.push({name:"end",time:new Date(s.end_time).toISOString()}),s.extra={...s.extra,...a},await this.onLLMEnd?.(s),await this._endTrace(s),s}async handleLLMError(e,t,r,i,a){const s=this.getRunById(t);if(!s||s?.run_type!=="llm")throw new Error("No LLM run to end.");return s.end_time=Date.now(),s.error=this.stringifyError(e),s.events.push({name:"error",time:new Date(s.end_time).toISOString()}),s.extra={...s.extra,...a},await this.onLLMError?.(s),await this._endTrace(s),s}_createRunForChainStart(e,t,r,i,a,s,o,u){const l=this._getExecutionOrder(i),c=Date.now(),h={id:r,name:u??e.id[e.id.length-1],parent_run_id:i,start_time:c,serialized:e,events:[{name:"start",time:new Date(c).toISOString()}],inputs:t,execution_order:l,child_execution_order:l,run_type:o??"chain",child_runs:[],extra:s?{metadata:s}:{},tags:a||[]};return this._addRunToRunMap(h)}async handleChainStart(e,t,r,i,a,s,o,u){const l=this.getRunById(r)??this._createRunForChainStart(e,t,r,i,a,s,o,u);return await this.onRunCreate?.(l),await this.onChainStart?.(l),l}async handleChainEnd(e,t,r,i,a){const s=this.getRunById(t);if(!s)throw new Error("No chain run to end.");return s.end_time=Date.now(),s.outputs=ys(e,"output"),s.events.push({name:"end",time:new Date(s.end_time).toISOString()}),a?.inputs!==void 0&&(s.inputs=ys(a.inputs,"input")),await this.onChainEnd?.(s),await this._endTrace(s),s}async handleChainError(e,t,r,i,a){const s=this.getRunById(t);if(!s)throw new Error("No chain run to end.");return s.end_time=Date.now(),s.error=this.stringifyError(e),s.events.push({name:"error",time:new Date(s.end_time).toISOString()}),a?.inputs!==void 0&&(s.inputs=ys(a.inputs,"input")),await this.onChainError?.(s),await this._endTrace(s),s}_createRunForToolStart(e,t,r,i,a,s,o){const u=this._getExecutionOrder(i),l=Date.now(),c={id:r,name:o??e.id[e.id.length-1],parent_run_id:i,start_time:l,serialized:e,events:[{name:"start",time:new Date(l).toISOString()}],inputs:{input:t},execution_order:u,child_execution_order:u,run_type:"tool",child_runs:[],extra:s?{metadata:s}:{},tags:a||[]};return this._addRunToRunMap(c)}async handleToolStart(e,t,r,i,a,s,o){const u=this.getRunById(r)??this._createRunForToolStart(e,t,r,i,a,s,o);return await this.onRunCreate?.(u),await this.onToolStart?.(u),u}async handleToolEnd(e,t){const r=this.getRunById(t);if(!r||r?.run_type!=="tool")throw new Error("No tool run to end");return r.end_time=Date.now(),r.outputs={output:e},r.events.push({name:"end",time:new Date(r.end_time).toISOString()}),await this.onToolEnd?.(r),await this._endTrace(r),r}async handleToolError(e,t){const r=this.getRunById(t);if(!r||r?.run_type!=="tool")throw new Error("No tool run to end");return r.end_time=Date.now(),r.error=this.stringifyError(e),r.events.push({name:"error",time:new Date(r.end_time).toISOString()}),await this.onToolError?.(r),await this._endTrace(r),r}async handleAgentAction(e,t){const r=this.getRunById(t);if(!r||r?.run_type!=="chain")return;const i=r;i.actions=i.actions||[],i.actions.push(e),i.events.push({name:"agent_action",time:new Date().toISOString(),kwargs:{action:e}}),await this.onAgentAction?.(r)}async handleAgentEnd(e,t){const r=this.getRunById(t);!r||r?.run_type!=="chain"||(r.events.push({name:"agent_end",time:new Date().toISOString(),kwargs:{action:e}}),await this.onAgentEnd?.(r))}_createRunForRetrieverStart(e,t,r,i,a,s,o){const u=this._getExecutionOrder(i),l=Date.now(),c={id:r,name:o??e.id[e.id.length-1],parent_run_id:i,start_time:l,serialized:e,events:[{name:"start",time:new Date(l).toISOString()}],inputs:{query:t},execution_order:u,child_execution_order:u,run_type:"retriever",child_runs:[],extra:s?{metadata:s}:{},tags:a||[]};return this._addRunToRunMap(c)}async handleRetrieverStart(e,t,r,i,a,s,o){const u=this.getRunById(r)??this._createRunForRetrieverStart(e,t,r,i,a,s,o);return await this.onRunCreate?.(u),await this.onRetrieverStart?.(u),u}async handleRetrieverEnd(e,t){const r=this.getRunById(t);if(!r||r?.run_type!=="retriever")throw new Error("No retriever run to end");return r.end_time=Date.now(),r.outputs={documents:e},r.events.push({name:"end",time:new Date(r.end_time).toISOString()}),await this.onRetrieverEnd?.(r),await this._endTrace(r),r}async handleRetrieverError(e,t){const r=this.getRunById(t);if(!r||r?.run_type!=="retriever")throw new Error("No retriever run to end");return r.end_time=Date.now(),r.error=this.stringifyError(e),r.events.push({name:"error",time:new Date(r.end_time).toISOString()}),await this.onRetrieverError?.(r),await this._endTrace(r),r}async handleText(e,t){const r=this.getRunById(t);!r||r?.run_type!=="chain"||(r.events.push({name:"text",time:new Date().toISOString(),kwargs:{text:e}}),await this.onText?.(r))}async handleLLMNewToken(e,t,r,i,a,s){const o=this.getRunById(r);if(!o||o?.run_type!=="llm")throw new Error('Invalid "runId" provided to "handleLLMNewToken" callback.');return o.events.push({name:"new_token",time:new Date().toISOString(),kwargs:{token:e,idx:t,chunk:s?.chunk}}),await this.onLLMNewToken?.(o,e,{chunk:s?.chunk}),o}}function Ne(n,e){return`${n.open}${e}${n.close}`}function Je(n,e){try{return JSON.stringify(n,null,2)}catch{return e}}function _c(n){return typeof n=="string"?n.trim():n==null?n:Je(n,n.toString())}function Tt(n){if(!n.end_time)return"";const e=n.end_time-n.start_time;return e<1e3?`${e}ms`:`${(e/1e3).toFixed(2)}s`}const{color:Be}=lf;class vc extends gn{constructor(){super(...arguments),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"console_callback_handler"})}persistRun(e){return Promise.resolve()}getParents(e){const t=[];let r=e;for(;r.parent_run_id;){const i=this.runMap.get(r.parent_run_id);if(i)t.push(i),r=i;else break}return t}getBreadcrumbs(e){const r=[...this.getParents(e).reverse(),e].map((i,a,s)=>{const o=`${i.execution_order}:${i.run_type}:${i.name}`;return a===s.length-1?Ne(lf.bold,o):o}).join(" > ");return Ne(Be.grey,r)}onChainStart(e){const t=this.getBreadcrumbs(e);console.log(`${Ne(Be.green,"[chain/start]")} [${t}] Entering Chain run with input: ${Je(e.inputs,"[inputs]")}`)}onChainEnd(e){const t=this.getBreadcrumbs(e);console.log(`${Ne(Be.cyan,"[chain/end]")} [${t}] [${Tt(e)}] Exiting Chain run with output: ${Je(e.outputs,"[outputs]")}`)}onChainError(e){const t=this.getBreadcrumbs(e);console.log(`${Ne(Be.red,"[chain/error]")} [${t}] [${Tt(e)}] Chain run errored with error: ${Je(e.error,"[error]")}`)}onLLMStart(e){const t=this.getBreadcrumbs(e),r="prompts"in e.inputs?{prompts:e.inputs.prompts.map(i=>i.trim())}:e.inputs;console.log(`${Ne(Be.green,"[llm/start]")} [${t}] Entering LLM run with input: ${Je(r,"[inputs]")}`)}onLLMEnd(e){const t=this.getBreadcrumbs(e);console.log(`${Ne(Be.cyan,"[llm/end]")} [${t}] [${Tt(e)}] Exiting LLM run with output: ${Je(e.outputs,"[response]")}`)}onLLMError(e){const t=this.getBreadcrumbs(e);console.log(`${Ne(Be.red,"[llm/error]")} [${t}] [${Tt(e)}] LLM run errored with error: ${Je(e.error,"[error]")}`)}onToolStart(e){const t=this.getBreadcrumbs(e);console.log(`${Ne(Be.green,"[tool/start]")} [${t}] Entering Tool run with input: "${_c(e.inputs.input)}"`)}onToolEnd(e){const t=this.getBreadcrumbs(e);console.log(`${Ne(Be.cyan,"[tool/end]")} [${t}] [${Tt(e)}] Exiting Tool run with output: "${_c(e.outputs?.output)}"`)}onToolError(e){const t=this.getBreadcrumbs(e);console.log(`${Ne(Be.red,"[tool/error]")} [${t}] [${Tt(e)}] Tool run errored with error: ${Je(e.error,"[error]")}`)}onRetrieverStart(e){const t=this.getBreadcrumbs(e);console.log(`${Ne(Be.green,"[retriever/start]")} [${t}] Entering Retriever run with input: ${Je(e.inputs,"[inputs]")}`)}onRetrieverEnd(e){const t=this.getBreadcrumbs(e);console.log(`${Ne(Be.cyan,"[retriever/end]")} [${t}] [${Tt(e)}] Exiting Retriever run with output: ${Je(e.outputs,"[outputs]")}`)}onRetrieverError(e){const t=this.getBreadcrumbs(e);console.log(`${Ne(Be.red,"[retriever/error]")} [${t}] [${Tt(e)}] Retriever run errored with error: ${Je(e.error,"[error]")}`)}onAgentAction(e){const t=e,r=this.getBreadcrumbs(e);console.log(`${Ne(Be.blue,"[agent/action]")} [${r}] Agent selected action: ${Je(t.actions[t.actions.length-1],"[action]")}`)}}function Ci(n,e){return n.lc_error_code=e,n.message=`${n.message}
|
|
81
|
+
|
|
82
|
+
Troubleshooting URL: https://js.langchain.com/docs/troubleshooting/errors/${e}/
|
|
83
|
+
`,n}function Hr(n){return!!(n&&typeof n=="object"&&"type"in n&&n.type==="tool_call")}function yy(n){return!!(n&&typeof n=="object"&&"toolCall"in n&&n.toolCall!=null&&typeof n.toolCall=="object"&&"id"in n.toolCall&&typeof n.toolCall.id=="string")}class rn extends Error{constructor(e,t){super(e),Object.defineProperty(this,"output",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.output=t}}function by(n){if(typeof n>"u")return null;try{return JSON.parse(n)}catch{}let e="";const t=[];let r=!1,i=!1;for(let a of n){if(r)a==='"'&&!i?r=!1:a===`
|
|
84
|
+
`&&!i?a="\\n":a==="\\"?i=!i:i=!1;else if(a==='"')r=!0,i=!1;else if(a==="{")t.push("}");else if(a==="[")t.push("]");else if(a==="}"||a==="]")if(t&&t[t.length-1]===a)t.pop();else return null;e+=a}r&&(e+='"');for(let a=t.length-1;a>=0;a-=1)e+=t[a];try{return JSON.parse(e)}catch{return null}}function wc(n){return typeof n=="object"&&n!==null&&"type"in n&&typeof n.type=="string"&&"source_type"in n&&(n.source_type==="url"||n.source_type==="base64"||n.source_type==="text"||n.source_type==="id")}function _y(n,e){return typeof n=="string"?n===""?e:typeof e=="string"?n+e:Array.isArray(e)&&e.some(t=>wc(t))?[{type:"text",source_type:"text",text:n},...e]:[{type:"text",text:n},...e]:Array.isArray(e)?bo(n,e)??[...n,...e]:e===""?n:Array.isArray(n)&&n.some(t=>wc(t))?[...n,{type:"file",source_type:"text",text:e}]:[...n,{type:"text",text:e}]}function vy(n,e){function t(r,i){if(typeof r!="object"||r===null||r===void 0)return r;if(i>=e)return Array.isArray(r)?"[Array]":"[Object]";if(Array.isArray(r))return r.map(s=>t(s,i+1));const a={};for(const s of Object.keys(r))a[s]=t(r[s],i+1);return a}return JSON.stringify(t(n,0),null,2)}class tt extends bt{get lc_aliases(){return{additional_kwargs:"additional_kwargs",response_metadata:"response_metadata"}}get text(){return typeof this.content=="string"?this.content:Array.isArray(this.content)?this.content.map(e=>typeof e=="string"?e:e.type==="text"?e.text:"").join(""):""}getType(){return this._getType()}constructor(e,t){typeof e=="string"&&(e={content:e,additional_kwargs:t,response_metadata:{}}),e.additional_kwargs||(e.additional_kwargs={}),e.response_metadata||(e.response_metadata={}),super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","messages"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"additional_kwargs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"response_metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e.name,this.content=e.content,this.additional_kwargs=e.additional_kwargs,this.response_metadata=e.response_metadata,this.id=e.id}toDict(){return{type:this._getType(),data:this.toJSON().kwargs}}static lc_name(){return"BaseMessage"}get _printableFields(){return{id:this.id,content:this.content,name:this.name,additional_kwargs:this.additional_kwargs,response_metadata:this.response_metadata}}_updateId(e){this.id=e,this.lc_kwargs.id=e}get[Symbol.toStringTag](){return this.constructor.lc_name()}[Symbol.for("nodejs.util.inspect.custom")](e){if(e===null)return this;const t=vy(this._printableFields,Math.max(4,e));return`${this.constructor.lc_name()} ${t}`}}function pi(n,e){const t={...n};for(const[r,i]of Object.entries(e))if(t[r]==null)t[r]=i;else{if(i==null)continue;if(typeof t[r]!=typeof i||Array.isArray(t[r])!==Array.isArray(i))throw new Error(`field[${r}] already exists in the message chunk, but with a different type.`);if(typeof t[r]=="string"){if(r==="type")continue;["id","name","output_version","model_provider"].includes(r)?t[r]=i:t[r]+=i}else if(typeof t[r]=="object"&&!Array.isArray(t[r]))t[r]=pi(t[r],i);else if(Array.isArray(t[r]))t[r]=bo(t[r],i);else{if(t[r]===i)continue;console.warn(`field[${r}] already exists in this message chunk and value has unsupported type.`)}}return t}function bo(n,e){if(!(n===void 0&&e===void 0)){if(n===void 0||e===void 0)return n||e;{const t=[...n];for(const r of e)if(typeof r=="object"&&r!==null&&"index"in r&&typeof r.index=="number"){const i=t.findIndex(a=>{const s=typeof a=="object",o="index"in a&&a.index===r.index,u="id"in a&&"id"in r&&a?.id===r?.id,l=!("id"in a)||!a?.id||!("id"in r)||!r?.id;return s&&o&&(u||l)});i!==-1&&typeof t[i]=="object"&&t[i]!==null?t[i]=pi(t[i],r):t.push(r)}else{if(typeof r=="object"&&r!==null&&"text"in r&&r.text==="")continue;t.push(r)}return t}}}class wy extends tt{}function Ey(n){return typeof n.role=="string"}function _o(n){return typeof n?._getType=="function"}function Sy(n){return n!=null&&typeof n=="object"&&"lc_direct_tool_output"in n&&n.lc_direct_tool_output===!0}class wr extends tt{static lc_name(){return"ToolMessage"}get lc_aliases(){return{tool_call_id:"tool_call_id"}}constructor(e,t,r){typeof e=="string"&&(e={content:e,name:r,tool_call_id:t}),super(e),Object.defineProperty(this,"lc_direct_tool_output",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tool_call_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"artifact",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.tool_call_id=e.tool_call_id,this.artifact=e.artifact,this.status=e.status,this.metadata=e.metadata}_getType(){return"tool"}static isInstance(e){return e._getType()==="tool"}get _printableFields(){return{...super._printableFields,tool_call_id:this.tool_call_id,artifact:this.artifact}}}function Oy(n){const e=[],t=[];for(const r of n)if(r.function){const i=r.function.name;try{const a=JSON.parse(r.function.arguments),s={name:i||"",args:a||{},id:r.id};e.push(s)}catch{t.push({name:i,args:r.function.arguments,id:r.id,error:"Malformed args."})}}else continue;return[e,t]}class ot extends tt{get lc_aliases(){return{...super.lc_aliases,tool_calls:"tool_calls",invalid_tool_calls:"invalid_tool_calls"}}constructor(e,t){let r;if(typeof e=="string")r={content:e,tool_calls:[],invalid_tool_calls:[],additional_kwargs:t??{}};else{r=e;const i=r.additional_kwargs?.tool_calls,a=r.tool_calls;i!=null&&i.length>0&&(a===void 0||a.length===0)&&console.warn(["New LangChain packages are available that more efficiently handle",`tool calling.
|
|
85
|
+
|
|
86
|
+
Please upgrade your packages to versions that set`,"message tool calls. e.g., `yarn add @langchain/anthropic`,","yarn add @langchain/openai`, etc."].join(" "));try{if(i!=null&&a===void 0){const[s,o]=Oy(i);r.tool_calls=s??[],r.invalid_tool_calls=o??[]}else r.tool_calls=r.tool_calls??[],r.invalid_tool_calls=r.invalid_tool_calls??[]}catch{r.tool_calls=[],r.invalid_tool_calls=[]}}super(r),Object.defineProperty(this,"tool_calls",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"invalid_tool_calls",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"usage_metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),typeof r!="string"&&(this.tool_calls=r.tool_calls??this.tool_calls,this.invalid_tool_calls=r.invalid_tool_calls??this.invalid_tool_calls),this.usage_metadata=r.usage_metadata}static lc_name(){return"AIMessage"}_getType(){return"ai"}get _printableFields(){return{...super._printableFields,tool_calls:this.tool_calls,invalid_tool_calls:this.invalid_tool_calls,usage_metadata:this.usage_metadata}}}class $i extends wy{constructor(e){let t;if(typeof e=="string")t={content:e,tool_calls:[],invalid_tool_calls:[],tool_call_chunks:[]};else if(e.tool_call_chunks===void 0)t={...e,tool_calls:e.tool_calls??[],invalid_tool_calls:[],tool_call_chunks:[],usage_metadata:e.usage_metadata!==void 0?e.usage_metadata:void 0};else{const r=e.tool_call_chunks.reduce((s,o)=>{const u=s.findIndex(([l])=>"id"in o&&o.id&&"index"in o&&o.index!==void 0?o.id===l.id&&o.index===l.index:"id"in o&&o.id?o.id===l.id:"index"in o&&o.index!==void 0?o.index===l.index:!1);return u!==-1?s[u].push(o):s.push([o]),s},[]),i=[],a=[];for(const s of r){let o={};const u=s[0]?.name??"",l=s.map(f=>f.args||"").join(""),c=l.length?l:"{}",h=s[0]?.id;try{if(o=by(c),!h||o===null||typeof o!="object"||Array.isArray(o))throw new Error("Malformed tool call chunk args.");i.push({name:u,args:o,id:h,type:"tool_call"})}catch{a.push({name:u,args:c,id:h,error:"Malformed args.",type:"invalid_tool_call"})}}t={...e,tool_calls:i,invalid_tool_calls:a,usage_metadata:e.usage_metadata!==void 0?e.usage_metadata:void 0}}super(t),Object.defineProperty(this,"tool_calls",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"invalid_tool_calls",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"tool_call_chunks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"usage_metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.tool_call_chunks=t.tool_call_chunks??this.tool_call_chunks,this.tool_calls=t.tool_calls??this.tool_calls,this.invalid_tool_calls=t.invalid_tool_calls??this.invalid_tool_calls,this.usage_metadata=t.usage_metadata}get lc_aliases(){return{...super.lc_aliases,tool_calls:"tool_calls",invalid_tool_calls:"invalid_tool_calls",tool_call_chunks:"tool_call_chunks"}}static lc_name(){return"AIMessageChunk"}_getType(){return"ai"}get _printableFields(){return{...super._printableFields,tool_calls:this.tool_calls,tool_call_chunks:this.tool_call_chunks,invalid_tool_calls:this.invalid_tool_calls,usage_metadata:this.usage_metadata}}concat(e){const t={content:_y(this.content,e.content),additional_kwargs:pi(this.additional_kwargs,e.additional_kwargs),response_metadata:pi(this.response_metadata,e.response_metadata),tool_call_chunks:[],id:this.id??e.id};if(this.tool_call_chunks!==void 0||e.tool_call_chunks!==void 0){const r=bo(this.tool_call_chunks,e.tool_call_chunks);r!==void 0&&r.length>0&&(t.tool_call_chunks=r)}if(this.usage_metadata!==void 0||e.usage_metadata!==void 0){const r={...(this.usage_metadata?.input_token_details?.audio!==void 0||e.usage_metadata?.input_token_details?.audio!==void 0)&&{audio:(this.usage_metadata?.input_token_details?.audio??0)+(e.usage_metadata?.input_token_details?.audio??0)},...(this.usage_metadata?.input_token_details?.cache_read!==void 0||e.usage_metadata?.input_token_details?.cache_read!==void 0)&&{cache_read:(this.usage_metadata?.input_token_details?.cache_read??0)+(e.usage_metadata?.input_token_details?.cache_read??0)},...(this.usage_metadata?.input_token_details?.cache_creation!==void 0||e.usage_metadata?.input_token_details?.cache_creation!==void 0)&&{cache_creation:(this.usage_metadata?.input_token_details?.cache_creation??0)+(e.usage_metadata?.input_token_details?.cache_creation??0)}},i={...(this.usage_metadata?.output_token_details?.audio!==void 0||e.usage_metadata?.output_token_details?.audio!==void 0)&&{audio:(this.usage_metadata?.output_token_details?.audio??0)+(e.usage_metadata?.output_token_details?.audio??0)},...(this.usage_metadata?.output_token_details?.reasoning!==void 0||e.usage_metadata?.output_token_details?.reasoning!==void 0)&&{reasoning:(this.usage_metadata?.output_token_details?.reasoning??0)+(e.usage_metadata?.output_token_details?.reasoning??0)}},a=this.usage_metadata??{input_tokens:0,output_tokens:0,total_tokens:0},s=e.usage_metadata??{input_tokens:0,output_tokens:0,total_tokens:0},o={input_tokens:a.input_tokens+s.input_tokens,output_tokens:a.output_tokens+s.output_tokens,total_tokens:a.total_tokens+s.total_tokens,...Object.keys(r).length>0&&{input_token_details:r},...Object.keys(i).length>0&&{output_token_details:i}};t.usage_metadata=o}return new $i(t)}}class ji extends tt{static lc_name(){return"ChatMessage"}static _chatMessageClass(){return ji}constructor(e,t){typeof e=="string"&&(e={content:e,role:t}),super(e),Object.defineProperty(this,"role",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.role=e.role}_getType(){return"generic"}static isInstance(e){return e._getType()==="generic"}get _printableFields(){return{...super._printableFields,role:this.role}}}class Xe extends tt{static lc_name(){return"HumanMessage"}_getType(){return"human"}constructor(e,t){super(e,t)}}class Ty extends tt{constructor(e){super({...e,content:""}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.id=e.id}_getType(){return"remove"}get _printableFields(){return{...super._printableFields,id:this.id}}}class yt extends tt{static lc_name(){return"SystemMessage"}_getType(){return"system"}constructor(e,t){super(e,t)}}function Py(n){return Hr(n)?n:typeof n.id=="string"&&n.type==="function"&&typeof n.function=="object"&&n.function!==null&&"arguments"in n.function&&typeof n.function.arguments=="string"&&"name"in n.function&&typeof n.function.name=="string"?{id:n.id,args:JSON.parse(n.function.arguments),name:n.function.name,type:"tool_call"}:n}function xy(n){return typeof n=="object"&&n!=null&&n.lc===1&&Array.isArray(n.id)&&n.kwargs!=null&&typeof n.kwargs=="object"}function bs(n){let e,t;if(xy(n)){const r=n.id.at(-1);r==="HumanMessage"||r==="HumanMessageChunk"?e="user":r==="AIMessage"||r==="AIMessageChunk"?e="assistant":r==="SystemMessage"||r==="SystemMessageChunk"?e="system":r==="FunctionMessage"||r==="FunctionMessageChunk"?e="function":r==="ToolMessage"||r==="ToolMessageChunk"?e="tool":e="unknown",t=n.kwargs}else{const{type:r,...i}=n;e=r,t=i}if(e==="human"||e==="user")return new Xe(t);if(e==="ai"||e==="assistant"){const{tool_calls:r,...i}=t;if(!Array.isArray(r))return new ot(t);const a=r.map(Py);return new ot({...i,tool_calls:a})}else{if(e==="system")return new yt(t);if(e==="developer")return new yt({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}});if(e==="tool"&&"tool_call_id"in t)return new wr({...t,content:t.content,tool_call_id:t.tool_call_id,name:t.name});if(e==="remove"&&"id"in t&&typeof t.id=="string")return new Ty({...t,id:t.id});throw Ci(new Error(`Unable to coerce message from array: only human, AI, system, developer, or tool message coercion is currently supported.
|
|
87
|
+
|
|
88
|
+
Received: ${JSON.stringify(n,null,2)}`),"MESSAGE_COERCION_FAILURE")}}function mi(n){if(typeof n=="string")return new Xe(n);if(_o(n))return n;if(Array.isArray(n)){const[e,t]=n;return bs({type:e,content:t})}else if(Ey(n)){const{role:e,...t}=n;return bs({...t,type:e})}else return bs(n)}function pd(n,e="Human",t="AI"){const r=[];for(const i of n){let a;if(i._getType()==="human")a=e;else if(i._getType()==="ai")a=t;else if(i._getType()==="system")a="System";else if(i._getType()==="function")a="Function";else if(i._getType()==="tool")a="Tool";else if(i._getType()==="generic")a=i.role;else throw new Error(`Got unsupported message type: ${i._getType()}`);const s=i.name?`${i.name}, `:"",o=typeof i.content=="string"?i.content:JSON.stringify(i.content,null,2);r.push(`${a}: ${s}${o}`)}return r.join(`
|
|
89
|
+
`)}let Ay=class{getStore(){}run(e,t){return t()}};const _s=Symbol.for("ls:tracing_async_local_storage"),Ry=new Ay;let Iy=class{getInstance(){return globalThis[_s]??Ry}initializeGlobalInstance(e){globalThis[_s]===void 0&&(globalThis[_s]=e)}};const Cy=new Iy;function $y(n=!1){const e=Cy.getInstance().getStore();if(!n&&e===void 0)throw new Error(`Could not get the current run tree.
|
|
90
|
+
|
|
91
|
+
Please make sure you are calling this method within a traceable function and that tracing is enabled.`);return e}function vo(n){return typeof n=="function"&&"langsmith:traceable"in n}let vs;const jy=()=>{if(vs===void 0){const n=Jt("LANGCHAIN_CALLBACKS_BACKGROUND")==="false"?{blockOnRootRunFinalization:!0}:{};vs=new tn(n)}return vs};class Gr extends gn{constructor(e={}){super(e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"langchain_tracer"}),Object.defineProperty(this,"projectName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"exampleId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"replicas",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"usesRunTreeMap",{enumerable:!0,configurable:!0,writable:!0,value:!0});const{exampleId:t,projectName:r,client:i,replicas:a}=e;this.projectName=r??td(),this.replicas=a,this.exampleId=t,this.client=i??jy();const s=Gr.getTraceableRunTree();s&&this.updateFromRunTree(s)}async persistRun(e){}async onRunCreate(e){await this.getRunTreeWithTracingConfig(e.id)?.postRun()}async onRunUpdate(e){await this.getRunTreeWithTracingConfig(e.id)?.patchRun()}getRun(e){return this.runTreeMap.get(e)}updateFromRunTree(e){this.runTreeMap.set(e.id,e);let t=e;const r=new Set;for(;t.parent_run&&!(r.has(t.id)||(r.add(t.id),!t.parent_run));)t=t.parent_run;r.clear();const i=[t];for(;i.length>0;){const a=i.shift();!a||r.has(a.id)||(r.add(a.id),this.runTreeMap.set(a.id,a),a.child_runs&&i.push(...a.child_runs))}this.client=e.client??this.client,this.replicas=e.replicas??this.replicas,this.projectName=e.project_name??this.projectName,this.exampleId=e.reference_example_id??this.exampleId}getRunTreeWithTracingConfig(e){const t=this.runTreeMap.get(e);if(t)return new qe({...t,client:this.client,project_name:this.projectName,replicas:this.replicas,reference_example_id:this.exampleId,tracingEnabled:!0})}static getTraceableRunTree(){try{return $y(!0)}catch{return}}}const md=Symbol.for("ls:tracing_async_local_storage"),ni=Symbol.for("lc:context_variables"),My=n=>{globalThis[md]=n},nn=()=>globalThis[md];let Vr;function ky(){const n="default"in gt?gt.default:gt;return new n({autoStart:!0,concurrency:1})}function Ny(){return typeof Vr>"u"&&(Vr=ky()),Vr}async function Ie(n,e){if(e===!0){const t=nn();t!==void 0?await t.run(void 0,async()=>n()):await n()}else Vr=Ny(),Vr.add(async()=>{const t=nn();t!==void 0?await t.run(void 0,async()=>n()):await n()})}const Ly=n=>!!["LANGSMITH_TRACING_V2","LANGCHAIN_TRACING_V2","LANGSMITH_TRACING","LANGCHAIN_TRACING"].find(t=>Jt(t)==="true");function gd(n){const e=nn();return e===void 0?void 0:e.getStore()?.[ni]?.[n]}const Fy=Symbol("lc:configure_hooks"),Dy=()=>gd(Fy)||[];function wo(n){return n?Array.isArray(n)||"name"in n?{callbacks:n}:n:{}}class Uy{setHandler(e){return this.setHandlers([e])}}class Mi{constructor(e,t,r,i,a,s,o,u){Object.defineProperty(this,"runId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"inheritableHandlers",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"inheritableTags",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"inheritableMetadata",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_parentRunId",{enumerable:!0,configurable:!0,writable:!0,value:u})}get parentRunId(){return this._parentRunId}async handleText(e){await Promise.all(this.handlers.map(t=>Ie(async()=>{try{await t.handleText?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleText: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}async handleCustomEvent(e,t,r,i,a){await Promise.all(this.handlers.map(s=>Ie(async()=>{try{await s.handleCustomEvent?.(e,t,this.runId,this.tags,this.metadata)}catch(o){if((s.raiseError?console.error:console.warn)(`Error in handler ${s.constructor.name}, handleCustomEvent: ${o}`),s.raiseError)throw o}},s.awaitHandlers)))}}class By extends Mi{getChild(e){const t=new Fe(this.runId);return t.setHandlers(this.inheritableHandlers),t.addTags(this.inheritableTags),t.addMetadata(this.inheritableMetadata),e&&t.addTags([e],!1),t}async handleRetrieverEnd(e){await Promise.all(this.handlers.map(t=>Ie(async()=>{if(!t.ignoreRetriever)try{await t.handleRetrieverEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleRetriever`),t.raiseError)throw r}},t.awaitHandlers)))}async handleRetrieverError(e){await Promise.all(this.handlers.map(t=>Ie(async()=>{if(!t.ignoreRetriever)try{await t.handleRetrieverError?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleRetrieverError: ${r}`),t.raiseError)throw e}},t.awaitHandlers)))}}class Ec extends Mi{async handleLLMNewToken(e,t,r,i,a,s){await Promise.all(this.handlers.map(o=>Ie(async()=>{if(!o.ignoreLLM)try{await o.handleLLMNewToken?.(e,t??{prompt:0,completion:0},this.runId,this._parentRunId,this.tags,s)}catch(u){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleLLMNewToken: ${u}`),o.raiseError)throw u}},o.awaitHandlers)))}async handleLLMError(e,t,r,i,a){await Promise.all(this.handlers.map(s=>Ie(async()=>{if(!s.ignoreLLM)try{await s.handleLLMError?.(e,this.runId,this._parentRunId,this.tags,a)}catch(o){if((s.raiseError?console.error:console.warn)(`Error in handler ${s.constructor.name}, handleLLMError: ${o}`),s.raiseError)throw o}},s.awaitHandlers)))}async handleLLMEnd(e,t,r,i,a){await Promise.all(this.handlers.map(s=>Ie(async()=>{if(!s.ignoreLLM)try{await s.handleLLMEnd?.(e,this.runId,this._parentRunId,this.tags,a)}catch(o){if((s.raiseError?console.error:console.warn)(`Error in handler ${s.constructor.name}, handleLLMEnd: ${o}`),s.raiseError)throw o}},s.awaitHandlers)))}}class qy extends Mi{getChild(e){const t=new Fe(this.runId);return t.setHandlers(this.inheritableHandlers),t.addTags(this.inheritableTags),t.addMetadata(this.inheritableMetadata),e&&t.addTags([e],!1),t}async handleChainError(e,t,r,i,a){await Promise.all(this.handlers.map(s=>Ie(async()=>{if(!s.ignoreChain)try{await s.handleChainError?.(e,this.runId,this._parentRunId,this.tags,a)}catch(o){if((s.raiseError?console.error:console.warn)(`Error in handler ${s.constructor.name}, handleChainError: ${o}`),s.raiseError)throw o}},s.awaitHandlers)))}async handleChainEnd(e,t,r,i,a){await Promise.all(this.handlers.map(s=>Ie(async()=>{if(!s.ignoreChain)try{await s.handleChainEnd?.(e,this.runId,this._parentRunId,this.tags,a)}catch(o){if((s.raiseError?console.error:console.warn)(`Error in handler ${s.constructor.name}, handleChainEnd: ${o}`),s.raiseError)throw o}},s.awaitHandlers)))}async handleAgentAction(e){await Promise.all(this.handlers.map(t=>Ie(async()=>{if(!t.ignoreAgent)try{await t.handleAgentAction?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleAgentAction: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}async handleAgentEnd(e){await Promise.all(this.handlers.map(t=>Ie(async()=>{if(!t.ignoreAgent)try{await t.handleAgentEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleAgentEnd: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}}class zy extends Mi{getChild(e){const t=new Fe(this.runId);return t.setHandlers(this.inheritableHandlers),t.addTags(this.inheritableTags),t.addMetadata(this.inheritableMetadata),e&&t.addTags([e],!1),t}async handleToolError(e){await Promise.all(this.handlers.map(t=>Ie(async()=>{if(!t.ignoreAgent)try{await t.handleToolError?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleToolError: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}async handleToolEnd(e){await Promise.all(this.handlers.map(t=>Ie(async()=>{if(!t.ignoreAgent)try{await t.handleToolEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleToolEnd: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}}class Fe extends Uy{constructor(e,t){super(),Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"inheritableHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"inheritableTags",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"inheritableMetadata",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"callback_manager"}),Object.defineProperty(this,"_parentRunId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.handlers=t?.handlers??this.handlers,this.inheritableHandlers=t?.inheritableHandlers??this.inheritableHandlers,this.tags=t?.tags??this.tags,this.inheritableTags=t?.inheritableTags??this.inheritableTags,this.metadata=t?.metadata??this.metadata,this.inheritableMetadata=t?.inheritableMetadata??this.inheritableMetadata,this._parentRunId=e}getParentRunId(){return this._parentRunId}async handleLLMStart(e,t,r=void 0,i=void 0,a=void 0,s=void 0,o=void 0,u=void 0){return Promise.all(t.map(async(l,c)=>{const h=c===0&&r?r:Le();return await Promise.all(this.handlers.map(f=>{if(!f.ignoreLLM)return Lr(f)&&f._createRunForLLMStart(e,[l],h,this._parentRunId,a,this.tags,this.metadata,u),Ie(async()=>{try{await f.handleLLMStart?.(e,[l],h,this._parentRunId,a,this.tags,this.metadata,u)}catch(_){if((f.raiseError?console.error:console.warn)(`Error in handler ${f.constructor.name}, handleLLMStart: ${_}`),f.raiseError)throw _}},f.awaitHandlers)})),new Ec(h,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChatModelStart(e,t,r=void 0,i=void 0,a=void 0,s=void 0,o=void 0,u=void 0){return Promise.all(t.map(async(l,c)=>{const h=c===0&&r?r:Le();return await Promise.all(this.handlers.map(f=>{if(!f.ignoreLLM)return Lr(f)&&f._createRunForChatModelStart(e,[l],h,this._parentRunId,a,this.tags,this.metadata,u),Ie(async()=>{try{if(f.handleChatModelStart)await f.handleChatModelStart?.(e,[l],h,this._parentRunId,a,this.tags,this.metadata,u);else if(f.handleLLMStart){const _=pd(l);await f.handleLLMStart?.(e,[_],h,this._parentRunId,a,this.tags,this.metadata,u)}}catch(_){if((f.raiseError?console.error:console.warn)(`Error in handler ${f.constructor.name}, handleLLMStart: ${_}`),f.raiseError)throw _}},f.awaitHandlers)})),new Ec(h,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChainStart(e,t,r=Le(),i=void 0,a=void 0,s=void 0,o=void 0){return await Promise.all(this.handlers.map(u=>{if(!u.ignoreChain)return Lr(u)&&u._createRunForChainStart(e,t,r,this._parentRunId,this.tags,this.metadata,i,o),Ie(async()=>{try{await u.handleChainStart?.(e,t,r,this._parentRunId,this.tags,this.metadata,i,o)}catch(l){if((u.raiseError?console.error:console.warn)(`Error in handler ${u.constructor.name}, handleChainStart: ${l}`),u.raiseError)throw l}},u.awaitHandlers)})),new qy(r,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleToolStart(e,t,r=Le(),i=void 0,a=void 0,s=void 0,o=void 0){return await Promise.all(this.handlers.map(u=>{if(!u.ignoreAgent)return Lr(u)&&u._createRunForToolStart(e,t,r,this._parentRunId,this.tags,this.metadata,o),Ie(async()=>{try{await u.handleToolStart?.(e,t,r,this._parentRunId,this.tags,this.metadata,o)}catch(l){if((u.raiseError?console.error:console.warn)(`Error in handler ${u.constructor.name}, handleToolStart: ${l}`),u.raiseError)throw l}},u.awaitHandlers)})),new zy(r,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleRetrieverStart(e,t,r=Le(),i=void 0,a=void 0,s=void 0,o=void 0){return await Promise.all(this.handlers.map(u=>{if(!u.ignoreRetriever)return Lr(u)&&u._createRunForRetrieverStart(e,t,r,this._parentRunId,this.tags,this.metadata,o),Ie(async()=>{try{await u.handleRetrieverStart?.(e,t,r,this._parentRunId,this.tags,this.metadata,o)}catch(l){if((u.raiseError?console.error:console.warn)(`Error in handler ${u.constructor.name}, handleRetrieverStart: ${l}`),u.raiseError)throw l}},u.awaitHandlers)})),new By(r,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleCustomEvent(e,t,r,i,a){await Promise.all(this.handlers.map(s=>Ie(async()=>{if(!s.ignoreCustomEvent)try{await s.handleCustomEvent?.(e,t,r,this.tags,this.metadata)}catch(o){if((s.raiseError?console.error:console.warn)(`Error in handler ${s.constructor.name}, handleCustomEvent: ${o}`),s.raiseError)throw o}},s.awaitHandlers)))}addHandler(e,t=!0){this.handlers.push(e),t&&this.inheritableHandlers.push(e)}removeHandler(e){this.handlers=this.handlers.filter(t=>t!==e),this.inheritableHandlers=this.inheritableHandlers.filter(t=>t!==e)}setHandlers(e,t=!0){this.handlers=[],this.inheritableHandlers=[];for(const r of e)this.addHandler(r,t)}addTags(e,t=!0){this.removeTags(e),this.tags.push(...e),t&&this.inheritableTags.push(...e)}removeTags(e){this.tags=this.tags.filter(t=>!e.includes(t)),this.inheritableTags=this.inheritableTags.filter(t=>!e.includes(t))}addMetadata(e,t=!0){this.metadata={...this.metadata,...e},t&&(this.inheritableMetadata={...this.inheritableMetadata,...e})}removeMetadata(e){for(const t of Object.keys(e))delete this.metadata[t],delete this.inheritableMetadata[t]}copy(e=[],t=!0){const r=new Fe(this._parentRunId);for(const i of this.handlers){const a=this.inheritableHandlers.includes(i);r.addHandler(i,a)}for(const i of this.tags){const a=this.inheritableTags.includes(i);r.addTags([i],a)}for(const i of Object.keys(this.metadata)){const a=Object.keys(this.inheritableMetadata).includes(i);r.addMetadata({[i]:this.metadata[i]},a)}for(const i of e)r.handlers.filter(a=>a.name==="console_callback_handler").some(a=>a.name===i.name)||r.addHandler(i,t);return r}static fromHandlers(e){class t extends mn{constructor(){super(),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:Le()}),Object.assign(this,e)}}const r=new this;return r.addHandler(new t),r}static configure(e,t,r,i,a,s,o){return this._configureSync(e,t,r,i,a,s,o)}static _configureSync(e,t,r,i,a,s,o){let u;(e||t)&&(Array.isArray(e)||!e?(u=new Fe,u.setHandlers(e?.map(gi)??[],!0)):u=e,u=u.copy(Array.isArray(t)?t.map(gi):t?.handlers,!1));const l=Jt("LANGCHAIN_VERBOSE")==="true"||o?.verbose,c=Gr.getTraceableRunTree()?.tracingEnabled||Ly(),h=c||(Jt("LANGCHAIN_TRACING")??!1);if(l||h){if(u||(u=new Fe),l&&!u.handlers.some(f=>f.name===vc.prototype.name)){const f=new vc;u.addHandler(f,!0)}if(h&&!u.handlers.some(f=>f.name==="langchain_tracer")&&c){const f=new Gr;u.addHandler(f,!0)}if(c){const f=Gr.getTraceableRunTree();f&&u._parentRunId===void 0&&(u._parentRunId=f.id,u.handlers.find(p=>p.name==="langchain_tracer")?.updateFromRunTree(f))}}for(const{contextVar:f,inheritable:_=!0,handlerClass:p,envVar:b}of Dy()){const w=b&&Jt(b)==="true"&&p;let m;const g=f!==void 0?gd(f):void 0;g&&Jm(g)?m=g:w&&(m=new p({})),m!==void 0&&(u||(u=new Fe),u.handlers.some(v=>v.name===m.name)||u.addHandler(m,_))}return(r||i)&&u&&(u.addTags(r??[]),u.addTags(i??[],!1)),(a||s)&&u&&(u.addMetadata(a??{}),u.addMetadata(s??{},!1)),u}}function gi(n){return"name"in n?n:mn.fromMethods(n)}/*
|
|
92
|
+
* [js-sha1]{@link https://github.com/emn178/js-sha1}
|
|
93
|
+
*
|
|
94
|
+
* @version 0.6.0
|
|
95
|
+
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
96
|
+
* @copyright Chen, Yi-Cyuan 2014-2017
|
|
97
|
+
* @license MIT
|
|
98
|
+
*/var Hy=typeof window=="object"?window:{},me="0123456789abcdef".split(""),Gy=[-2147483648,8388608,32768,128],Qe=[24,16,8,0],$e=[];function nt(n){n?($e[0]=$e[16]=$e[1]=$e[2]=$e[3]=$e[4]=$e[5]=$e[6]=$e[7]=$e[8]=$e[9]=$e[10]=$e[11]=$e[12]=$e[13]=$e[14]=$e[15]=0,this.blocks=$e):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.h0=1732584193,this.h1=4023233417,this.h2=2562383102,this.h3=271733878,this.h4=3285377520,this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}nt.prototype.update=function(n){if(!this.finalized){var e=typeof n!="string";e&&n.constructor===Hy.ArrayBuffer&&(n=new Uint8Array(n));for(var t,r=0,i,a=n.length||0,s=this.blocks;r<a;){if(this.hashed&&(this.hashed=!1,s[0]=this.block,s[16]=s[1]=s[2]=s[3]=s[4]=s[5]=s[6]=s[7]=s[8]=s[9]=s[10]=s[11]=s[12]=s[13]=s[14]=s[15]=0),e)for(i=this.start;r<a&&i<64;++r)s[i>>2]|=n[r]<<Qe[i++&3];else for(i=this.start;r<a&&i<64;++r)t=n.charCodeAt(r),t<128?s[i>>2]|=t<<Qe[i++&3]:t<2048?(s[i>>2]|=(192|t>>6)<<Qe[i++&3],s[i>>2]|=(128|t&63)<<Qe[i++&3]):t<55296||t>=57344?(s[i>>2]|=(224|t>>12)<<Qe[i++&3],s[i>>2]|=(128|t>>6&63)<<Qe[i++&3],s[i>>2]|=(128|t&63)<<Qe[i++&3]):(t=65536+((t&1023)<<10|n.charCodeAt(++r)&1023),s[i>>2]|=(240|t>>18)<<Qe[i++&3],s[i>>2]|=(128|t>>12&63)<<Qe[i++&3],s[i>>2]|=(128|t>>6&63)<<Qe[i++&3],s[i>>2]|=(128|t&63)<<Qe[i++&3]);this.lastByteIndex=i,this.bytes+=i-this.start,i>=64?(this.block=s[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};nt.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var n=this.blocks,e=this.lastByteIndex;n[16]=this.block,n[e>>2]|=Gy[e&3],this.block=n[16],e>=56&&(this.hashed||this.hash(),n[0]=this.block,n[16]=n[1]=n[2]=n[3]=n[4]=n[5]=n[6]=n[7]=n[8]=n[9]=n[10]=n[11]=n[12]=n[13]=n[14]=n[15]=0),n[14]=this.hBytes<<3|this.bytes>>>29,n[15]=this.bytes<<3,this.hash()}};nt.prototype.hash=function(){var n=this.h0,e=this.h1,t=this.h2,r=this.h3,i=this.h4,a,s,o,u=this.blocks;for(s=16;s<80;++s)o=u[s-3]^u[s-8]^u[s-14]^u[s-16],u[s]=o<<1|o>>>31;for(s=0;s<20;s+=5)a=e&t|~e&r,o=n<<5|n>>>27,i=o+a+i+1518500249+u[s]<<0,e=e<<30|e>>>2,a=n&e|~n&t,o=i<<5|i>>>27,r=o+a+r+1518500249+u[s+1]<<0,n=n<<30|n>>>2,a=i&n|~i&e,o=r<<5|r>>>27,t=o+a+t+1518500249+u[s+2]<<0,i=i<<30|i>>>2,a=r&i|~r&n,o=t<<5|t>>>27,e=o+a+e+1518500249+u[s+3]<<0,r=r<<30|r>>>2,a=t&r|~t&i,o=e<<5|e>>>27,n=o+a+n+1518500249+u[s+4]<<0,t=t<<30|t>>>2;for(;s<40;s+=5)a=e^t^r,o=n<<5|n>>>27,i=o+a+i+1859775393+u[s]<<0,e=e<<30|e>>>2,a=n^e^t,o=i<<5|i>>>27,r=o+a+r+1859775393+u[s+1]<<0,n=n<<30|n>>>2,a=i^n^e,o=r<<5|r>>>27,t=o+a+t+1859775393+u[s+2]<<0,i=i<<30|i>>>2,a=r^i^n,o=t<<5|t>>>27,e=o+a+e+1859775393+u[s+3]<<0,r=r<<30|r>>>2,a=t^r^i,o=e<<5|e>>>27,n=o+a+n+1859775393+u[s+4]<<0,t=t<<30|t>>>2;for(;s<60;s+=5)a=e&t|e&r|t&r,o=n<<5|n>>>27,i=o+a+i-1894007588+u[s]<<0,e=e<<30|e>>>2,a=n&e|n&t|e&t,o=i<<5|i>>>27,r=o+a+r-1894007588+u[s+1]<<0,n=n<<30|n>>>2,a=i&n|i&e|n&e,o=r<<5|r>>>27,t=o+a+t-1894007588+u[s+2]<<0,i=i<<30|i>>>2,a=r&i|r&n|i&n,o=t<<5|t>>>27,e=o+a+e-1894007588+u[s+3]<<0,r=r<<30|r>>>2,a=t&r|t&i|r&i,o=e<<5|e>>>27,n=o+a+n-1894007588+u[s+4]<<0,t=t<<30|t>>>2;for(;s<80;s+=5)a=e^t^r,o=n<<5|n>>>27,i=o+a+i-899497514+u[s]<<0,e=e<<30|e>>>2,a=n^e^t,o=i<<5|i>>>27,r=o+a+r-899497514+u[s+1]<<0,n=n<<30|n>>>2,a=i^n^e,o=r<<5|r>>>27,t=o+a+t-899497514+u[s+2]<<0,i=i<<30|i>>>2,a=r^i^n,o=t<<5|t>>>27,e=o+a+e-899497514+u[s+3]<<0,r=r<<30|r>>>2,a=t^r^i,o=e<<5|e>>>27,n=o+a+n-899497514+u[s+4]<<0,t=t<<30|t>>>2;this.h0=this.h0+n<<0,this.h1=this.h1+e<<0,this.h2=this.h2+t<<0,this.h3=this.h3+r<<0,this.h4=this.h4+i<<0};nt.prototype.hex=function(){this.finalize();var n=this.h0,e=this.h1,t=this.h2,r=this.h3,i=this.h4;return me[n>>28&15]+me[n>>24&15]+me[n>>20&15]+me[n>>16&15]+me[n>>12&15]+me[n>>8&15]+me[n>>4&15]+me[n&15]+me[e>>28&15]+me[e>>24&15]+me[e>>20&15]+me[e>>16&15]+me[e>>12&15]+me[e>>8&15]+me[e>>4&15]+me[e&15]+me[t>>28&15]+me[t>>24&15]+me[t>>20&15]+me[t>>16&15]+me[t>>12&15]+me[t>>8&15]+me[t>>4&15]+me[t&15]+me[r>>28&15]+me[r>>24&15]+me[r>>20&15]+me[r>>16&15]+me[r>>12&15]+me[r>>8&15]+me[r>>4&15]+me[r&15]+me[i>>28&15]+me[i>>24&15]+me[i>>20&15]+me[i>>16&15]+me[i>>12&15]+me[i>>8&15]+me[i>>4&15]+me[i&15]};nt.prototype.toString=nt.prototype.hex;nt.prototype.digest=function(){this.finalize();var n=this.h0,e=this.h1,t=this.h2,r=this.h3,i=this.h4;return[n>>24&255,n>>16&255,n>>8&255,n&255,e>>24&255,e>>16&255,e>>8&255,e&255,t>>24&255,t>>16&255,t>>8&255,t&255,r>>24&255,r>>16&255,r>>8&255,r&255,i>>24&255,i>>16&255,i>>8&255,i&255]};nt.prototype.array=nt.prototype.digest;nt.prototype.arrayBuffer=function(){this.finalize();var n=new ArrayBuffer(20),e=new DataView(n);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),n};let Sc=!1;const Vy=n=>(Sc||(console.warn(["The default method for hashing keys is insecure and will be replaced in a future version,","but hasn't been replaced yet as to not break existing caches. It's recommended that you use","a more secure hashing algorithm to avoid cache poisoning.","","See this page for more information:","|","└> https://js.langchain.com/docs/troubleshooting/warnings/insecure-cache-algorithm"].join(`
|
|
99
|
+
`)),Sc=!0),new nt(!0).update(n).hex()),Wy=(...n)=>Vy(n.join("_"));class Jy{constructor(){Object.defineProperty(this,"keyEncoder",{enumerable:!0,configurable:!0,writable:!0,value:Wy})}makeDefaultKeyEncoder(e){this.keyEncoder=e}}const Ky=new Map;class Eo extends Jy{constructor(e){super(),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cache=e??new Map}lookup(e,t){return Promise.resolve(this.cache.get(this.keyEncoder(e,t))??null)}async update(e,t,r){this.cache.set(this.keyEncoder(e,t),r)}static global(){return new Eo(Ky)}}class So extends bt{}class yd extends So{static lc_name(){return"StringPromptValue"}constructor(e){super({value:e}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","prompt_values"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"value",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.value=e}toString(){return this.value}toChatMessages(){return[new Xe(this.value)]}}class bd extends So{static lc_name(){return"ChatPromptValue"}constructor(e){Array.isArray(e)&&(e={messages:e}),super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","prompt_values"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"messages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.messages=e.messages}toString(){return pd(this.messages)}toChatMessages(){return this.messages}}class Yy extends So{static lc_name(){return"ImagePromptValue"}constructor(e){"imageUrl"in e||(e={imageUrl:e}),super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","prompt_values"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"imageUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"value",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.imageUrl=e.imageUrl}toString(){return this.imageUrl.url}toChatMessages(){return[new Xe({content:[{type:"image_url",image_url:{detail:this.imageUrl.detail,url:this.imageUrl.url}}]})]}}const Qy=[400,401,402,403,404,405,406,407,409],Zy=n=>{if(n.message.startsWith("Cancel")||n.message.startsWith("AbortError")||n.name==="AbortError"||n?.code==="ECONNABORTED")throw n;const e=n?.response?.status??n?.status;if(e&&Qy.includes(+e))throw n;if(n?.error?.code==="insufficient_quota"){const t=new Error(n?.message);throw t.name="InsufficientQuotaError",t}};class Oo{constructor(e){Object.defineProperty(this,"maxConcurrency",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxRetries",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFailedAttempt",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"queue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxConcurrency=e.maxConcurrency??1/0,this.maxRetries=e.maxRetries??6,this.onFailedAttempt=e.onFailedAttempt??Zy;const t="default"in gt?gt.default:gt;this.queue=new t({concurrency:this.maxConcurrency})}call(e,...t){return this.queue.add(()=>ai(()=>e(...t).catch(r=>{throw r instanceof Error?r:new Error(r)}),{onFailedAttempt:this.onFailedAttempt,retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0})}callWithOptions(e,t,...r){return e.signal?Promise.race([this.call(t,...r),new Promise((i,a)=>{e.signal?.addEventListener("abort",()=>{a(new Error("AbortError"))})})]):this.call(t,...r)}fetch(...e){return this.call(()=>fetch(...e).then(t=>t.ok?t:Promise.reject(t)))}}const Zn={},Xy=new Oo({});async function eb(n){return n in Zn||(Zn[n]=Xy.fetch(`https://tiktoken.pages.dev/js/${n}.json`).then(e=>e.json()).then(e=>new _h(e)).catch(e=>{throw delete Zn[n],e})),await Zn[n]}async function tb(n){return eb(bh(n))}/*!
|
|
100
|
+
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
101
|
+
* (c) 2017-2022 Joachim Wester
|
|
102
|
+
* MIT licensed
|
|
103
|
+
*/const rb=Object.prototype.hasOwnProperty;function nb(n,e){return rb.call(n,e)}function ib(n){if(Array.isArray(n)){const t=new Array(n.length);for(let r=0;r<t.length;r++)t[r]=""+r;return t}if(Object.keys)return Object.keys(n);let e=[];for(let t in n)nb(n,t)&&e.push(t);return e}function Er(n){switch(typeof n){case"object":return JSON.parse(JSON.stringify(n));case"undefined":return null;default:return n}}function Ms(n){let e=0;const t=n.length;let r;for(;e<t;){if(r=n.charCodeAt(e),r>=48&&r<=57){e++;continue}return!1}return!0}function ab(n){return n.replace(/~1/g,"/").replace(/~0/g,"~")}function ks(n){if(n===void 0)return!0;if(n){if(Array.isArray(n)){for(let t=0,r=n.length;t<r;t++)if(ks(n[t]))return!0}else if(typeof n=="object"){const t=ib(n),r=t.length;for(var e=0;e<r;e++)if(ks(n[t[e]]))return!0}}return!1}function Oc(n,e){const t=[n];for(const r in e){const i=typeof e[r]=="object"?JSON.stringify(e[r],null,2):e[r];typeof i<"u"&&t.push(`${r}: ${i}`)}return t.join(`
|
|
104
|
+
`)}class sb extends Error{constructor(e,t,r,i,a){super(Oc(e,{name:t,index:r,operation:i,tree:a})),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"index",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"operation",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"tree",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.setPrototypeOf(this,new.target.prototype),this.message=Oc(e,{name:t,index:r,operation:i,tree:a})}}const Re=sb,Wt={add:function(n,e,t){return n[e]=this.value,{newDocument:t}},remove:function(n,e,t){var r=n[e];return delete n[e],{newDocument:t,removed:r}},replace:function(n,e,t){var r=n[e];return n[e]=this.value,{newDocument:t,removed:r}},move:function(n,e,t){let r=Ns(t,this.path);r&&(r=Er(r));const i=Wr(t,{op:"remove",path:this.from}).removed;return Wr(t,{op:"add",path:this.path,value:i}),{newDocument:t,removed:r}},copy:function(n,e,t){const r=Ns(t,this.from);return Wr(t,{op:"add",path:this.path,value:Er(r)}),{newDocument:t}},test:function(n,e,t){return{newDocument:t,test:bi(n[e],this.value)}},_get:function(n,e,t){return this.value=n[e],{newDocument:t}}};var ob={add:function(n,e,t){return Ms(e)?n.splice(e,0,this.value):n[e]=this.value,{newDocument:t,index:e}},remove:function(n,e,t){var r=n.splice(e,1);return{newDocument:t,removed:r[0]}},replace:function(n,e,t){var r=n[e];return n[e]=this.value,{newDocument:t,removed:r}},move:Wt.move,copy:Wt.copy,test:Wt.test,_get:Wt._get};function Ns(n,e){if(e=="")return n;var t={op:"_get",path:e};return Wr(n,t),t.value}function Wr(n,e,t=!1,r=!0,i=!0,a=0){if(t&&(typeof t=="function"?t(e,0,n,e.path):Ls(e,0)),e.path===""){let s={newDocument:n};if(e.op==="add")return s.newDocument=e.value,s;if(e.op==="replace")return s.newDocument=e.value,s.removed=n,s;if(e.op==="move"||e.op==="copy")return s.newDocument=Ns(n,e.from),e.op==="move"&&(s.removed=n),s;if(e.op==="test"){if(s.test=bi(n,e.value),s.test===!1)throw new Re("Test operation failed","TEST_OPERATION_FAILED",a,e,n);return s.newDocument=n,s}else{if(e.op==="remove")return s.removed=n,s.newDocument=null,s;if(e.op==="_get")return e.value=n,s;if(t)throw new Re("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",a,e,n);return s}}else{r||(n=Er(n));const o=(e.path||"").split("/");let u=n,l=1,c=o.length,h,f,_;for(typeof t=="function"?_=t:_=Ls;;){if(f=o[l],f&&f.indexOf("~")!=-1&&(f=ab(f)),i&&(f=="__proto__"||f=="prototype"&&l>0&&o[l-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(t&&h===void 0&&(u[f]===void 0?h=o.slice(0,l).join("/"):l==c-1&&(h=e.path),h!==void 0&&_(e,0,n,h)),l++,Array.isArray(u)){if(f==="-")f=u.length;else{if(t&&!Ms(f))throw new Re("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",a,e,n);Ms(f)&&(f=~~f)}if(l>=c){if(t&&e.op==="add"&&f>u.length)throw new Re("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",a,e,n);const p=ob[e.op].call(e,u,f,n);if(p.test===!1)throw new Re("Test operation failed","TEST_OPERATION_FAILED",a,e,n);return p}}else if(l>=c){const p=Wt[e.op].call(e,u,f,n);if(p.test===!1)throw new Re("Test operation failed","TEST_OPERATION_FAILED",a,e,n);return p}if(u=u[f],t&&l<c&&(!u||typeof u!="object"))throw new Re("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",a,e,n)}}}function yi(n,e,t,r=!0,i=!0){if(t&&!Array.isArray(e))throw new Re("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");r||(n=Er(n));const a=new Array(e.length);for(let s=0,o=e.length;s<o;s++)a[s]=Wr(n,e[s],t,!0,i,s),n=a[s].newDocument;return a.newDocument=n,a}function Ls(n,e,t,r){if(typeof n!="object"||n===null||Array.isArray(n))throw new Re("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,n,t);if(Wt[n.op]){if(typeof n.path!="string")throw new Re("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,n,t);if(n.path.indexOf("/")!==0&&n.path.length>0)throw new Re('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",e,n,t);if((n.op==="move"||n.op==="copy")&&typeof n.from!="string")throw new Re("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",e,n,t);if((n.op==="add"||n.op==="replace"||n.op==="test")&&n.value===void 0)throw new Re("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",e,n,t);if((n.op==="add"||n.op==="replace"||n.op==="test")&&ks(n.value))throw new Re("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",e,n,t);if(t){if(n.op=="add"){var i=n.path.split("/").length,a=r.split("/").length;if(i!==a+1&&i!==a)throw new Re("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",e,n,t)}else if(n.op==="replace"||n.op==="remove"||n.op==="_get"){if(n.path!==r)throw new Re("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",e,n,t)}else if(n.op==="move"||n.op==="copy"){var s={op:"_get",path:n.from,value:void 0},o=ub([s],t);if(o&&o.name==="OPERATION_PATH_UNRESOLVABLE")throw new Re("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,n,t)}}}else throw new Re("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,n,t)}function ub(n,e,t){try{if(!Array.isArray(n))throw new Re("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)yi(Er(e),Er(n),t||!0);else{t=t||Ls;for(var r=0;r<n.length;r++)t(n[r],r,e,void 0)}}catch(i){if(i instanceof Re)return i;throw i}}function bi(n,e){if(n===e)return!0;if(n&&e&&typeof n=="object"&&typeof e=="object"){var t=Array.isArray(n),r=Array.isArray(e),i,a,s;if(t&&r){if(a=n.length,a!=e.length)return!1;for(i=a;i--!==0;)if(!bi(n[i],e[i]))return!1;return!0}if(t!=r)return!1;var o=Object.keys(n);if(a=o.length,a!==Object.keys(e).length)return!1;for(i=a;i--!==0;)if(!e.hasOwnProperty(o[i]))return!1;for(i=a;i--!==0;)if(s=o[i],!bi(n[s],e[s]))return!1;return!0}return n!==n&&e!==e}class lb{getStore(){}run(e,t){return t()}enterWith(e){}}const cb=new lb,Tc=Symbol.for("lc:child_config");class fb{getInstance(){return nn()??cb}getRunnableConfig(){return this.getInstance().getStore()?.extra?.[Tc]}runWithConfig(e,t,r){const i=Fe._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata),a=this.getInstance(),s=a.getStore(),o=i?.getParentRunId(),u=i?.handlers?.find(c=>c?.name==="langchain_tracer");let l;return u&&o?l=u.getRunTreeWithTracingConfig(o):r||(l=new qe({name:"<runnable_lambda>",tracingEnabled:!1})),l&&(l.extra={...l.extra,[Tc]:e}),s!==void 0&&s[ni]!==void 0&&(l===void 0&&(l={}),l[ni]=s[ni]),a.run(l,t)}initializeGlobalInstance(e){nn()===void 0&&My(e)}}const $t=new fb,ws=25;async function rt(n){return Fe._configureSync(n?.callbacks,void 0,n?.tags,void 0,n?.metadata)}function Fs(...n){const e={};for(const t of n.filter(r=>!!r))for(const r of Object.keys(t))if(r==="metadata")e[r]={...e[r],...t[r]};else if(r==="tags"){const i=e[r]??[];e[r]=[...new Set(i.concat(t[r]??[]))]}else if(r==="configurable")e[r]={...e[r],...t[r]};else if(r==="timeout")e.timeout===void 0?e.timeout=t.timeout:t.timeout!==void 0&&(e.timeout=Math.min(e.timeout,t.timeout));else if(r==="signal")e.signal===void 0?e.signal=t.signal:t.signal!==void 0&&("any"in AbortSignal?e.signal=AbortSignal.any([e.signal,t.signal]):e.signal=t.signal);else if(r==="callbacks"){const i=e.callbacks,a=t.callbacks;if(Array.isArray(a))if(!i)e.callbacks=a;else if(Array.isArray(i))e.callbacks=i.concat(a);else{const s=i.copy();for(const o of a)s.addHandler(gi(o),!0);e.callbacks=s}else if(a)if(!i)e.callbacks=a;else if(Array.isArray(i)){const s=a.copy();for(const o of i)s.addHandler(gi(o),!0);e.callbacks=s}else e.callbacks=new Fe(a._parentRunId,{handlers:i.handlers.concat(a.handlers),inheritableHandlers:i.inheritableHandlers.concat(a.inheritableHandlers),tags:Array.from(new Set(i.tags.concat(a.tags))),inheritableTags:Array.from(new Set(i.inheritableTags.concat(a.inheritableTags))),metadata:{...i.metadata,...a.metadata}})}else{const i=r;e[i]=t[i]??e[i]}return e}const db=new Set(["string","number","boolean"]);function be(n){const e=$t.getRunnableConfig();let t={tags:[],metadata:{},recursionLimit:25,runId:void 0};if(e){const{runId:r,runName:i,...a}=e;t=Object.entries(a).reduce((s,[o,u])=>(u!==void 0&&(s[o]=u),s),t)}if(n&&(t=Object.entries(n).reduce((r,[i,a])=>(a!==void 0&&(r[i]=a),r),t)),t?.configurable)for(const r of Object.keys(t.configurable))db.has(typeof t.configurable[r])&&!t.metadata?.[r]&&(t.metadata||(t.metadata={}),t.metadata[r]=t.configurable[r]);if(t.timeout!==void 0){if(t.timeout<=0)throw new Error("Timeout must be a positive number");const r=AbortSignal.timeout(t.timeout);t.signal!==void 0?"any"in AbortSignal&&(t.signal=AbortSignal.any([t.signal,r])):t.signal=r,delete t.timeout}return t}function Ce(n={},{callbacks:e,maxConcurrency:t,recursionLimit:r,runName:i,configurable:a,runId:s}={}){const o=be(n);return e!==void 0&&(delete o.runName,o.callbacks=e),r!==void 0&&(o.recursionLimit=r),t!==void 0&&(o.maxConcurrency=t),i!==void 0&&(o.runName=i),a!==void 0&&(o.configurable={...o.configurable,...a}),s!==void 0&&delete o.runId,o}function Sr(n){return n?{configurable:n.configurable,recursionLimit:n.recursionLimit,callbacks:n.callbacks,tags:n.tags,metadata:n.metadata,maxConcurrency:n.maxConcurrency,timeout:n.timeout,signal:n.signal}:void 0}async function jt(n,e){if(e===void 0)return n;let t;return Promise.race([n.catch(r=>{if(!e?.aborted)throw r}),new Promise((r,i)=>{t=()=>{i(new Error("Aborted"))},e.addEventListener("abort",t),e.aborted&&i(new Error("Aborted"))})]).finally(()=>e.removeEventListener("abort",t))}class Ve extends ReadableStream{constructor(){super(...arguments),Object.defineProperty(this,"reader",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}ensureReader(){this.reader||(this.reader=this.getReader())}async next(){this.ensureReader();try{const e=await this.reader.read();return e.done?(this.reader.releaseLock(),{done:!0,value:void 0}):{done:!1,value:e.value}}catch(e){throw this.reader.releaseLock(),e}}async return(){if(this.ensureReader(),this.locked){const e=this.reader.cancel();this.reader.releaseLock(),await e}return{done:!0,value:void 0}}async throw(e){if(this.ensureReader(),this.locked){const t=this.reader.cancel();this.reader.releaseLock(),await t}throw e}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){await this.return()}static fromReadableStream(e){const t=e.getReader();return new Ve({start(r){return i();function i(){return t.read().then(({done:a,value:s})=>{if(a){r.close();return}return r.enqueue(s),i()})}},cancel(){t.releaseLock()}})}static fromAsyncGenerator(e){return new Ve({async pull(t){const{value:r,done:i}=await e.next();i&&t.close(),t.enqueue(r)},async cancel(t){await e.return(t)}})}}function _d(n,e=2){const t=Array.from({length:e},()=>[]);return t.map(async function*(i){for(;;)if(i.length===0){const a=await n.next();for(const s of t)s.push(a)}else{if(i[0].done)return;yield i.shift().value}})}function To(n,e){if(Array.isArray(n)&&Array.isArray(e))return n.concat(e);if(typeof n=="string"&&typeof e=="string")return n+e;if(typeof n=="number"&&typeof e=="number")return n+e;if("concat"in n&&typeof n.concat=="function")return n.concat(e);if(typeof n=="object"&&typeof e=="object"){const t={...n};for(const[r,i]of Object.entries(e))r in t&&!Array.isArray(t[r])?t[r]=To(t[r],i):t[r]=i;return t}else throw new Error(`Cannot concat ${typeof n} and ${typeof e}`)}class Rr{constructor(e){Object.defineProperty(this,"generator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"setup",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signal",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"firstResult",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"firstResultUsed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.generator=e.generator,this.config=e.config,this.signal=e.signal??this.config?.signal,this.setup=new Promise((t,r)=>{$t.runWithConfig(Sr(e.config),async()=>{this.firstResult=e.generator.next(),e.startSetup?this.firstResult.then(e.startSetup).then(t,r):this.firstResult.then(i=>t(void 0),r)},!0)})}async next(...e){return this.signal?.throwIfAborted(),this.firstResultUsed?$t.runWithConfig(Sr(this.config),this.signal?async()=>jt(this.generator.next(...e),this.signal):async()=>this.generator.next(...e),!0):(this.firstResultUsed=!0,this.firstResult)}async return(e){return this.generator.return(e)}async throw(e){return this.generator.throw(e)}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){await this.return()}}async function hb(n,e,t,r,...i){const a=new Rr({generator:e,startSetup:t,signal:r}),s=await a.setup;return{output:n(a,s,...i),setup:s}}class xt{constructor(e){Object.defineProperty(this,"ops",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.ops=e.ops??[]}concat(e){const t=this.ops.concat(e.ops),r=yi({},t);return new an({ops:t,state:r[r.length-1].newDocument})}}class an extends xt{constructor(e){super(e),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.state=e.state}concat(e){const t=this.ops.concat(e.ops),r=yi(this.state,e.ops);return new an({ops:t,state:r[r.length-1].newDocument})}static fromRunLogPatch(e){const t=yi({},e.ops);return new an({ops:e.ops,state:t[t.length-1].newDocument})}}const pb=n=>n.name==="log_stream_tracer";async function Pc(n,e){if(e==="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.");const{inputs:t}=n;if(["retriever","llm","prompt"].includes(n.run_type))return t;if(!(Object.keys(t).length===1&&t?.input===""))return t.input}async function xc(n,e){const{outputs:t}=n;return e==="original"||["retriever","llm","prompt"].includes(n.run_type)?t:t!==void 0&&Object.keys(t).length===1&&t?.output!==void 0?t.output:t}function mb(n){return n!==void 0&&n.message!==void 0}class Ac extends gn{constructor(e){super({_awaitHandler:!0,...e}),Object.defineProperty(this,"autoClose",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"includeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_schemaFormat",{enumerable:!0,configurable:!0,writable:!0,value:"original"}),Object.defineProperty(this,"rootId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"keyMapByRunId",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"counterMapByRunName",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"transformStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"writer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"receiveStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"log_stream_tracer"}),Object.defineProperty(this,"lc_prefer_streaming",{enumerable:!0,configurable:!0,writable:!0,value:!0}),this.autoClose=e?.autoClose??!0,this.includeNames=e?.includeNames,this.includeTypes=e?.includeTypes,this.includeTags=e?.includeTags,this.excludeNames=e?.excludeNames,this.excludeTypes=e?.excludeTypes,this.excludeTags=e?.excludeTags,this._schemaFormat=e?._schemaFormat??this._schemaFormat,this.transformStream=new TransformStream,this.writer=this.transformStream.writable.getWriter(),this.receiveStream=Ve.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){if(e.id===this.rootId)return!1;const t=e.tags??[];let r=this.includeNames===void 0&&this.includeTags===void 0&&this.includeTypes===void 0;return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(e.run_type)),this.includeTags!==void 0&&(r=r||t.find(i=>this.includeTags?.includes(i))!==void 0),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(e.run_type)),this.excludeTags!==void 0&&(r=r&&t.every(i=>!this.excludeTags?.includes(i))),r}async*tapOutputIterable(e,t){for await(const r of t){if(e!==this.rootId){const i=this.keyMapByRunId[e];i&&await this.writer.write(new xt({ops:[{op:"add",path:`/logs/${i}/streamed_output/-`,value:r}]}))}yield r}}async onRunCreate(e){if(this.rootId===void 0&&(this.rootId=e.id,await this.writer.write(new xt({ops:[{op:"replace",path:"",value:{id:e.id,name:e.name,type:e.run_type,streamed_output:[],final_output:void 0,logs:{}}}]}))),!this._includeRun(e))return;this.counterMapByRunName[e.name]===void 0&&(this.counterMapByRunName[e.name]=0),this.counterMapByRunName[e.name]+=1;const t=this.counterMapByRunName[e.name];this.keyMapByRunId[e.id]=t===1?e.name:`${e.name}:${t}`;const r={id:e.id,name:e.name,type:e.run_type,tags:e.tags??[],metadata:e.extra?.metadata??{},start_time:new Date(e.start_time).toISOString(),streamed_output:[],streamed_output_str:[],final_output:void 0,end_time:void 0};this._schemaFormat==="streaming_events"&&(r.inputs=await Pc(e,this._schemaFormat)),await this.writer.write(new xt({ops:[{op:"add",path:`/logs/${this.keyMapByRunId[e.id]}`,value:r}]}))}async onRunUpdate(e){try{const t=this.keyMapByRunId[e.id];if(t===void 0)return;const r=[];this._schemaFormat==="streaming_events"&&r.push({op:"replace",path:`/logs/${t}/inputs`,value:await Pc(e,this._schemaFormat)}),r.push({op:"add",path:`/logs/${t}/final_output`,value:await xc(e,this._schemaFormat)}),e.end_time!==void 0&&r.push({op:"add",path:`/logs/${t}/end_time`,value:new Date(e.end_time).toISOString()});const i=new xt({ops:r});await this.writer.write(i)}finally{if(e.id===this.rootId){const t=new xt({ops:[{op:"replace",path:"/final_output",value:await xc(e,this._schemaFormat)}]});await this.writer.write(t),this.autoClose&&await this.writer.close()}}}async onLLMNewToken(e,t,r){const i=this.keyMapByRunId[e.id];if(i===void 0)return;const a=e.inputs.messages!==void 0;let s;a?mb(r?.chunk)?s=r?.chunk:s=new $i({id:`run-${e.id}`,content:t}):s=t;const o=new xt({ops:[{op:"add",path:`/logs/${i}/streamed_output_str/-`,value:t},{op:"add",path:`/logs/${i}/streamed_output/-`,value:s}]});await this.writer.write(o)}}const gb="__run";class _i{constructor(e){Object.defineProperty(this,"text",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"generationInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.text=e.text,this.generationInfo=e.generationInfo}concat(e){return new _i({text:this.text+e.text,generationInfo:{...this.generationInfo,...e.generationInfo}})}}function Xn({name:n,serialized:e}){return n!==void 0?n:e?.name!==void 0?e.name:e?.id!==void 0&&Array.isArray(e?.id)?e.id[e.id.length-1]:"Unnamed"}const yb=n=>n.name==="event_stream_tracer";class bb extends gn{constructor(e){super({_awaitHandler:!0,...e}),Object.defineProperty(this,"autoClose",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"includeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"runInfoMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"tappedPromises",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"transformStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"writer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"receiveStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"event_stream_tracer"}),Object.defineProperty(this,"lc_prefer_streaming",{enumerable:!0,configurable:!0,writable:!0,value:!0}),this.autoClose=e?.autoClose??!0,this.includeNames=e?.includeNames,this.includeTypes=e?.includeTypes,this.includeTags=e?.includeTags,this.excludeNames=e?.excludeNames,this.excludeTypes=e?.excludeTypes,this.excludeTags=e?.excludeTags,this.transformStream=new TransformStream,this.writer=this.transformStream.writable.getWriter(),this.receiveStream=Ve.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){const t=e.tags??[];let r=this.includeNames===void 0&&this.includeTags===void 0&&this.includeTypes===void 0;return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(e.runType)),this.includeTags!==void 0&&(r=r||t.find(i=>this.includeTags?.includes(i))!==void 0),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(e.runType)),this.excludeTags!==void 0&&(r=r&&t.every(i=>!this.excludeTags?.includes(i))),r}async*tapOutputIterable(e,t){const r=await t.next();if(r.done)return;const i=this.runInfoMap.get(e);if(i===void 0){yield r.value;return}function a(o,u){return o==="llm"&&typeof u=="string"?new _i({text:u}):u}let s=this.tappedPromises.get(e);if(s===void 0){let o;s=new Promise(u=>{o=u}),this.tappedPromises.set(e,s);try{const u={event:`on_${i.runType}_stream`,run_id:e,name:i.name,tags:i.tags,metadata:i.metadata,data:{}};await this.send({...u,data:{chunk:a(i.runType,r.value)}},i),yield r.value;for await(const l of t)i.runType!=="tool"&&i.runType!=="retriever"&&await this.send({...u,data:{chunk:a(i.runType,l)}},i),yield l}finally{o()}}else{yield r.value;for await(const o of t)yield o}}async send(e,t){this._includeRun(t)&&await this.writer.write(e)}async sendEndEvent(e,t){const r=this.tappedPromises.get(e.run_id);r!==void 0?r.then(()=>{this.send(e,t)}):await this.send(e,t)}async onLLMStart(e){const t=Xn(e),r=e.inputs.messages!==void 0?"chat_model":"llm",i={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:r,inputs:e.inputs};this.runInfoMap.set(e.id,i);const a=`on_${r}_start`;await this.send({event:a,data:{input:e.inputs},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},i)}async onLLMNewToken(e,t,r){const i=this.runInfoMap.get(e.id);let a,s;if(i===void 0)throw new Error(`onLLMNewToken: Run ID ${e.id} not found in run map.`);if(this.runInfoMap.size!==1){if(i.runType==="chat_model")s="on_chat_model_stream",r?.chunk===void 0?a=new $i({content:t,id:`run-${e.id}`}):a=r.chunk.message;else if(i.runType==="llm")s="on_llm_stream",r?.chunk===void 0?a=new _i({text:t}):a=r.chunk;else throw new Error(`Unexpected run type ${i.runType}`);await this.send({event:s,data:{chunk:a},run_id:e.id,name:i.name,tags:i.tags,metadata:i.metadata},i)}}async onLLMEnd(e){const t=this.runInfoMap.get(e.id);this.runInfoMap.delete(e.id);let r;if(t===void 0)throw new Error(`onLLMEnd: Run ID ${e.id} not found in run map.`);const i=e.outputs?.generations;let a;if(t.runType==="chat_model"){for(const s of i??[]){if(a!==void 0)break;a=s[0]?.message}r="on_chat_model_end"}else if(t.runType==="llm")a={generations:i?.map(s=>s.map(o=>({text:o.text,generationInfo:o.generationInfo}))),llmOutput:e.outputs?.llmOutput??{}},r="on_llm_end";else throw new Error(`onLLMEnd: Unexpected run type: ${t.runType}`);await this.sendEndEvent({event:r,data:{output:a,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onChainStart(e){const t=Xn(e),r=e.run_type??"chain",i={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:e.run_type};let a={};e.inputs.input===""&&Object.keys(e.inputs).length===1?(a={},i.inputs={}):e.inputs.input!==void 0?(a.input=e.inputs.input,i.inputs=e.inputs.input):(a.input=e.inputs,i.inputs=e.inputs),this.runInfoMap.set(e.id,i),await this.send({event:`on_${r}_start`,data:a,name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},i)}async onChainEnd(e){const t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onChainEnd: Run ID ${e.id} not found in run map.`);const r=`on_${e.run_type}_end`,i=e.inputs??t.inputs??{},s={output:e.outputs?.output??e.outputs,input:i};i.input&&Object.keys(i).length===1&&(s.input=i.input,t.inputs=i.input),await this.sendEndEvent({event:r,data:s,run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata??{}},t)}async onToolStart(e){const t=Xn(e),r={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"tool",inputs:e.inputs??{}};this.runInfoMap.set(e.id,r),await this.send({event:"on_tool_start",data:{input:e.inputs??{}},name:t,run_id:e.id,tags:e.tags??[],metadata:e.extra?.metadata??{}},r)}async onToolEnd(e){const t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onToolEnd: Run ID ${e.id} not found in run map.`);if(t.inputs===void 0)throw new Error(`onToolEnd: Run ID ${e.id} is a tool call, and is expected to have traced inputs.`);const r=e.outputs?.output===void 0?e.outputs:e.outputs.output;await this.sendEndEvent({event:"on_tool_end",data:{output:r,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onRetrieverStart(e){const t=Xn(e),i={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"retriever",inputs:{query:e.inputs.query}};this.runInfoMap.set(e.id,i),await this.send({event:"on_retriever_start",data:{input:{query:e.inputs.query}},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},i)}async onRetrieverEnd(e){const t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onRetrieverEnd: Run ID ${e.id} not found in run map.`);await this.sendEndEvent({event:"on_retriever_end",data:{output:e.outputs?.documents??e.outputs,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async handleCustomEvent(e,t,r){const i=this.runInfoMap.get(r);if(i===void 0)throw new Error(`handleCustomEvent: Run ID ${r} not found in run map.`);await this.send({event:"on_custom_event",run_id:r,name:e,tags:i.tags,metadata:i.metadata,data:t},i)}async finish(){const e=[...this.tappedPromises.values()];Promise.all(e).finally(()=>{this.writer.close()})}}class vd extends gn{constructor({config:e,onStart:t,onEnd:r,onError:i}){super({_awaitHandler:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RootListenersTracer"}),Object.defineProperty(this,"rootId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"argOnStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"argOnEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"argOnError",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.config=e,this.argOnStart=t,this.argOnEnd=r,this.argOnError=i}persistRun(e){return Promise.resolve()}async onRunCreate(e){this.rootId||(this.rootId=e.id,this.argOnStart&&await this.argOnStart(e,this.config))}async onRunUpdate(e){e.id===this.rootId&&(e.error?this.argOnError&&await this.argOnError(e,this.config):this.argOnEnd&&await this.argOnEnd(e,this.config))}}function Po(n){return n?n.lc_runnable:!1}class _b{constructor(e){Object.defineProperty(this,"includeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.includeNames=e.includeNames,this.includeTypes=e.includeTypes,this.includeTags=e.includeTags,this.excludeNames=e.excludeNames,this.excludeTypes=e.excludeTypes,this.excludeTags=e.excludeTags}includeEvent(e,t){let r=this.includeNames===void 0&&this.includeTypes===void 0&&this.includeTags===void 0;const i=e.tags??[];return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(t)),this.includeTags!==void 0&&(r=r||i.some(a=>this.includeTags?.includes(a))),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(t)),this.excludeTags!==void 0&&(r=r&&i.every(a=>!this.excludeTags?.includes(a))),r}}function Es(n){return n.replace(/[^a-zA-Z-_0-9]/g,"_")}const vb=["*","_","`"];function wb(n){let e="";for(const[t,r]of Object.entries(n))e+=` classDef ${t} ${r};
|
|
105
|
+
`;return e}function Eb(n,e,t){const{firstNode:r,lastNode:i,nodeColors:a,withStyles:s=!0,curveStyle:o="linear",wrapLabelNWords:u=9}=t??{};let l=s?`%%{init: {'flowchart': {'curve': '${o}'}}}%%
|
|
106
|
+
graph TD;
|
|
107
|
+
`:`graph TD;
|
|
108
|
+
`;if(s){const _="default",p={[_]:"{0}({1})"};r!==void 0&&(p[r]="{0}([{1}]):::first"),i!==void 0&&(p[i]="{0}([{1}]):::last");for(const[b,w]of Object.entries(n)){const m=w.name.split(":").pop()??"";let v=vb.some(O=>m.startsWith(O)&&m.endsWith(O))?`<p>${m}</p>`:m;Object.keys(w.metadata??{}).length&&(v+=`<hr/><small><em>${Object.entries(w.metadata??{}).map(([O,C])=>`${O} = ${C}`).join(`
|
|
109
|
+
`)}</em></small>`);const E=(p[b]??p[_]).replace("{0}",Es(b)).replace("{1}",v);l+=` ${E}
|
|
110
|
+
`}}const c={};for(const _ of e){const p=_.source.split(":"),b=_.target.split(":"),w=p.filter((m,g)=>m===b[g]).join(":");c[w]||(c[w]=[]),c[w].push(_)}const h=new Set;function f(_,p){const b=_.length===1&&_[0].source===_[0].target;if(p&&!b){const w=p.split(":").pop();if(h.has(w))throw new Error(`Found duplicate subgraph '${w}' -- this likely means that you're reusing a subgraph node with the same name. Please adjust your graph to have subgraph nodes with unique names.`);h.add(w),l+=` subgraph ${w}
|
|
111
|
+
`}for(const w of _){const{source:m,target:g,data:v,conditional:E}=w;let O="";if(v!==void 0){let C=v;const R=C.split(" ");R.length>u&&(C=Array.from({length:Math.ceil(R.length/u)},(I,$)=>R.slice($*u,($+1)*u).join(" ")).join(" <br> ")),O=E?` -. ${C} .-> `:` -- ${C} --> `}else O=E?" -.-> ":" --> ";l+=` ${Es(m)}${O}${Es(g)};
|
|
112
|
+
`}for(const w in c)w.startsWith(`${p}:`)&&w!==p&&f(c[w],w);p&&!b&&(l+=` end
|
|
113
|
+
`)}f(c[""]??[],"");for(const _ in c)!_.includes(":")&&_!==""&&f(c[_],_);return s&&(l+=wb(a??{})),l}async function Sb(n,e){return Ob(n,{...e,imageType:"png"})}async function Ob(n,e){let t=e?.backgroundColor??"white";const r=e?.imageType,i=btoa(n);t!==void 0&&(/^#(?:[0-9a-fA-F]{3}){1,2}$/.test(t)||(t=`!${t}`));const a=`https://mermaid.ink/img/${i}?bgColor=${t}&type=${r}`,s=await fetch(a);if(!s.ok)throw new Error(["Failed to render the graph using the Mermaid.INK API.",`Status code: ${s.status}`,`Status text: ${s.statusText}`].join(`
|
|
114
|
+
`));return await s.blob()}function _t(n){if(typeof n!="object"||n===null)return!1;const e=n;if(!("_zod"in e))return!1;const t=e._zod;return typeof t=="object"&&t!==null&&"def"in t}function Mt(n){if(typeof n!="object"||n===null)return!1;const e=n;if(!("_def"in e)||"_zod"in e)return!1;const t=e._def;return typeof t=="object"&&t!=null&&"typeName"in t}function wd(n){return!n||typeof n!="object"||Array.isArray(n)?!1:!!(_t(n)||Mt(n))}async function Ed(n,e){if(_t(n))return vh(n,e);if(Mt(n))return n.parse(e);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function Tb(n){if(_t(n))return Lt.get(n)?.description;if(Mt(n)||"description"in n&&typeof n.description=="string")return n.description}function Pb(n){return wd(n)?Mt(n)?n._def.typeName==="ZodString":_t(n)?n._zod.def.type==="string":!1:!1}function Jr(n){return _t(n)?typeof n=="object"&&n!==null&&"_zod"in n&&typeof n._zod=="object"&&n._zod!==null&&"def"in n._zod&&typeof n._zod.def=="object"&&n._zod.def!==null&&"type"in n._zod.def&&n._zod.def.type==="object":!1}function Sd(n){return _t(n)?typeof n=="object"&&n!==null&&"_zod"in n&&typeof n._zod=="object"&&n._zod!==null&&"def"in n._zod&&typeof n._zod.def=="object"&&n._zod.def!==null&&"type"in n._zod.def&&n._zod.def.type==="array":!1}function Ds(n,e=!1){if(Mt(n))return n.strict();if(Jr(n)){const t=n._zod.def.shape;if(e)for(const[a,s]of Object.entries(n._zod.def.shape)){if(Jr(s)){const u=Ds(s,e);t[a]=u}else if(Sd(s)){let u=s._zod.def.element;Jr(u)&&(u=Ds(u,e)),t[a]=si(s,{...s._zod.def,element:u})}else t[a]=s;const o=Lt.get(s);o&&Lt.add(t[a],o)}const r=si(n,{...n._zod.def,shape:t,catchall:wh(Eh)}),i=Lt.get(n);return i&&Lt.add(r,i),r}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function xb(n){return Mt(n)&&"typeName"in n._def&&n._def.typeName==="ZodEffects"}function Ab(n){return _t(n)&&n._zod.def.type==="pipe"}function Br(n,e=!1){if(Mt(n))return xb(n)?Br(n._def.schema,e):n;if(_t(n)){let t=n;if(Ab(n)&&(t=Br(n._zod.def.in,e)),e){if(Jr(t)){const i=t._zod.def.shape;for(const[a,s]of Object.entries(t._zod.def.shape))i[a]=Br(s,e);t=si(t,{...t._zod.def,shape:i})}else if(Sd(t)){const i=Br(t._zod.def.element,e);t=si(t,{...t._zod.def,element:i})}}const r=Lt.get(n);return r&&Lt.add(t,r),t}throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function Rb(n){if(_t(n)){const e=Br(n,!0);if(Jr(e)){const t=Ds(e,!0);return Fo(t)}else return Fo(n)}return Mt(n)?Nt(n):n}function Ib(n,e){if(n!==void 0&&!ti(n))return n;if(Po(e))try{let t=e.getName();return t=t.startsWith("Runnable")?t.slice(8):t,t}catch{return e.getName()}else return e.name??"UnknownSchema"}function Cb(n){return Po(n.data)?{type:"runnable",data:{id:n.data.lc_id,name:n.data.getName()}}:{type:"schema",data:{...Rb(n.data.schema),title:n.data.name}}}class ki{constructor(e){Object.defineProperty(this,"nodes",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"edges",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this.nodes=e?.nodes??this.nodes,this.edges=e?.edges??this.edges}toJSON(){const e={};return Object.values(this.nodes).forEach((t,r)=>{e[t.id]=ti(t.id)?r:t.id}),{nodes:Object.values(this.nodes).map(t=>({id:e[t.id],...Cb(t)})),edges:this.edges.map(t=>{const r={source:e[t.source],target:e[t.target]};return typeof t.data<"u"&&(r.data=t.data),typeof t.conditional<"u"&&(r.conditional=t.conditional),r})}}addNode(e,t,r){if(t!==void 0&&this.nodes[t]!==void 0)throw new Error(`Node with id ${t} already exists`);const i=t??Le(),a={id:i,data:e,name:Ib(t,e),metadata:r};return this.nodes[i]=a,a}removeNode(e){delete this.nodes[e.id],this.edges=this.edges.filter(t=>t.source!==e.id&&t.target!==e.id)}addEdge(e,t,r,i){if(this.nodes[e.id]===void 0)throw new Error(`Source node ${e.id} not in graph`);if(this.nodes[t.id]===void 0)throw new Error(`Target node ${t.id} not in graph`);const a={source:e.id,target:t.id,data:r,conditional:i};return this.edges.push(a),a}firstNode(){return Rc(this)}lastNode(){return Ic(this)}extend(e,t=""){let r=t;Object.values(e.nodes).map(l=>l.id).every(ti)&&(r="");const a=l=>r?`${r}:${l}`:l;Object.entries(e.nodes).forEach(([l,c])=>{this.nodes[a(l)]={...c,id:a(l)}});const s=e.edges.map(l=>({...l,source:a(l.source),target:a(l.target)}));this.edges=[...this.edges,...s];const o=e.firstNode(),u=e.lastNode();return[o?{id:a(o.id),data:o.data}:void 0,u?{id:a(u.id),data:u.data}:void 0]}trimFirstNode(){const e=this.firstNode();e&&Rc(this,[e.id])&&this.removeNode(e)}trimLastNode(){const e=this.lastNode();e&&Ic(this,[e.id])&&this.removeNode(e)}reid(){const e=Object.fromEntries(Object.values(this.nodes).map(i=>[i.id,i.name])),t=new Map;Object.values(e).forEach(i=>{t.set(i,(t.get(i)||0)+1)});const r=i=>{const a=e[i];return ti(i)&&t.get(a)===1?a:i};return new ki({nodes:Object.fromEntries(Object.entries(this.nodes).map(([i,a])=>[r(i),{...a,id:r(i)}])),edges:this.edges.map(i=>({...i,source:r(i.source),target:r(i.target)}))})}drawMermaid(e){const{withStyles:t,curveStyle:r,nodeColors:i={default:"fill:#f2f0ff,line-height:1.2",first:"fill-opacity:0",last:"fill:#bfb6fc"},wrapLabelNWords:a}=e??{},s=this.reid(),o=s.firstNode(),u=s.lastNode();return Eb(s.nodes,s.edges,{firstNode:o?.id,lastNode:u?.id,withStyles:t,curveStyle:r,nodeColors:i,wrapLabelNWords:a})}async drawMermaidPng(e){const t=this.drawMermaid(e);return Sb(t,{backgroundColor:e?.backgroundColor})}}function Rc(n,e=[]){const t=new Set(n.edges.filter(i=>!e.includes(i.source)).map(i=>i.target)),r=[];for(const i of Object.values(n.nodes))!e.includes(i.id)&&!t.has(i.id)&&r.push(i);return r.length===1?r[0]:void 0}function Ic(n,e=[]){const t=new Set(n.edges.filter(i=>!e.includes(i.target)).map(i=>i.source)),r=[];for(const i of Object.values(n.nodes))!e.includes(i.id)&&!t.has(i.id)&&r.push(i);return r.length===1?r[0]:void 0}function $b(n){const e=new TextEncoder,t=new ReadableStream({async start(r){for await(const i of n)r.enqueue(e.encode(`event: data
|
|
115
|
+
data: ${JSON.stringify(i)}
|
|
116
|
+
|
|
117
|
+
`));r.enqueue(e.encode(`event: end
|
|
118
|
+
|
|
119
|
+
`)),r.close()}});return Ve.fromReadableStream(t)}function Cc(n){return typeof n=="object"&&n!==null&&typeof n[Symbol.iterator]=="function"&&typeof n.next=="function"}const jb=n=>n!=null&&typeof n=="object"&&"next"in n&&typeof n.next=="function";function Us(n){return typeof n=="object"&&n!==null&&typeof n[Symbol.asyncIterator]=="function"}function*$c(n,e){for(;;){const{value:t,done:r}=$t.runWithConfig(Sr(n),e.next.bind(e),!0);if(r)break;yield t}}async function*Bs(n,e){const t=e[Symbol.asyncIterator]();for(;;){const{value:r,done:i}=await $t.runWithConfig(Sr(n),t.next.bind(e),!0);if(i)break;yield r}}function je(n,e){return n&&!Array.isArray(n)&&!(n instanceof Date)&&typeof n=="object"?n:{[e]:n}}class Ae extends bt{constructor(){super(...arguments),Object.defineProperty(this,"lc_runnable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}getName(e){const t=this.name??this.constructor.lc_name()??this.constructor.name;return e?`${t}${e}`:t}bind(e){return new Dt({bound:this,kwargs:e,config:{}})}map(){return new vi({bound:this})}withRetry(e){return new Od({bound:this,kwargs:{},config:{},maxAttemptNumber:e?.stopAfterAttempt,...e})}withConfig(e){return new Dt({bound:this,config:e,kwargs:{}})}withFallbacks(e){const t=Array.isArray(e)?e:e.fallbacks;return new kb({runnable:this,fallbacks:t})}_getOptionsList(e,t=0){if(Array.isArray(e)&&e.length!==t)throw new Error(`Passed "options" must be an array with the same length as the inputs, but got ${e.length} options for ${t} inputs`);if(Array.isArray(e))return e.map(be);if(t>1&&!Array.isArray(e)&&e.runId){console.warn("Provided runId will be used only for the first element of the batch.");const r=Object.fromEntries(Object.entries(e).filter(([i])=>i!=="runId"));return Array.from({length:t},(i,a)=>be(a===0?e:r))}return Array.from({length:t},()=>be(e))}async batch(e,t,r){const i=this._getOptionsList(t??{},e.length),a=i[0]?.maxConcurrency??r?.maxConcurrency,s=new Oo({maxConcurrency:a,onFailedAttempt:u=>{throw u}}),o=e.map((u,l)=>s.call(async()=>{try{return await this.invoke(u,i[l])}catch(c){if(r?.returnExceptions)return c;throw c}}));return Promise.all(o)}async*_streamIterator(e,t){yield this.invoke(e,t)}async stream(e,t){const r=be(t),i=new Rr({generator:this._streamIterator(e,r),config:r});return await i.setup,Ve.fromAsyncGenerator(i)}_separateRunnableConfigFromCallOptions(e){let t;e===void 0?t=be(e):t=be({callbacks:e.callbacks,tags:e.tags,metadata:e.metadata,runName:e.runName,configurable:e.configurable,recursionLimit:e.recursionLimit,maxConcurrency:e.maxConcurrency,runId:e.runId,timeout:e.timeout,signal:e.signal});const r={...e};return delete r.callbacks,delete r.tags,delete r.metadata,delete r.runName,delete r.configurable,delete r.recursionLimit,delete r.maxConcurrency,delete r.runId,delete r.timeout,delete r.signal,[t,r]}async _callWithConfig(e,t,r){const i=be(r),s=await(await rt(i))?.handleChainStart(this.toJSON(),je(t,"input"),i.runId,i?.runType,void 0,void 0,i?.runName??this.getName());delete i.runId;let o;try{const u=e.call(this,t,i,s);o=await jt(u,r?.signal)}catch(u){throw await s?.handleChainError(u),u}return await s?.handleChainEnd(je(o,"output")),o}async _batchWithConfig(e,t,r,i){const a=this._getOptionsList(r??{},t.length),s=await Promise.all(a.map(rt)),o=await Promise.all(s.map(async(l,c)=>{const h=await l?.handleChainStart(this.toJSON(),je(t[c],"input"),a[c].runId,a[c].runType,void 0,void 0,a[c].runName??this.getName());return delete a[c].runId,h}));let u;try{const l=e.call(this,t,a,o,i);u=await jt(l,a?.[0]?.signal)}catch(l){throw await Promise.all(o.map(c=>c?.handleChainError(l))),l}return await Promise.all(o.map(l=>l?.handleChainEnd(je(u,"output")))),u}_concatOutputChunks(e,t){return To(e,t)}async*_transformStreamWithConfig(e,t,r){let i,a=!0,s,o=!0;const u=be(r),l=await rt(u),c=this;async function*h(){for await(const _ of e){if(a)if(i===void 0)i=_;else try{i=c._concatOutputChunks(i,_)}catch{i=void 0,a=!1}yield _}}let f;try{const _=await hb(t.bind(this),h(),async()=>l?.handleChainStart(this.toJSON(),{input:""},u.runId,u.runType,void 0,void 0,u.runName??this.getName()),r?.signal,u);delete u.runId,f=_.setup;const p=f?.handlers.find(yb);let b=_.output;p!==void 0&&f!==void 0&&(b=p.tapOutputIterable(f.runId,b));const w=f?.handlers.find(pb);w!==void 0&&f!==void 0&&(b=w.tapOutputIterable(f.runId,b));for await(const m of b)if(yield m,o)if(s===void 0)s=m;else try{s=this._concatOutputChunks(s,m)}catch{s=void 0,o=!1}}catch(_){throw await f?.handleChainError(_,void 0,void 0,void 0,{inputs:je(i,"input")}),_}await f?.handleChainEnd(s??{},void 0,void 0,void 0,{inputs:je(i,"input")})}getGraph(e){const t=new ki,r=t.addNode({name:`${this.getName()}Input`,schema:pt()}),i=t.addNode(this),a=t.addNode({name:`${this.getName()}Output`,schema:pt()});return t.addEdge(r,i),t.addEdge(i,a),t}pipe(e){return new mt({first:this,last:Ft(e)})}pick(e){return this.pipe(new Nb(e))}assign(e){return this.pipe(new Td(new Ir({steps:e})))}async*transform(e,t){let r;for await(const i of e)r===void 0?r=i:r=this._concatOutputChunks(r,i);yield*this._streamIterator(r,be(t))}async*streamLog(e,t,r){const i=new Ac({...r,autoClose:!1,_schemaFormat:"original"}),a=be(t);yield*this._streamLog(e,i,a)}async*_streamLog(e,t,r){const{callbacks:i}=r;if(i===void 0)r.callbacks=[t];else if(Array.isArray(i))r.callbacks=i.concat([t]);else{const u=i.copy();u.addHandler(t,!0),r.callbacks=u}const a=this.stream(e,r);async function s(){try{const u=await a;for await(const l of u){const c=new xt({ops:[{op:"add",path:"/streamed_output/-",value:l}]});await t.writer.write(c)}}finally{await t.writer.close()}}const o=s();try{for await(const u of t)yield u}finally{await o}}streamEvents(e,t,r){let i;if(t.version==="v1")i=this._streamEventsV1(e,t,r);else if(t.version==="v2")i=this._streamEventsV2(e,t,r);else throw new Error('Only versions "v1" and "v2" of the schema are currently supported.');return t.encoding==="text/event-stream"?$b(i):Ve.fromAsyncGenerator(i)}async*_streamEventsV2(e,t,r){const i=new bb({...r,autoClose:!1}),a=be(t),s=a.runId??Le();a.runId=s;const o=a.callbacks;if(o===void 0)a.callbacks=[i];else if(Array.isArray(o))a.callbacks=o.concat(i);else{const p=o.copy();p.addHandler(i,!0),a.callbacks=p}const u=new AbortController,l=this;async function c(){let p,b=null;try{t?.signal?"any"in AbortSignal?p=AbortSignal.any([u.signal,t.signal]):(p=t.signal,b=()=>{u.abort()},t.signal.addEventListener("abort",b,{once:!0})):p=u.signal;const w=await l.stream(e,{...a,signal:p}),m=i.tapOutputIterable(s,w);for await(const g of m)if(u.signal.aborted)break}finally{await i.finish(),p&&b&&p.removeEventListener("abort",b)}}const h=c();let f=!1,_;try{for await(const p of i){if(!f){p.data.input=e,f=!0,_=p.run_id,yield p;continue}p.run_id===_&&p.event.endsWith("_end")&&p.data?.input&&delete p.data.input,yield p}}finally{u.abort(),await h}}async*_streamEventsV1(e,t,r){let i,a=!1;const s=be(t),o=s.tags??[],u=s.metadata??{},l=s.runName??this.getName(),c=new Ac({...r,autoClose:!1,_schemaFormat:"streaming_events"}),h=new _b({...r}),f=this._streamLog(e,c,s);for await(const p of f){if(i?i=i.concat(p):i=an.fromRunLogPatch(p),i.state===void 0)throw new Error('Internal error: "streamEvents" state is missing. Please open a bug report.');if(!a){a=!0;const g={...i.state},v={run_id:g.id,event:`on_${g.type}_start`,name:l,tags:o,metadata:u,data:{input:e}};h.includeEvent(v,g.type)&&(yield v)}const b=p.ops.filter(g=>g.path.startsWith("/logs/")).map(g=>g.path.split("/")[2]),w=[...new Set(b)];for(const g of w){let v,E={};const O=i.state.logs[g];if(O.end_time===void 0?O.streamed_output.length>0?v="stream":v="start":v="end",v==="start")O.inputs!==void 0&&(E.input=O.inputs);else if(v==="end")O.inputs!==void 0&&(E.input=O.inputs),E.output=O.final_output;else if(v==="stream"){const C=O.streamed_output.length;if(C!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${C} instead. Encountered in: "${O.name}"`);E={chunk:O.streamed_output[0]},O.streamed_output=[]}yield{event:`on_${O.type}_${v}`,name:O.name,run_id:O.id,tags:O.tags,metadata:O.metadata,data:E}}const{state:m}=i;if(m.streamed_output.length>0){const g=m.streamed_output.length;if(g!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${g} instead. Encountered in: "${m.name}"`);const v={chunk:m.streamed_output[0]};m.streamed_output=[];const E={event:`on_${m.type}_stream`,run_id:m.id,tags:o,metadata:u,name:l,data:v};h.includeEvent(E,m.type)&&(yield E)}}const _=i?.state;if(_!==void 0){const p={event:`on_${_.type}_end`,name:l,run_id:_.id,tags:o,metadata:u,data:{output:_.final_output}};h.includeEvent(p,_.type)&&(yield p)}}static isRunnable(e){return Po(e)}withListeners({onStart:e,onEnd:t,onError:r}){return new Dt({bound:this,config:{},configFactories:[i=>({callbacks:[new vd({config:i,onStart:e,onEnd:t,onError:r})]})]})}asTool(e){return Lb(this,e)}}class Dt extends Ae{static lc_name(){return"RunnableBinding"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"bound",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"kwargs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"configFactories",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.bound=e.bound,this.kwargs=e.kwargs,this.config=e.config,this.configFactories=e.configFactories}getName(e){return this.bound.getName(e)}async _mergeConfig(...e){const t=Fs(this.config,...e);return Fs(t,...this.configFactories?await Promise.all(this.configFactories.map(async r=>await r(t))):[])}bind(e){return new this.constructor({bound:this.bound,kwargs:{...this.kwargs,...e},config:this.config})}withConfig(e){return new this.constructor({bound:this.bound,kwargs:this.kwargs,config:{...this.config,...e}})}withRetry(e){return new Od({bound:this.bound,kwargs:this.kwargs,config:this.config,maxAttemptNumber:e?.stopAfterAttempt,...e})}async invoke(e,t){return this.bound.invoke(e,await this._mergeConfig(be(t),this.kwargs))}async batch(e,t,r){const i=Array.isArray(t)?await Promise.all(t.map(async a=>this._mergeConfig(be(a),this.kwargs))):await this._mergeConfig(be(t),this.kwargs);return this.bound.batch(e,i,r)}_concatOutputChunks(e,t){return this.bound._concatOutputChunks(e,t)}async*_streamIterator(e,t){yield*this.bound._streamIterator(e,await this._mergeConfig(be(t),this.kwargs))}async stream(e,t){return this.bound.stream(e,await this._mergeConfig(be(t),this.kwargs))}async*transform(e,t){yield*this.bound.transform(e,await this._mergeConfig(be(t),this.kwargs))}streamEvents(e,t,r){const i=this,a=async function*(){yield*i.bound.streamEvents(e,{...await i._mergeConfig(be(t),i.kwargs),version:t.version},r)};return Ve.fromAsyncGenerator(a())}static isRunnableBinding(e){return e.bound&&Ae.isRunnable(e.bound)}withListeners({onStart:e,onEnd:t,onError:r}){return new Dt({bound:this.bound,kwargs:this.kwargs,config:this.config,configFactories:[i=>({callbacks:[new vd({config:i,onStart:e,onEnd:t,onError:r})]})]})}}class vi extends Ae{static lc_name(){return"RunnableEach"}constructor(e){super(e),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"bound",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.bound=e.bound}bind(e){return new vi({bound:this.bound.bind(e)})}async invoke(e,t){return this._callWithConfig(this._invoke.bind(this),e,t)}async _invoke(e,t,r){return this.bound.batch(e,Ce(t,{callbacks:r?.getChild()}))}withListeners({onStart:e,onEnd:t,onError:r}){return new vi({bound:this.bound.withListeners({onStart:e,onEnd:t,onError:r})})}}class Od extends Dt{static lc_name(){return"RunnableRetry"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"maxAttemptNumber",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"onFailedAttempt",{enumerable:!0,configurable:!0,writable:!0,value:()=>{}}),this.maxAttemptNumber=e.maxAttemptNumber??this.maxAttemptNumber,this.onFailedAttempt=e.onFailedAttempt??this.onFailedAttempt}_patchConfigForRetry(e,t,r){const i=e>1?`retry:attempt:${e}`:void 0;return Ce(t,{callbacks:r?.getChild(i)})}async _invoke(e,t,r){return ai(i=>super.invoke(e,this._patchConfigForRetry(i,t,r)),{onFailedAttempt:i=>this.onFailedAttempt(i,e),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}async invoke(e,t){return this._callWithConfig(this._invoke.bind(this),e,t)}async _batch(e,t,r,i){const a={};try{await ai(async s=>{const o=e.map((f,_)=>_).filter(f=>a[f.toString()]===void 0||a[f.toString()]instanceof Error),u=o.map(f=>e[f]),l=o.map(f=>this._patchConfigForRetry(s,t?.[f],r?.[f])),c=await super.batch(u,l,{...i,returnExceptions:!0});let h;for(let f=0;f<c.length;f+=1){const _=c[f],p=o[f];_ instanceof Error&&h===void 0&&(h=_,h.input=u[f]),a[p.toString()]=_}if(h)throw h;return c},{onFailedAttempt:s=>this.onFailedAttempt(s,s.input),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}catch(s){if(i?.returnExceptions!==!0)throw s}return Object.keys(a).sort((s,o)=>parseInt(s,10)-parseInt(o,10)).map(s=>a[parseInt(s,10)])}async batch(e,t,r){return this._batchWithConfig(this._batch.bind(this),e,t,r)}}class mt extends Ae{static lc_name(){return"RunnableSequence"}constructor(e){super(e),Object.defineProperty(this,"first",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"middle",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"last",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"omitSequenceTags",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),this.first=e.first,this.middle=e.middle??this.middle,this.last=e.last,this.name=e.name,this.omitSequenceTags=e.omitSequenceTags??this.omitSequenceTags}get steps(){return[this.first,...this.middle,this.last]}async invoke(e,t){const r=be(t),a=await(await rt(r))?.handleChainStart(this.toJSON(),je(e,"input"),r.runId,void 0,void 0,void 0,r?.runName);delete r.runId;let s=e,o;try{const u=[this.first,...this.middle];for(let l=0;l<u.length;l+=1){const h=u[l].invoke(s,Ce(r,{callbacks:a?.getChild(this.omitSequenceTags?void 0:`seq:step:${l+1}`)}));s=await jt(h,t?.signal)}if(t?.signal?.aborted)throw new Error("Aborted");o=await this.last.invoke(s,Ce(r,{callbacks:a?.getChild(this.omitSequenceTags?void 0:`seq:step:${this.steps.length}`)}))}catch(u){throw await a?.handleChainError(u),u}return await a?.handleChainEnd(je(o,"output")),o}async batch(e,t,r){const i=this._getOptionsList(t??{},e.length),a=await Promise.all(i.map(rt)),s=await Promise.all(a.map(async(u,l)=>{const c=await u?.handleChainStart(this.toJSON(),je(e[l],"input"),i[l].runId,void 0,void 0,void 0,i[l].runName);return delete i[l].runId,c}));let o=e;try{for(let u=0;u<this.steps.length;u+=1){const c=this.steps[u].batch(o,s.map((h,f)=>{const _=h?.getChild(this.omitSequenceTags?void 0:`seq:step:${u+1}`);return Ce(i[f],{callbacks:_})}),r);o=await jt(c,i[0]?.signal)}}catch(u){throw await Promise.all(s.map(l=>l?.handleChainError(u))),u}return await Promise.all(s.map(u=>u?.handleChainEnd(je(o,"output")))),o}_concatOutputChunks(e,t){return this.last._concatOutputChunks(e,t)}async*_streamIterator(e,t){const r=await rt(t),{runId:i,...a}=t??{},s=await r?.handleChainStart(this.toJSON(),je(e,"input"),i,void 0,void 0,void 0,a?.runName),o=[this.first,...this.middle,this.last];let u=!0,l;async function*c(){yield e}try{let h=o[0].transform(c(),Ce(a,{callbacks:s?.getChild(this.omitSequenceTags?void 0:"seq:step:1")}));for(let f=1;f<o.length;f+=1)h=await o[f].transform(h,Ce(a,{callbacks:s?.getChild(this.omitSequenceTags?void 0:`seq:step:${f+1}`)}));for await(const f of h)if(t?.signal?.throwIfAborted(),yield f,u)if(l===void 0)l=f;else try{l=this._concatOutputChunks(l,f)}catch{l=void 0,u=!1}}catch(h){throw await s?.handleChainError(h),h}await s?.handleChainEnd(je(l,"output"))}getGraph(e){const t=new ki;let r=null;return this.steps.forEach((i,a)=>{const s=i.getGraph(e);a!==0&&s.trimFirstNode(),a!==this.steps.length-1&&s.trimLastNode(),t.extend(s);const o=s.firstNode();if(!o)throw new Error(`Runnable ${i} has no first node`);r&&t.addEdge(r,o),r=s.lastNode()}),t}pipe(e){return mt.isRunnableSequence(e)?new mt({first:this.first,middle:this.middle.concat([this.last,e.first,...e.middle]),last:e.last,name:this.name??e.name}):new mt({first:this.first,middle:[...this.middle,this.last],last:Ft(e),name:this.name})}static isRunnableSequence(e){return Array.isArray(e.middle)&&Ae.isRunnable(e)}static from([e,...t],r){let i={};return typeof r=="string"?i.name=r:r!==void 0&&(i=r),new mt({...i,first:Ft(e),middle:t.slice(0,-1).map(Ft),last:Ft(t[t.length-1])})}}class Ir extends Ae{static lc_name(){return"RunnableMap"}getStepsKeys(){return Object.keys(this.steps)}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"steps",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.steps={};for(const[t,r]of Object.entries(e.steps))this.steps[t]=Ft(r)}static from(e){return new Ir({steps:e})}async invoke(e,t){const r=be(t),a=await(await rt(r))?.handleChainStart(this.toJSON(),{input:e},r.runId,void 0,void 0,void 0,r?.runName);delete r.runId;const s={};try{const o=Object.entries(this.steps).map(async([u,l])=>{s[u]=await l.invoke(e,Ce(r,{callbacks:a?.getChild(`map:key:${u}`)}))});await jt(Promise.all(o),t?.signal)}catch(o){throw await a?.handleChainError(o),o}return await a?.handleChainEnd(s),s}async*_transform(e,t,r){const i={...this.steps},a=_d(e,Object.keys(i).length),s=new Map(Object.entries(i).map(([o,u],l)=>{const c=u.transform(a[l],Ce(r,{callbacks:t?.getChild(`map:key:${o}`)}));return[o,c.next().then(h=>({key:o,gen:c,result:h}))]}));for(;s.size;){const o=Promise.race(s.values()),{key:u,result:l,gen:c}=await jt(o,r?.signal);s.delete(u),l.done||(yield{[u]:l.value},s.set(u,c.next().then(h=>({key:u,gen:c,result:h}))))}}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){async function*r(){yield e}const i=be(t),a=new Rr({generator:this.transform(r(),i),config:i});return await a.setup,Ve.fromAsyncGenerator(a)}}class xo extends Ae{constructor(e){if(super(e),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!vo(e.func))throw new Error("RunnableTraceable requires a function that is wrapped in traceable higher-order function");this.func=e.func}async invoke(e,t){const[r]=this._getOptionsList(t??{},1),i=await rt(r),a=this.func(Ce(r,{callbacks:i}),e);return jt(a,r?.signal)}async*_streamIterator(e,t){const[r]=this._getOptionsList(t??{},1),i=await this.invoke(e,t);if(Us(i)){for await(const a of i)r?.signal?.throwIfAborted(),yield a;return}if(jb(i)){for(;;){r?.signal?.throwIfAborted();const a=i.next();if(a.done)break;yield a.value}return}yield i}static from(e){return new xo({func:e})}}function Mb(n){if(vo(n))throw new Error("RunnableLambda requires a function that is not wrapped in traceable higher-order function. This shouldn't happen.")}class Ni extends Ae{static lc_name(){return"RunnableLambda"}constructor(e){if(vo(e.func))return xo.from(e.func);super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Mb(e.func),this.func=e.func}static from(e){return new Ni({func:e})}async _invoke(e,t,r){return new Promise((i,a)=>{const s=Ce(t,{callbacks:r?.getChild(),recursionLimit:(t?.recursionLimit??ws)-1});$t.runWithConfig(Sr(s),async()=>{try{let o=await this.func(e,{...s});if(o&&Ae.isRunnable(o)){if(t?.recursionLimit===0)throw new Error("Recursion limit reached.");o=await o.invoke(e,{...s,recursionLimit:(s.recursionLimit??ws)-1})}else if(Us(o)){let u;for await(const l of Bs(s,o))if(t?.signal?.throwIfAborted(),u===void 0)u=l;else try{u=this._concatOutputChunks(u,l)}catch{u=l}o=u}else if(Cc(o)){let u;for(const l of $c(s,o))if(t?.signal?.throwIfAborted(),u===void 0)u=l;else try{u=this._concatOutputChunks(u,l)}catch{u=l}o=u}i(o)}catch(o){a(o)}})})}async invoke(e,t){return this._callWithConfig(this._invoke.bind(this),e,t)}async*_transform(e,t,r){let i;for await(const o of e)if(i===void 0)i=o;else try{i=this._concatOutputChunks(i,o)}catch{i=o}const a=Ce(r,{callbacks:t?.getChild(),recursionLimit:(r?.recursionLimit??ws)-1}),s=await new Promise((o,u)=>{$t.runWithConfig(Sr(a),async()=>{try{const l=await this.func(i,{...a,config:a});o(l)}catch(l){u(l)}})});if(s&&Ae.isRunnable(s)){if(r?.recursionLimit===0)throw new Error("Recursion limit reached.");const o=await s.stream(i,a);for await(const u of o)yield u}else if(Us(s))for await(const o of Bs(a,s))r?.signal?.throwIfAborted(),yield o;else if(Cc(s))for(const o of $c(a,s))r?.signal?.throwIfAborted(),yield o;else yield s}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){async function*r(){yield e}const i=be(t),a=new Rr({generator:this.transform(r(),i),config:i});return await a.setup,Ve.fromAsyncGenerator(a)}}class kb extends Ae{static lc_name(){return"RunnableWithFallbacks"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"runnable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"fallbacks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.runnable=e.runnable,this.fallbacks=e.fallbacks}*runnables(){yield this.runnable;for(const e of this.fallbacks)yield e}async invoke(e,t){const r=be(t),i=await rt(r),{runId:a,...s}=r,o=await i?.handleChainStart(this.toJSON(),je(e,"input"),a,void 0,void 0,void 0,s?.runName),u=Ce(s,{callbacks:o?.getChild()});return await $t.runWithConfig(u,async()=>{let c;for(const h of this.runnables()){r?.signal?.throwIfAborted();try{const f=await h.invoke(e,u);return await o?.handleChainEnd(je(f,"output")),f}catch(f){c===void 0&&(c=f)}}throw c===void 0?new Error("No error stored at end of fallback."):(await o?.handleChainError(c),c)})}async*_streamIterator(e,t){const r=be(t),i=await rt(r),{runId:a,...s}=r,o=await i?.handleChainStart(this.toJSON(),je(e,"input"),a,void 0,void 0,void 0,s?.runName);let u,l;for(const h of this.runnables()){r?.signal?.throwIfAborted();const f=Ce(s,{callbacks:o?.getChild()});try{const _=await h.stream(e,f);l=Bs(f,_);break}catch(_){u===void 0&&(u=_)}}if(l===void 0){const h=u??new Error("No error stored at end of fallback.");throw await o?.handleChainError(h),h}let c;try{for await(const h of l){yield h;try{c=c===void 0?c:this._concatOutputChunks(c,h)}catch{c=void 0}}}catch(h){throw await o?.handleChainError(h),h}await o?.handleChainEnd(je(c,"output"))}async batch(e,t,r){if(r?.returnExceptions)throw new Error("Not implemented.");const i=this._getOptionsList(t??{},e.length),a=await Promise.all(i.map(u=>rt(u))),s=await Promise.all(a.map(async(u,l)=>{const c=await u?.handleChainStart(this.toJSON(),je(e[l],"input"),i[l].runId,void 0,void 0,void 0,i[l].runName);return delete i[l].runId,c}));let o;for(const u of this.runnables()){i[0].signal?.throwIfAborted();try{const l=await u.batch(e,s.map((c,h)=>Ce(i[h],{callbacks:c?.getChild()})),r);return await Promise.all(s.map((c,h)=>c?.handleChainEnd(je(l[h],"output")))),l}catch(l){o===void 0&&(o=l)}}throw o?(await Promise.all(s.map(u=>u?.handleChainError(o))),o):new Error("No error stored at end of fallbacks.")}}function Ft(n){if(typeof n=="function")return new Ni({func:n});if(Ae.isRunnable(n))return n;if(!Array.isArray(n)&&typeof n=="object"){const e={};for(const[t,r]of Object.entries(n))e[t]=Ft(r);return new Ir({steps:e})}else throw new Error(`Expected a Runnable, function or object.
|
|
120
|
+
Instead got an unsupported type.`)}class Td extends Ae{static lc_name(){return"RunnableAssign"}constructor(e){e instanceof Ir&&(e={mapper:e}),super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"mapper",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.mapper=e.mapper}async invoke(e,t){const r=await this.mapper.invoke(e,t);return{...e,...r}}async*_transform(e,t,r){const i=this.mapper.getStepsKeys(),[a,s]=_d(e),o=this.mapper.transform(s,Ce(r,{callbacks:t?.getChild()})),u=o.next();for await(const l of a){if(typeof l!="object"||Array.isArray(l))throw new Error(`RunnableAssign can only be used with objects as input, got ${typeof l}`);const c=Object.fromEntries(Object.entries(l).filter(([h])=>!i.includes(h)));Object.keys(c).length>0&&(yield c)}yield(await u).value;for await(const l of o)yield l}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){async function*r(){yield e}const i=be(t),a=new Rr({generator:this.transform(r(),i),config:i});return await a.setup,Ve.fromAsyncGenerator(a)}}class Nb extends Ae{static lc_name(){return"RunnablePick"}constructor(e){(typeof e=="string"||Array.isArray(e))&&(e={keys:e}),super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"keys",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.keys=e.keys}async _pick(e){if(typeof this.keys=="string")return e[this.keys];{const t=this.keys.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0);return t.length===0?void 0:Object.fromEntries(t)}}async invoke(e,t){return this._callWithConfig(this._pick.bind(this),e,t)}async*_transform(e){for await(const t of e){const r=await this._pick(t);r!==void 0&&(yield r)}}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){async function*r(){yield e}const i=be(t),a=new Rr({generator:this.transform(r(),i),config:i});return await a.setup,Ve.fromAsyncGenerator(a)}}class jc extends Dt{constructor(e){const t=mt.from([Ni.from(async r=>{let i;if(Hr(r))try{i=await Ed(this.schema,r.args)}catch{throw new rn("Received tool input did not match expected schema",JSON.stringify(r.args))}else i=r;return i}).withConfig({runName:`${e.name}:parse_input`}),e.bound]).withConfig({runName:e.name});super({bound:t,config:e.config??{}}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e.name,this.description=e.description,this.schema=e.schema}static lc_name(){return"RunnableToolLike"}}function Lb(n,e){const t=e.name??n.getName(),r=e.description??Tb(e.schema);return Pb(e.schema)?new jc({name:t,description:r,schema:lt({input:cn()}).transform(i=>i.input),bound:n}):new jc({name:t,description:r,schema:e.schema,bound:n})}const Fb=n=>n.startsWith("gpt-3.5-turbo-16k")?"gpt-3.5-turbo-16k":n.startsWith("gpt-3.5-turbo-")?"gpt-3.5-turbo":n.startsWith("gpt-4-32k")?"gpt-4-32k":n.startsWith("gpt-4-")?"gpt-4":n.startsWith("gpt-4o")?"gpt-4o":n,Db=()=>!1;class Ao extends Ae{get lc_attributes(){return{callbacks:void 0,verbose:void 0}}constructor(e){super(e),Object.defineProperty(this,"verbose",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"callbacks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.verbose=e.verbose??Db(),this.callbacks=e.callbacks,this.tags=e.tags??[],this.metadata=e.metadata??{}}}class oE extends Ao{get callKeys(){return["stop","timeout","signal","tags","metadata","callbacks"]}constructor({callbacks:e,callbackManager:t,...r}){const{cache:i,...a}=r;super({callbacks:e??t,...a}),Object.defineProperty(this,"caller",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_encoding",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),typeof i=="object"?this.cache=i:i?this.cache=Eo.global():this.cache=void 0,this.caller=new Oo(r??{})}async getNumTokens(e){let t;typeof e=="string"?t=e:t=e.map(i=>typeof i=="string"?i:i.type==="text"&&"text"in i?i.text:"").join("");let r=Math.ceil(t.length/4);if(!this._encoding)try{this._encoding=await tb("modelName"in this?Fb(this.modelName):"gpt2")}catch(i){console.warn("Failed to calculate number of tokens, falling back to approximate count",i)}if(this._encoding)try{r=this._encoding.encode(t).length}catch(i){console.warn("Failed to calculate number of tokens, falling back to approximate count",i)}return r}static _convertInputToPromptValue(e){return typeof e=="string"?new yd(e):Array.isArray(e)?new bd(e.map(mi)):e}_identifyingParams(){return{}}_getSerializedCacheKeyParametersForCall({config:e,...t}){const r={...this._identifyingParams(),...t,_type:this._llmType(),_model:this._modelType()};return Object.entries(r).filter(([s,o])=>o!==void 0).map(([s,o])=>`${s}:${JSON.stringify(o)}`).sort().join(",")}serialize(){return{...this._identifyingParams(),_type:this._llmType(),_model:this._modelType()}}static async deserialize(e){throw new Error("Use .toJSON() instead")}}class Li extends Ao{get lc_namespace(){return["langchain","tools"]}constructor(e){super(e??{}),Object.defineProperty(this,"returnDirect",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"verboseParsingErrors",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"responseFormat",{enumerable:!0,configurable:!0,writable:!0,value:"content"}),Object.defineProperty(this,"defaultConfig",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.verboseParsingErrors=e?.verboseParsingErrors??this.verboseParsingErrors,this.responseFormat=e?.responseFormat??this.responseFormat,this.defaultConfig=e?.defaultConfig??this.defaultConfig,this.metadata=e?.metadata??this.metadata}async invoke(e,t){let r,i=be(Fs(this.defaultConfig,t));return Hr(e)?(r=e.args,i={...i,toolCall:e}):r=e,this.call(r,i)}async call(e,t,r){const i=Hr(e)?e.args:e;let a;if(wd(this.schema))try{a=await Ed(this.schema,i)}catch(p){let b="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(b=`${b}
|
|
121
|
+
Details: ${p.message}`),new rn(b,JSON.stringify(e))}else{const p=Se(i,this.schema);if(!p.valid){let b="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(b=`${b}
|
|
122
|
+
Details: ${p.errors.map(w=>`${w.keywordLocation}: ${w.error}`).join(`
|
|
123
|
+
`)}`),new rn(b,JSON.stringify(e))}a=i}const s=wo(t),u=await Fe.configure(s.callbacks,this.callbacks,s.tags||r,this.tags,s.metadata,this.metadata,{verbose:this.verbose})?.handleToolStart(this.toJSON(),typeof e=="string"?e:JSON.stringify(e),s.runId,void 0,void 0,void 0,s.runName);delete s.runId;let l;try{l=await this._call(a,u,s)}catch(p){throw await u?.handleToolError(p),p}let c,h;if(this.responseFormat==="content_and_artifact")if(Array.isArray(l)&&l.length===2)[c,h]=l;else throw new Error(`Tool response format is "content_and_artifact" but the output was not a two-tuple.
|
|
124
|
+
Result: ${JSON.stringify(l)}`);else c=l;let f;Hr(e)&&(f=e.id),!f&&yy(s)&&(f=s.toolCall.id);const _=qb({content:c,artifact:h,toolCallId:f,name:this.name,metadata:this.metadata});return await u?.handleToolEnd(_),_}}class Ub extends Li{constructor(e){super(e),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:lt({input:cn().optional()}).transform(t=>t.input)})}call(e,t){const r=typeof e=="string"||e==null?{input:e}:e;return super.call(r,t)}}class Bb extends Li{static lc_name(){return"DynamicStructuredTool"}constructor(e){super(e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect,this.schema=e.schema}async call(e,t,r){const i=wo(t);return i.runName===void 0&&(i.runName=this.name),super.call(e,i,r)}_call(e,t,r){return this.func(e,t,r)}}function qb(n){const{content:e,artifact:t,toolCallId:r,metadata:i}=n;return r&&!Sy(e)?typeof e=="string"||Array.isArray(e)&&e.every(a=>typeof a=="object")?new wr({status:"success",content:e,artifact:t,tool_call_id:r,name:n.name,metadata:i}):new wr({status:"success",content:zb(e),artifact:t,tool_call_id:r,name:n.name,metadata:i}):e}function zb(n){try{return JSON.stringify(n,null,2)??""}catch{return`${n}`}}var Fr={},Mc;function Hb(){if(Mc)return Fr;Mc=1;var n=/~/,e=/~[01]/g;function t(l){switch(l){case"~1":return"/";case"~0":return"~"}throw new Error("Invalid tilde escape: "+l)}function r(l){return n.test(l)?l.replace(e,t):l}function i(l,c,h){for(var f,_,p=1,b=c.length;p<b;){if(c[p]==="constructor"||c[p]==="prototype"||c[p]==="__proto__")return l;if(f=r(c[p++]),_=b>p,typeof l[f]>"u"&&(Array.isArray(l)&&f==="-"&&(f=l.length),_&&(c[p]!==""&&c[p]<1/0||c[p]==="-"?l[f]=[]:l[f]={})),!_)break;l=l[f]}var w=l[f];return h===void 0?delete l[f]:l[f]=h,w}function a(l){if(typeof l=="string"){if(l=l.split("/"),l[0]==="")return l;throw new Error("Invalid JSON pointer.")}else if(Array.isArray(l)){for(const c of l)if(typeof c!="string"&&typeof c!="number")throw new Error("Invalid JSON pointer. Must be of type string or number.");return l}throw new Error("Invalid JSON pointer.")}function s(l,c){if(typeof l!="object")throw new Error("Invalid input object.");c=a(c);var h=c.length;if(h===1)return l;for(var f=1;f<h;){if(l=l[r(c[f++])],h===f)return l;if(typeof l!="object"||l===null)return}}function o(l,c,h){if(typeof l!="object")throw new Error("Invalid input object.");if(c=a(c),c.length===0)throw new Error("Invalid JSON pointer for set.");return i(l,c,h)}function u(l){var c=a(l);return{get:function(h){return s(h,c)},set:function(h,f){return o(h,c,f)}}}return Fr.get=s,Fr.set=o,Fr.compile=u,Fr}Hb();class Gb extends Ae{static lc_name(){return"RunnablePassthrough"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e&&(this.func=e.func)}async invoke(e,t){const r=be(t);return this.func&&await this.func(e,r),this._callWithConfig(i=>Promise.resolve(i),e,r)}async*transform(e,t){const r=be(t);let i,a=!0;for await(const s of this._transformStreamWithConfig(e,o=>o,r))if(yield s,a)if(i===void 0)i=s;else try{i=To(i,s)}catch{i=void 0,a=!1}this.func&&i!==void 0&&await this.func(i,r)}static assign(e){return new Td(new Ir({steps:e}))}}class Vb extends Ao{get lc_namespace(){return["langchain","chains",this._chainType()]}constructor(e,t,r){if(arguments.length===1&&typeof e=="object"&&!("saveContext"in e)){const{memory:i,callbackManager:a,...s}=e;super({...s,callbacks:a??s.callbacks}),this.memory=i}else super({verbose:t,callbacks:r}),this.memory=e}_selectMemoryInputs(e){const t={...e};return"signal"in t&&delete t.signal,"timeout"in t&&delete t.timeout,t}async invoke(e,t){const r=be(t),i=await this._formatValues(e),s=await(await Fe.configure(r?.callbacks,this.callbacks,r?.tags,this.tags,r?.metadata,this.metadata,{verbose:this.verbose}))?.handleChainStart(this.toJSON(),i,void 0,void 0,void 0,void 0,r?.runName);let o;try{o=await(i.signal?Promise.race([this._call(i,s,r),new Promise((u,l)=>{i.signal?.addEventListener("abort",()=>{l(new Error("AbortError"))})})]):this._call(i,s,r))}catch(u){throw await s?.handleChainError(u),u}return this.memory!=null&&await this.memory.saveContext(this._selectMemoryInputs(e),o),await s?.handleChainEnd(o),Object.defineProperty(o,gb,{value:s?{runId:s?.runId}:void 0,configurable:!0}),o}_validateOutputs(e){const t=this.outputKeys.filter(r=>!(r in e));if(t.length)throw new Error(`Missing output keys: ${t.join(", ")} from chain ${this._chainType()}`)}async prepOutputs(e,t,r=!1){return this._validateOutputs(t),this.memory&&await this.memory.saveContext(e,t),r?t:{...e,...t}}serialize(){throw new Error("Method not implemented.")}async run(e,t){const r=this.inputKeys.filter(u=>!this.memory?.memoryKeys.includes(u));if(!(r.length<=1))throw new Error(`Chain ${this._chainType()} expects multiple inputs, cannot use 'run' `);const a=r.length?{[r[0]]:e}:{},s=await this.call(a,t),o=Object.keys(s);if(o.length===1)return s[o[0]];throw new Error("return values have multiple keys, `run` only supported when one key currently")}async _formatValues(e){const t={...e};if(t.timeout&&!t.signal&&(t.signal=AbortSignal.timeout(t.timeout),delete t.timeout),this.memory!=null){const r=await this.memory.loadMemoryVariables(this._selectMemoryInputs(e));for(const[i,a]of Object.entries(r))t[i]=a}return t}async call(e,t,r){const i={tags:r,...wo(t)};return this.invoke(e,i)}async apply(e,t){return Promise.all(e.map(async(r,i)=>this.call(r,t?.[i])))}static async deserialize(e,t={}){switch(e._type){case"llm_chain":{const{LLMChain:r}=await Me(async()=>{const{LLMChain:i}=await import("./llm_chain-CYdmV1P-.js");return{LLMChain:i}},__vite__mapDeps([7,4,2,3,5,6]));return r.deserialize(e)}case"sequential_chain":{const{SequentialChain:r}=await Me(async()=>{const{SequentialChain:i}=await import("./sequential_chain-BSDR0Wvv.js");return{SequentialChain:i}},__vite__mapDeps([8,2,3,4,5,6]));return r.deserialize(e)}case"simple_sequential_chain":{const{SimpleSequentialChain:r}=await Me(async()=>{const{SimpleSequentialChain:i}=await import("./sequential_chain-BSDR0Wvv.js");return{SimpleSequentialChain:i}},__vite__mapDeps([8,2,3,4,5,6]));return r.deserialize(e)}case"stuff_documents_chain":{const{StuffDocumentsChain:r}=await Me(async()=>{const{StuffDocumentsChain:i}=await import("./combine_docs_chain-Bi09clmQ.js");return{StuffDocumentsChain:i}},__vite__mapDeps([9,4,2,3,7,5,6]));return r.deserialize(e)}case"map_reduce_documents_chain":{const{MapReduceDocumentsChain:r}=await Me(async()=>{const{MapReduceDocumentsChain:i}=await import("./combine_docs_chain-Bi09clmQ.js");return{MapReduceDocumentsChain:i}},__vite__mapDeps([9,4,2,3,7,5,6]));return r.deserialize(e)}case"refine_documents_chain":{const{RefineDocumentsChain:r}=await Me(async()=>{const{RefineDocumentsChain:i}=await import("./combine_docs_chain-Bi09clmQ.js");return{RefineDocumentsChain:i}},__vite__mapDeps([9,4,2,3,7,5,6]));return r.deserialize(e)}case"vector_db_qa":{const{VectorDBQAChain:r}=await Me(async()=>{const{VectorDBQAChain:i}=await import("./vector_db_qa-Dl73pdLE.js");return{VectorDBQAChain:i}},__vite__mapDeps([10,7,4,2,3,5,6,9]));return r.deserialize(e,t)}case"api_chain":{const{APIChain:r}=await Me(async()=>{const{APIChain:i}=await import("./api_chain-3SKETdru.js");return{APIChain:i}},__vite__mapDeps([11,7,4,2,3,5,6]));return r.deserialize(e)}default:throw new Error(`Invalid prompt type in config: ${e._type}`)}}}class Ro extends Ae{get lc_attributes(){return{partialVariables:void 0}}constructor(e){super(e),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","prompts",this._getPromptType()]}),Object.defineProperty(this,"inputVariables",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputParser",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"partialVariables",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:void 0});const{inputVariables:t}=e;if(t.includes("stop"))throw new Error("Cannot have an input variable named 'stop', as it is used internally, please rename.");Object.assign(this,e)}async mergePartialAndUserVariables(e){const t=this.partialVariables??{},r={};for(const[a,s]of Object.entries(t))typeof s=="string"?r[a]=s:r[a]=await s();return{...r,...e}}async invoke(e,t){const r={...this.metadata,...t?.metadata},i=[...this.tags??[],...t?.tags??[]];return this._callWithConfig(a=>this.formatPromptValue(a),e,{...t,tags:i,metadata:r,runType:"prompt"})}serialize(){throw new Error("Use .toJSON() instead")}static async deserialize(e){switch(e._type){case"prompt":{const{PromptTemplate:t}=await Me(async()=>{const{PromptTemplate:r}=await Promise.resolve().then(()=>Lc);return{PromptTemplate:r}},void 0);return t.deserialize(e)}case void 0:{const{PromptTemplate:t}=await Me(async()=>{const{PromptTemplate:r}=await Promise.resolve().then(()=>Lc);return{PromptTemplate:r}},void 0);return t.deserialize({...e,_type:"prompt"})}case"few_shot":{const{FewShotPromptTemplate:t}=await Me(async()=>{const{FewShotPromptTemplate:r}=await import("./few_shot-ZsJ5YbeJ.js");return{FewShotPromptTemplate:r}},__vite__mapDeps([12,4,2,3,5,6]));return t.deserialize(e)}default:throw new Error(`Invalid prompt type in config: ${e._type}`)}}}class qs extends Ro{async formatPromptValue(e){const t=await this.format(e);return new yd(t)}}/*!
|
|
125
|
+
* mustache.js - Logic-less {{mustache}} templates with JavaScript
|
|
126
|
+
* http://github.com/janl/mustache.js
|
|
127
|
+
*/var Wb=Object.prototype.toString,Cr=Array.isArray||function(e){return Wb.call(e)==="[object Array]"};function Io(n){return typeof n=="function"}function Jb(n){return Cr(n)?"array":typeof n}function Ss(n){return n.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function kc(n,e){return n!=null&&typeof n=="object"&&e in n}function Kb(n,e){return n!=null&&typeof n!="object"&&n.hasOwnProperty&&n.hasOwnProperty(e)}var Yb=RegExp.prototype.test;function Qb(n,e){return Yb.call(n,e)}var Zb=/\S/;function Xb(n){return!Qb(Zb,n)}var e_={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function t_(n){return String(n).replace(/[&<>"'`=\/]/g,function(t){return e_[t]})}var r_=/\s*/,n_=/\s+/,Nc=/\s*=/,i_=/\s*\}/,a_=/#|\^|\/|>|\{|&|=|!/;function s_(n,e){if(!n)return[];var t=!1,r=[],i=[],a=[],s=!1,o=!1,u="",l=0;function c(){if(s&&!o)for(;a.length;)delete i[a.pop()];else a=[];s=!1,o=!1}var h,f,_;function p(I){if(typeof I=="string"&&(I=I.split(n_,2)),!Cr(I)||I.length!==2)throw new Error("Invalid tags: "+I);h=new RegExp(Ss(I[0])+"\\s*"),f=new RegExp("\\s*"+Ss(I[1])),_=new RegExp("\\s*"+Ss("}"+I[1]))}p(e||He.tags);for(var b=new yn(n),w,m,g,v,E,O;!b.eos();){if(w=b.pos,g=b.scanUntil(h),g)for(var C=0,R=g.length;C<R;++C)v=g.charAt(C),Xb(v)?(a.push(i.length),u+=v):(o=!0,t=!0,u+=" "),i.push(["text",v,w,w+1]),w+=1,v===`
|
|
128
|
+
`&&(c(),u="",l=0,t=!1);if(!b.scan(h))break;if(s=!0,m=b.scan(a_)||"name",b.scan(r_),m==="="?(g=b.scanUntil(Nc),b.scan(Nc),b.scanUntil(f)):m==="{"?(g=b.scanUntil(_),b.scan(i_),b.scanUntil(f),m="&"):g=b.scanUntil(f),!b.scan(f))throw new Error("Unclosed tag at "+b.pos);if(m==">"?E=[m,g,w,b.pos,u,l,t]:E=[m,g,w,b.pos],l++,i.push(E),m==="#"||m==="^")r.push(E);else if(m==="/"){if(O=r.pop(),!O)throw new Error('Unopened section "'+g+'" at '+w);if(O[1]!==g)throw new Error('Unclosed section "'+O[1]+'" at '+w)}else m==="name"||m==="{"||m==="&"?o=!0:m==="="&&p(g)}if(c(),O=r.pop(),O)throw new Error('Unclosed section "'+O[1]+'" at '+b.pos);return u_(o_(i))}function o_(n){for(var e=[],t,r,i=0,a=n.length;i<a;++i)t=n[i],t&&(t[0]==="text"&&r&&r[0]==="text"?(r[1]+=t[1],r[3]=t[3]):(e.push(t),r=t));return e}function u_(n){for(var e=[],t=e,r=[],i,a,s=0,o=n.length;s<o;++s)switch(i=n[s],i[0]){case"#":case"^":t.push(i),r.push(i),t=i[4]=[];break;case"/":a=r.pop(),a[5]=i[2],t=r.length>0?r[r.length-1][4]:e;break;default:t.push(i)}return e}function yn(n){this.string=n,this.tail=n,this.pos=0}yn.prototype.eos=function(){return this.tail===""};yn.prototype.scan=function(e){var t=this.tail.match(e);if(!t||t.index!==0)return"";var r=t[0];return this.tail=this.tail.substring(r.length),this.pos+=r.length,r};yn.prototype.scanUntil=function(e){var t=this.tail.search(e),r;switch(t){case-1:r=this.tail,this.tail="";break;case 0:r="";break;default:r=this.tail.substring(0,t),this.tail=this.tail.substring(t)}return this.pos+=r.length,r};function Or(n,e){this.view=n,this.cache={".":this.view},this.parent=e}Or.prototype.push=function(e){return new Or(e,this)};Or.prototype.lookup=function(e){var t=this.cache,r;if(t.hasOwnProperty(e))r=t[e];else{for(var i=this,a,s,o,u=!1;i;){if(e.indexOf(".")>0)for(a=i.view,s=e.split("."),o=0;a!=null&&o<s.length;)o===s.length-1&&(u=kc(a,s[o])||Kb(a,s[o])),a=a[s[o++]];else a=i.view[e],u=kc(i.view,e);if(u){r=a;break}i=i.parent}t[e]=r}return Io(r)&&(r=r.call(this.view)),r};function De(){this.templateCache={_cache:{},set:function(e,t){this._cache[e]=t},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}De.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()};De.prototype.parse=function(e,t){var r=this.templateCache,i=e+":"+(t||He.tags).join(":"),a=typeof r<"u",s=a?r.get(i):void 0;return s==null&&(s=s_(e,t),a&&r.set(i,s)),s};De.prototype.render=function(e,t,r,i){var a=this.getConfigTags(i),s=this.parse(e,a),o=t instanceof Or?t:new Or(t,void 0);return this.renderTokens(s,o,r,e,i)};De.prototype.renderTokens=function(e,t,r,i,a){for(var s="",o,u,l,c=0,h=e.length;c<h;++c)l=void 0,o=e[c],u=o[0],u==="#"?l=this.renderSection(o,t,r,i,a):u==="^"?l=this.renderInverted(o,t,r,i,a):u===">"?l=this.renderPartial(o,t,r,a):u==="&"?l=this.unescapedValue(o,t):u==="name"?l=this.escapedValue(o,t,a):u==="text"&&(l=this.rawValue(o)),l!==void 0&&(s+=l);return s};De.prototype.renderSection=function(e,t,r,i,a){var s=this,o="",u=t.lookup(e[1]);function l(f){return s.render(f,t,r,a)}if(u){if(Cr(u))for(var c=0,h=u.length;c<h;++c)o+=this.renderTokens(e[4],t.push(u[c]),r,i,a);else if(typeof u=="object"||typeof u=="string"||typeof u=="number")o+=this.renderTokens(e[4],t.push(u),r,i,a);else if(Io(u)){if(typeof i!="string")throw new Error("Cannot use higher-order sections without the original template");u=u.call(t.view,i.slice(e[3],e[5]),l),u!=null&&(o+=u)}else o+=this.renderTokens(e[4],t,r,i,a);return o}};De.prototype.renderInverted=function(e,t,r,i,a){var s=t.lookup(e[1]);if(!s||Cr(s)&&s.length===0)return this.renderTokens(e[4],t,r,i,a)};De.prototype.indentPartial=function(e,t,r){for(var i=t.replace(/[^ \t]/g,""),a=e.split(`
|
|
129
|
+
`),s=0;s<a.length;s++)a[s].length&&(s>0||!r)&&(a[s]=i+a[s]);return a.join(`
|
|
130
|
+
`)};De.prototype.renderPartial=function(e,t,r,i){if(r){var a=this.getConfigTags(i),s=Io(r)?r(e[1]):r[e[1]];if(s!=null){var o=e[6],u=e[5],l=e[4],c=s;u==0&&l&&(c=this.indentPartial(s,l,o));var h=this.parse(c,a);return this.renderTokens(h,t,r,c,i)}}};De.prototype.unescapedValue=function(e,t){var r=t.lookup(e[1]);if(r!=null)return r};De.prototype.escapedValue=function(e,t,r){var i=this.getConfigEscape(r)||He.escape,a=t.lookup(e[1]);if(a!=null)return typeof a=="number"&&i===He.escape?String(a):i(a)};De.prototype.rawValue=function(e){return e[1]};De.prototype.getConfigTags=function(e){return Cr(e)?e:e&&typeof e=="object"?e.tags:void 0};De.prototype.getConfigEscape=function(e){if(e&&typeof e=="object"&&!Cr(e))return e.escape};var He={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(n){sn.templateCache=n},get templateCache(){return sn.templateCache}},sn=new De;He.clearCache=function(){return sn.clearCache()};He.parse=function(e,t){return sn.parse(e,t)};He.render=function(e,t,r,i){if(typeof e!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+Jb(e)+'" was given as the first argument for mustache#render(template, view, partials)');return sn.render(e,t,r,i)};He.escape=t_;He.Scanner=yn;He.Context=Or;He.Writer=De;function Pd(){He.escape=n=>n}const wi=n=>{const e=n.split(""),t=[],r=(a,s)=>{for(let o=s;o<e.length;o+=1)if(a.includes(e[o]))return o;return-1};let i=0;for(;i<e.length;)if(e[i]==="{"&&i+1<e.length&&e[i+1]==="{")t.push({type:"literal",text:"{"}),i+=2;else if(e[i]==="}"&&i+1<e.length&&e[i+1]==="}")t.push({type:"literal",text:"}"}),i+=2;else if(e[i]==="{"){const a=r("}",i);if(a<0)throw new Error("Unclosed '{' in template.");t.push({type:"variable",name:e.slice(i+1,a).join("")}),i=a+1}else{if(e[i]==="}")throw new Error("Single '}' in template.");{const a=r("{}",i),s=(a<0?e.slice(i):e.slice(i,a)).join("");t.push({type:"literal",text:s}),i=a<0?e.length:a}}return t},xd=(n,e=[])=>{const t=[];for(const r of n)if(r[0]==="name"){const i=r[1].includes(".")?r[1].split(".")[0]:r[1];t.push({type:"variable",name:i})}else if(["#","&","^",">"].includes(r[0])){if(t.push({type:"variable",name:r[1]}),r[0]==="#"&&r.length>4&&Array.isArray(r[4])){const i=[...e,r[1]],a=xd(r[4],i);t.push(...a)}}else t.push({type:"literal",text:r[1]});return t},zs=n=>{Pd();const e=He.parse(n);return xd(e)},l_=(n,e)=>wi(n).reduce((t,r)=>{if(r.type==="variable"){if(r.name in e){const i=typeof e[r.name]=="string"?e[r.name]:JSON.stringify(e[r.name]);return t+i}throw new Error(`(f-string) Missing value for input ${r.name}`)}return t+r.text},""),c_=(n,e)=>(Pd(),He.render(n,e)),Hs={"f-string":l_,mustache:c_},f_={"f-string":wi,mustache:zs},Rt=(n,e,t)=>{try{return Hs[e](n,t)}catch(r){throw Ci(r,"INVALID_PROMPT_INPUT")}},Gs=(n,e)=>f_[e](n),Ad=(n,e,t)=>{if(!(e in Hs)){const r=Object.keys(Hs);throw new Error(`Invalid template format. Got \`${e}\`;
|
|
131
|
+
should be one of ${r}`)}try{const r=t.reduce((i,a)=>(i[a]="foo",i),{});Array.isArray(n)?n.forEach(i=>{if(i.type==="text")Rt(i.text,e,r);else if(i.type==="image_url")if(typeof i.image_url=="string")Rt(i.image_url,e,r);else{const a=i.image_url.url;Rt(a,e,r)}else throw new Error(`Invalid message template received. ${JSON.stringify(i,null,2)}`)}):Rt(n,e,r)}catch(r){throw new Error(`Invalid prompt schema: ${r.message}`)}};class Ke extends qs{static lc_name(){return"PromptTemplate"}constructor(e){if(super(e),Object.defineProperty(this,"template",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"templateFormat",{enumerable:!0,configurable:!0,writable:!0,value:"f-string"}),Object.defineProperty(this,"validateTemplate",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"additionalContentFields",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e.templateFormat==="mustache"&&e.validateTemplate===void 0&&(this.validateTemplate=!1),Object.assign(this,e),this.validateTemplate){if(this.templateFormat==="mustache")throw new Error("Mustache templates cannot be validated.");let t=this.inputVariables;this.partialVariables&&(t=t.concat(Object.keys(this.partialVariables))),Ad(this.template,this.templateFormat,t)}}_getPromptType(){return"prompt"}async format(e){const t=await this.mergePartialAndUserVariables(e);return Rt(this.template,this.templateFormat,t)}static fromExamples(e,t,r,i=`
|
|
132
|
+
|
|
133
|
+
`,a=""){const s=[a,...e,t].join(i);return new Ke({inputVariables:r,template:s})}static fromTemplate(e,t){const{templateFormat:r="f-string",...i}=t??{},a=new Set;return Gs(e,r).forEach(s=>{s.type==="variable"&&a.add(s.name)}),new Ke({inputVariables:[...a],templateFormat:r,template:e,...i})}async partial(e){const t=this.inputVariables.filter(a=>!(a in e)),r={...this.partialVariables??{},...e},i={...this,inputVariables:t,partialVariables:r};return new Ke(i)}serialize(){if(this.outputParser!==void 0)throw new Error("Cannot serialize a prompt template with an output parser");return{_type:this._getPromptType(),input_variables:this.inputVariables,template:this.template,template_format:this.templateFormat}}static async deserialize(e){if(!e.template)throw new Error("Prompt template must have a template");return new Ke({inputVariables:e.input_variables,template:e.template,templateFormat:e.template_format})}}const Lc=Object.freeze(Object.defineProperty({__proto__:null,PromptTemplate:Ke},Symbol.toStringTag,{value:"Module"}));class Kr extends Ro{static lc_name(){return"ImagePromptTemplate"}constructor(e){if(super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","prompts","image"]}),Object.defineProperty(this,"template",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"templateFormat",{enumerable:!0,configurable:!0,writable:!0,value:"f-string"}),Object.defineProperty(this,"validateTemplate",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"additionalContentFields",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.template=e.template,this.templateFormat=e.templateFormat??this.templateFormat,this.validateTemplate=e.validateTemplate??this.validateTemplate,this.additionalContentFields=e.additionalContentFields,this.validateTemplate){let t=this.inputVariables;this.partialVariables&&(t=t.concat(Object.keys(this.partialVariables))),Ad([{type:"image_url",image_url:this.template}],this.templateFormat,t)}}_getPromptType(){return"prompt"}async partial(e){const t=this.inputVariables.filter(a=>!(a in e)),r={...this.partialVariables??{},...e},i={...this,inputVariables:t,partialVariables:r};return new Kr(i)}async format(e){const t={};for(const[s,o]of Object.entries(this.template))typeof o=="string"?t[s]=Rt(o,this.templateFormat,e):t[s]=o;const r=e.url||t.url,i=e.detail||t.detail;if(!r)throw new Error("Must provide either an image URL.");if(typeof r!="string")throw new Error("url must be a string.");const a={url:r};return i&&(a.detail=i),a}async formatPromptValue(e){const t=await this.format(e);return new Yy(t)}}class Fc extends Ae{static lc_name(){return"DictPromptTemplate"}constructor(e){const t=e.templateFormat??"f-string",r=Vs(e.template,t);super({inputVariables:r,...e}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","prompts","dict"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"template",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"templateFormat",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"inputVariables",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.template=e.template,this.templateFormat=t,this.inputVariables=r}async format(e){return Ws(this.template,e,this.templateFormat)}async invoke(e){return await this._callWithConfig(this.format.bind(this),e,{runType:"prompt"})}}function Vs(n,e){const t=[];for(const r of Object.values(n))if(typeof r=="string")Gs(r,e).forEach(i=>{i.type==="variable"&&t.push(i.name)});else if(Array.isArray(r))for(const i of r)typeof i=="string"?Gs(i,e).forEach(a=>{a.type==="variable"&&t.push(a.name)}):typeof i=="object"&&t.push(...Vs(i,e));else typeof r=="object"&&r!==null&&t.push(...Vs(r,e));return Array.from(new Set(t))}function Ws(n,e,t){const r={};for(const[i,a]of Object.entries(n))if(typeof a=="string")r[i]=Rt(a,t,e);else if(Array.isArray(a)){const s=[];for(const o of a)typeof o=="string"?s.push(Rt(o,t,e)):typeof o=="object"&&s.push(Ws(o,e,t));r[i]=s}else typeof a=="object"&&a!==null?r[i]=Ws(a,e,t):r[i]=a;return r}class Co extends Ae{constructor(){super(...arguments),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","prompts","chat"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0})}async invoke(e,t){return this._callWithConfig(r=>this.formatMessages(r),e,{...t,runType:"prompt"})}}class Ei extends Co{static lc_name(){return"MessagesPlaceholder"}constructor(e){typeof e=="string"&&(e={variableName:e}),super(e),Object.defineProperty(this,"variableName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"optional",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.variableName=e.variableName,this.optional=e.optional??!1}get inputVariables(){return[this.variableName]}async formatMessages(e){const t=e[this.variableName];if(this.optional&&!t)return[];if(!t){const i=new Error(`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages as an input value. Received: undefined`);throw i.name="InputFormatError",i}let r;try{Array.isArray(t)?r=t.map(mi):r=[mi(t)]}catch(i){const a=typeof t=="string"?t:JSON.stringify(t,null,2),s=new Error([`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages or coerceable values as input.`,`Received value: ${a}`,`Additional message: ${i.message}`].join(`
|
|
134
|
+
|
|
135
|
+
`));throw s.name="InputFormatError",s.lc_error_code=i.lc_error_code,s}return r}}class d_ extends Co{constructor(e){"prompt"in e||(e={prompt:e}),super(e),Object.defineProperty(this,"prompt",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.prompt=e.prompt}get inputVariables(){return this.prompt.inputVariables}async formatMessages(e){return[await this.format(e)]}}class h_ extends Ro{constructor(e){super(e)}async format(e){return(await this.formatPromptValue(e)).toString()}async formatPromptValue(e){const t=await this.formatMessages(e);return new bd(t)}}class p_ extends d_{static lc_name(){return"ChatMessagePromptTemplate"}constructor(e,t){"prompt"in e||(e={prompt:e,role:t}),super(e),Object.defineProperty(this,"role",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.role=e.role}async format(e){return new ji(await this.prompt.format(e),this.role)}static fromTemplate(e,t,r){return new this(Ke.fromTemplate(e,{templateFormat:r?.templateFormat}),t)}}function m_(n){return n===null||typeof n!="object"||Array.isArray(n)?!1:Object.keys(n).length===1&&"text"in n&&typeof n.text=="string"}function g_(n){return n===null||typeof n!="object"||Array.isArray(n)?!1:"image_url"in n&&(typeof n.image_url=="string"||typeof n.image_url=="object"&&n.image_url!==null&&"url"in n.image_url&&typeof n.image_url.url=="string")}class $o extends Co{static _messageClass(){throw new Error("Can not invoke _messageClass from inside _StringImageMessagePromptTemplate")}constructor(e,t){if("prompt"in e||(e={prompt:e}),super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","prompts","chat"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"inputVariables",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"additionalOptions",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"prompt",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"messageClass",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"chatMessageClass",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.prompt=e.prompt,Array.isArray(this.prompt)){let r=[];this.prompt.forEach(i=>{"inputVariables"in i&&(r=r.concat(i.inputVariables))}),this.inputVariables=r}else this.inputVariables=this.prompt.inputVariables;this.additionalOptions=t??this.additionalOptions}createMessage(e){const t=this.constructor;if(t._messageClass()){const r=t._messageClass();return new r({content:e})}else if(t.chatMessageClass){const r=t.chatMessageClass();return new r({content:e,role:this.getRoleFromMessageClass(r.lc_name())})}else throw new Error("No message class defined")}getRoleFromMessageClass(e){switch(e){case"HumanMessage":return"human";case"AIMessage":return"ai";case"SystemMessage":return"system";case"ChatMessage":return"chat";default:throw new Error("Invalid message class name")}}static fromTemplate(e,t){if(typeof e=="string")return new this(Ke.fromTemplate(e,t));const r=[];for(const i of e)if(typeof i=="string")r.push(Ke.fromTemplate(i,t));else if(i!==null)if(m_(i)){let a="";typeof i.text=="string"&&(a=i.text??"");const s={...t,additionalContentFields:i};r.push(Ke.fromTemplate(a,s))}else if(g_(i)){let a=i.image_url??"",s,o=[];if(typeof a=="string"){let u;t?.templateFormat==="mustache"?u=zs(a):u=wi(a);const l=u.flatMap(c=>c.type==="variable"?[c.name]:[]);if((l?.length??0)>0){if(l.length>1)throw new Error(`Only one format variable allowed per image template.
|
|
136
|
+
Got: ${l}
|
|
137
|
+
From: ${a}`);o=[l[0]]}else o=[];a={url:a},s=new Kr({template:a,inputVariables:o,templateFormat:t?.templateFormat,additionalContentFields:i})}else if(typeof a=="object"){if("url"in a){let u;t?.templateFormat==="mustache"?u=zs(a.url):u=wi(a.url),o=u.flatMap(l=>l.type==="variable"?[l.name]:[])}else o=[];s=new Kr({template:a,inputVariables:o,templateFormat:t?.templateFormat,additionalContentFields:i})}else throw new Error("Invalid image template");r.push(s)}else typeof i=="object"&&r.push(new Fc({template:i,templateFormat:t?.templateFormat}));return new this({prompt:r,additionalOptions:t})}async format(e){if(this.prompt instanceof qs){const t=await this.prompt.format(e);return this.createMessage(t)}else{const t=[];for(const r of this.prompt){let i={};if(!("inputVariables"in r))throw new Error(`Prompt ${r} does not have inputVariables defined.`);for(const a of r.inputVariables)i||(i={[a]:e[a]}),i={...i,[a]:e[a]};if(r instanceof qs){const a=await r.format(i);let s;"additionalContentFields"in r&&(s=r.additionalContentFields),a!==""&&t.push({...s,type:"text",text:a})}else if(r instanceof Kr){const a=await r.format(i);let s;"additionalContentFields"in r&&(s=r.additionalContentFields),t.push({...s,type:"image_url",image_url:a})}else if(r instanceof Fc){const a=await r.format(i);let s;"additionalContentFields"in r&&(s=r.additionalContentFields),t.push({...s,...a})}}return this.createMessage(t)}}async formatMessages(e){return[await this.format(e)]}}class Rd extends $o{static _messageClass(){return Xe}static lc_name(){return"HumanMessagePromptTemplate"}}class y_ extends $o{static _messageClass(){return ot}static lc_name(){return"AIMessagePromptTemplate"}}class b_ extends $o{static _messageClass(){return yt}static lc_name(){return"SystemMessagePromptTemplate"}}function __(n){return typeof n.formatMessages=="function"}function v_(n,e){if(__(n)||_o(n))return n;if(Array.isArray(n)&&n[0]==="placeholder"){const i=n[1];if(e?.templateFormat==="mustache"&&typeof i=="string"&&i.slice(0,2)==="{{"&&i.slice(-2)==="}}"){const a=i.slice(2,-2);return new Ei({variableName:a,optional:!0})}else if(typeof i=="string"&&i[0]==="{"&&i[i.length-1]==="}"){const a=i.slice(1,-1);return new Ei({variableName:a,optional:!0})}throw new Error(`Invalid placeholder template for format ${e?.templateFormat??'"f-string"'}: "${n[1]}". Expected a variable name surrounded by ${e?.templateFormat==="mustache"?"double":"single"} curly braces.`)}const t=mi(n);let r;if(typeof t.content=="string"?r=t.content:r=t.content.map(i=>"text"in i?{...i,text:i.text}:"image_url"in i?{...i,image_url:i.image_url}:i),t._getType()==="human")return Rd.fromTemplate(r,e);if(t._getType()==="ai")return y_.fromTemplate(r,e);if(t._getType()==="system")return b_.fromTemplate(r,e);if(ji.isInstance(t))return p_.fromTemplate(t.content,t.role,e);throw new Error(`Could not coerce message prompt template from input. Received message type: "${t._getType()}".`)}function w_(n){return n.constructor.lc_name()==="MessagesPlaceholder"}class Yr extends h_{static lc_name(){return"ChatPromptTemplate"}get lc_aliases(){return{promptMessages:"messages"}}constructor(e){if(super(e),Object.defineProperty(this,"promptMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"validateTemplate",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"templateFormat",{enumerable:!0,configurable:!0,writable:!0,value:"f-string"}),e.templateFormat==="mustache"&&e.validateTemplate===void 0&&(this.validateTemplate=!1),Object.assign(this,e),this.validateTemplate){const t=new Set;for(const o of this.promptMessages)if(!(o instanceof tt))for(const u of o.inputVariables)t.add(u);const r=this.inputVariables,i=new Set(this.partialVariables?r.concat(Object.keys(this.partialVariables)):r),a=new Set([...i].filter(o=>!t.has(o)));if(a.size>0)throw new Error(`Input variables \`${[...a]}\` are not used in any of the prompt messages.`);const s=new Set([...t].filter(o=>!i.has(o)));if(s.size>0)throw new Error(`Input variables \`${[...s]}\` are used in prompt messages but not in the prompt template.`)}}_getPromptType(){return"chat"}async _parseImagePrompts(e,t){if(typeof e.content=="string")return e;const r=await Promise.all(e.content.map(async i=>{if(i.type!=="image_url")return i;let a="";typeof i.image_url=="string"?a=i.image_url:a=i.image_url.url;const o=await Ke.fromTemplate(a,{templateFormat:this.templateFormat}).format(t);return typeof i.image_url!="string"&&"url"in i.image_url?i.image_url.url=o:i.image_url=o,i}));return e.content=r,e}async formatMessages(e){const t=await this.mergePartialAndUserVariables(e);let r=[];for(const i of this.promptMessages)if(i instanceof tt)r.push(await this._parseImagePrompts(i,t));else{let a;this.templateFormat==="mustache"?a={...t}:a=i.inputVariables.reduce((o,u)=>{if(!(u in t)&&!(w_(i)&&i.optional))throw Ci(new Error(`Missing value for input variable \`${u.toString()}\``),"INVALID_PROMPT_INPUT");return o[u]=t[u],o},{});const s=await i.formatMessages(a);r=r.concat(s)}return r}async partial(e){const t=this.inputVariables.filter(a=>!(a in e)),r={...this.partialVariables??{},...e},i={...this,inputVariables:t,partialVariables:r};return new Yr(i)}static fromTemplate(e,t){const r=Ke.fromTemplate(e,t),i=new Rd({prompt:r});return this.fromMessages([i])}static fromMessages(e,t){const r=e.reduce((s,o)=>s.concat(o instanceof Yr?o.promptMessages:[v_(o,t)]),[]),i=e.reduce((s,o)=>o instanceof Yr?Object.assign(s,o.partialVariables):s,Object.create(null)),a=new Set;for(const s of r)if(!(s instanceof tt))for(const o of s.inputVariables)o in i||a.add(o);return new this({...t,inputVariables:[...a],promptMessages:r,partialVariables:i,templateFormat:t?.templateFormat})}static fromPromptMessages(e){return this.fromMessages(e)}}class E_ extends Ae{parseResultWithPrompt(e,t,r){return this.parseResult(e,r)}_baseMessageToString(e){return typeof e.content=="string"?e.content:this._baseMessageContentToString(e.content)}_baseMessageContentToString(e){return JSON.stringify(e)}async invoke(e,t){return typeof e=="string"?this._callWithConfig(async(r,i)=>this.parseResult([{text:r}],i?.callbacks),e,{...t,runType:"parser"}):this._callWithConfig(async(r,i)=>this.parseResult([{message:r,text:this._baseMessageToString(r)}],i?.callbacks),e,{...t,runType:"parser"})}}class S_ extends E_{parseResult(e,t){return this.parse(e[0].text,t)}async parseWithPrompt(e,t,r){return this.parse(e,r)}_type(){throw new Error("_type not implemented")}}class Si extends Error{constructor(e,t,r,i=!1){if(super(e),Object.defineProperty(this,"llmOutput",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"observation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sendToLLM",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.llmOutput=t,this.observation=r,this.sendToLLM=i,i&&(r===void 0||t===void 0))throw new Error("Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true");Ci(this,"OUTPUT_PARSING_FAILURE")}}var Id=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,O_=typeof self=="object"&&self&&self.Object===Object&&self,vt=Id||O_||Function("return this")(),Tr=vt.Symbol,Cd=Object.prototype,T_=Cd.hasOwnProperty,P_=Cd.toString,Dr=Tr?Tr.toStringTag:void 0;function x_(n){var e=T_.call(n,Dr),t=n[Dr];try{n[Dr]=void 0;var r=!0}catch{}var i=P_.call(n);return r&&(e?n[Dr]=t:delete n[Dr]),i}var A_=Object.prototype,R_=A_.toString;function I_(n){return R_.call(n)}var C_="[object Null]",$_="[object Undefined]",Dc=Tr?Tr.toStringTag:void 0;function bn(n){return n==null?n===void 0?$_:C_:Dc&&Dc in Object(n)?x_(n):I_(n)}function on(n){return n!=null&&typeof n=="object"}var Oi=Array.isArray;function $d(n){var e=typeof n;return n!=null&&(e=="object"||e=="function")}var j_="[object AsyncFunction]",M_="[object Function]",k_="[object GeneratorFunction]",N_="[object Proxy]";function jd(n){if(!$d(n))return!1;var e=bn(n);return e==M_||e==k_||e==j_||e==N_}var Os=vt["__core-js_shared__"],Uc=(function(){var n=/[^.]+$/.exec(Os&&Os.keys&&Os.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function L_(n){return!!Uc&&Uc in n}var F_=Function.prototype,D_=F_.toString;function zt(n){if(n!=null){try{return D_.call(n)}catch{}try{return n+""}catch{}}return""}var U_=/[\\^$.*+?()[\]{}|]/g,B_=/^\[object .+?Constructor\]$/,q_=Function.prototype,z_=Object.prototype,H_=q_.toString,G_=z_.hasOwnProperty,V_=RegExp("^"+H_.call(G_).replace(U_,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function W_(n){if(!$d(n)||L_(n))return!1;var e=jd(n)?V_:B_;return e.test(zt(n))}function J_(n,e){return n?.[e]}function $r(n,e){var t=J_(n,e);return W_(t)?t:void 0}var Js=$r(vt,"WeakMap"),K_=9007199254740991,Y_=/^(?:0|[1-9]\d*)$/;function Q_(n,e){var t=typeof n;return e=e??K_,!!e&&(t=="number"||t!="symbol"&&Y_.test(n))&&n>-1&&n%1==0&&n<e}function Md(n,e){return n===e||n!==n&&e!==e}var Z_=9007199254740991;function kd(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=Z_}function X_(n){return n!=null&&kd(n.length)&&!jd(n)}var ev=Object.prototype;function tv(n){var e=n&&n.constructor,t=typeof e=="function"&&e.prototype||ev;return n===t}function rv(n,e){for(var t=-1,r=Array(n);++t<n;)r[t]=e(t);return r}var nv="[object Arguments]";function Bc(n){return on(n)&&bn(n)==nv}var Nd=Object.prototype,iv=Nd.hasOwnProperty,av=Nd.propertyIsEnumerable,sv=Bc((function(){return arguments})())?Bc:function(n){return on(n)&&iv.call(n,"callee")&&!av.call(n,"callee")};function ov(){return!1}var Ld=typeof exports=="object"&&exports&&!exports.nodeType&&exports,qc=Ld&&typeof module=="object"&&module&&!module.nodeType&&module,uv=qc&&qc.exports===Ld,zc=uv?vt.Buffer:void 0,lv=zc?zc.isBuffer:void 0,Ks=lv||ov,cv="[object Arguments]",fv="[object Array]",dv="[object Boolean]",hv="[object Date]",pv="[object Error]",mv="[object Function]",gv="[object Map]",yv="[object Number]",bv="[object Object]",_v="[object RegExp]",vv="[object Set]",wv="[object String]",Ev="[object WeakMap]",Sv="[object ArrayBuffer]",Ov="[object DataView]",Tv="[object Float32Array]",Pv="[object Float64Array]",xv="[object Int8Array]",Av="[object Int16Array]",Rv="[object Int32Array]",Iv="[object Uint8Array]",Cv="[object Uint8ClampedArray]",$v="[object Uint16Array]",jv="[object Uint32Array]",we={};we[Tv]=we[Pv]=we[xv]=we[Av]=we[Rv]=we[Iv]=we[Cv]=we[$v]=we[jv]=!0;we[cv]=we[fv]=we[Sv]=we[dv]=we[Ov]=we[hv]=we[pv]=we[mv]=we[gv]=we[yv]=we[bv]=we[_v]=we[vv]=we[wv]=we[Ev]=!1;function Mv(n){return on(n)&&kd(n.length)&&!!we[bn(n)]}function kv(n){return function(e){return n(e)}}var Fd=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Qr=Fd&&typeof module=="object"&&module&&!module.nodeType&&module,Nv=Qr&&Qr.exports===Fd,Ts=Nv&&Id.process,Hc=(function(){try{var n=Qr&&Qr.require&&Qr.require("util").types;return n||Ts&&Ts.binding&&Ts.binding("util")}catch{}})(),Gc=Hc&&Hc.isTypedArray,Dd=Gc?kv(Gc):Mv,Lv=Object.prototype,Fv=Lv.hasOwnProperty;function Dv(n,e){var t=Oi(n),r=!t&&sv(n),i=!t&&!r&&Ks(n),a=!t&&!r&&!i&&Dd(n),s=t||r||i||a,o=s?rv(n.length,String):[],u=o.length;for(var l in n)Fv.call(n,l)&&!(s&&(l=="length"||i&&(l=="offset"||l=="parent")||a&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||Q_(l,u)))&&o.push(l);return o}function Uv(n,e){return function(t){return n(e(t))}}var Bv=Uv(Object.keys,Object),qv=Object.prototype,zv=qv.hasOwnProperty;function Hv(n){if(!tv(n))return Bv(n);var e=[];for(var t in Object(n))zv.call(n,t)&&t!="constructor"&&e.push(t);return e}function Gv(n){return X_(n)?Dv(n):Hv(n)}var un=$r(Object,"create");function Vv(){this.__data__=un?un(null):{},this.size=0}function Wv(n){var e=this.has(n)&&delete this.__data__[n];return this.size-=e?1:0,e}var Jv="__lodash_hash_undefined__",Kv=Object.prototype,Yv=Kv.hasOwnProperty;function Qv(n){var e=this.__data__;if(un){var t=e[n];return t===Jv?void 0:t}return Yv.call(e,n)?e[n]:void 0}var Zv=Object.prototype,Xv=Zv.hasOwnProperty;function ew(n){var e=this.__data__;return un?e[n]!==void 0:Xv.call(e,n)}var tw="__lodash_hash_undefined__";function rw(n,e){var t=this.__data__;return this.size+=this.has(n)?0:1,t[n]=un&&e===void 0?tw:e,this}function qt(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var r=n[e];this.set(r[0],r[1])}}qt.prototype.clear=Vv;qt.prototype.delete=Wv;qt.prototype.get=Qv;qt.prototype.has=ew;qt.prototype.set=rw;function nw(){this.__data__=[],this.size=0}function Fi(n,e){for(var t=n.length;t--;)if(Md(n[t][0],e))return t;return-1}var iw=Array.prototype,aw=iw.splice;function sw(n){var e=this.__data__,t=Fi(e,n);if(t<0)return!1;var r=e.length-1;return t==r?e.pop():aw.call(e,t,1),--this.size,!0}function ow(n){var e=this.__data__,t=Fi(e,n);return t<0?void 0:e[t][1]}function uw(n){return Fi(this.__data__,n)>-1}function lw(n,e){var t=this.__data__,r=Fi(t,n);return r<0?(++this.size,t.push([n,e])):t[r][1]=e,this}function wt(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var r=n[e];this.set(r[0],r[1])}}wt.prototype.clear=nw;wt.prototype.delete=sw;wt.prototype.get=ow;wt.prototype.has=uw;wt.prototype.set=lw;var ln=$r(vt,"Map");function cw(){this.size=0,this.__data__={hash:new qt,map:new(ln||wt),string:new qt}}function fw(n){var e=typeof n;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?n!=="__proto__":n===null}function Di(n,e){var t=n.__data__;return fw(e)?t[typeof e=="string"?"string":"hash"]:t.map}function dw(n){var e=Di(this,n).delete(n);return this.size-=e?1:0,e}function hw(n){return Di(this,n).get(n)}function pw(n){return Di(this,n).has(n)}function mw(n,e){var t=Di(this,n),r=t.size;return t.set(n,e),this.size+=t.size==r?0:1,this}function Ht(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var r=n[e];this.set(r[0],r[1])}}Ht.prototype.clear=cw;Ht.prototype.delete=dw;Ht.prototype.get=hw;Ht.prototype.has=pw;Ht.prototype.set=mw;function gw(n,e){for(var t=-1,r=e.length,i=n.length;++t<r;)n[i+t]=e[t];return n}function yw(){this.__data__=new wt,this.size=0}function bw(n){var e=this.__data__,t=e.delete(n);return this.size=e.size,t}function _w(n){return this.__data__.get(n)}function vw(n){return this.__data__.has(n)}var ww=200;function Ew(n,e){var t=this.__data__;if(t instanceof wt){var r=t.__data__;if(!ln||r.length<ww-1)return r.push([n,e]),this.size=++t.size,this;t=this.__data__=new Ht(r)}return t.set(n,e),this.size=t.size,this}function It(n){var e=this.__data__=new wt(n);this.size=e.size}It.prototype.clear=yw;It.prototype.delete=bw;It.prototype.get=_w;It.prototype.has=vw;It.prototype.set=Ew;function Sw(n,e){for(var t=-1,r=n==null?0:n.length,i=0,a=[];++t<r;){var s=n[t];e(s,t,n)&&(a[i++]=s)}return a}function Ow(){return[]}var Tw=Object.prototype,Pw=Tw.propertyIsEnumerable,Vc=Object.getOwnPropertySymbols,xw=Vc?function(n){return n==null?[]:(n=Object(n),Sw(Vc(n),function(e){return Pw.call(n,e)}))}:Ow;function Aw(n,e,t){var r=e(n);return Oi(n)?r:gw(r,t(n))}function Wc(n){return Aw(n,Gv,xw)}var Ys=$r(vt,"DataView"),Qs=$r(vt,"Promise"),Zs=$r(vt,"Set"),Jc="[object Map]",Rw="[object Object]",Kc="[object Promise]",Yc="[object Set]",Qc="[object WeakMap]",Zc="[object DataView]",Iw=zt(Ys),Cw=zt(ln),$w=zt(Qs),jw=zt(Zs),Mw=zt(Js),At=bn;(Ys&&At(new Ys(new ArrayBuffer(1)))!=Zc||ln&&At(new ln)!=Jc||Qs&&At(Qs.resolve())!=Kc||Zs&&At(new Zs)!=Yc||Js&&At(new Js)!=Qc)&&(At=function(n){var e=bn(n),t=e==Rw?n.constructor:void 0,r=t?zt(t):"";if(r)switch(r){case Iw:return Zc;case Cw:return Jc;case $w:return Kc;case jw:return Yc;case Mw:return Qc}return e});var Xc=vt.Uint8Array,kw="__lodash_hash_undefined__";function Nw(n){return this.__data__.set(n,kw),this}function Lw(n){return this.__data__.has(n)}function Ti(n){var e=-1,t=n==null?0:n.length;for(this.__data__=new Ht;++e<t;)this.add(n[e])}Ti.prototype.add=Ti.prototype.push=Nw;Ti.prototype.has=Lw;function Fw(n,e){for(var t=-1,r=n==null?0:n.length;++t<r;)if(e(n[t],t,n))return!0;return!1}function Dw(n,e){return n.has(e)}var Uw=1,Bw=2;function Ud(n,e,t,r,i,a){var s=t&Uw,o=n.length,u=e.length;if(o!=u&&!(s&&u>o))return!1;var l=a.get(n),c=a.get(e);if(l&&c)return l==e&&c==n;var h=-1,f=!0,_=t&Bw?new Ti:void 0;for(a.set(n,e),a.set(e,n);++h<o;){var p=n[h],b=e[h];if(r)var w=s?r(b,p,h,e,n,a):r(p,b,h,n,e,a);if(w!==void 0){if(w)continue;f=!1;break}if(_){if(!Fw(e,function(m,g){if(!Dw(_,g)&&(p===m||i(p,m,t,r,a)))return _.push(g)})){f=!1;break}}else if(!(p===b||i(p,b,t,r,a))){f=!1;break}}return a.delete(n),a.delete(e),f}function qw(n){var e=-1,t=Array(n.size);return n.forEach(function(r,i){t[++e]=[i,r]}),t}function zw(n){var e=-1,t=Array(n.size);return n.forEach(function(r){t[++e]=r}),t}var Hw=1,Gw=2,Vw="[object Boolean]",Ww="[object Date]",Jw="[object Error]",Kw="[object Map]",Yw="[object Number]",Qw="[object RegExp]",Zw="[object Set]",Xw="[object String]",e0="[object Symbol]",t0="[object ArrayBuffer]",r0="[object DataView]",ef=Tr?Tr.prototype:void 0,Ps=ef?ef.valueOf:void 0;function n0(n,e,t,r,i,a,s){switch(t){case r0:if(n.byteLength!=e.byteLength||n.byteOffset!=e.byteOffset)return!1;n=n.buffer,e=e.buffer;case t0:return!(n.byteLength!=e.byteLength||!a(new Xc(n),new Xc(e)));case Vw:case Ww:case Yw:return Md(+n,+e);case Jw:return n.name==e.name&&n.message==e.message;case Qw:case Xw:return n==e+"";case Kw:var o=qw;case Zw:var u=r&Hw;if(o||(o=zw),n.size!=e.size&&!u)return!1;var l=s.get(n);if(l)return l==e;r|=Gw,s.set(n,e);var c=Ud(o(n),o(e),r,i,a,s);return s.delete(n),c;case e0:if(Ps)return Ps.call(n)==Ps.call(e)}return!1}var i0=1,a0=Object.prototype,s0=a0.hasOwnProperty;function o0(n,e,t,r,i,a){var s=t&i0,o=Wc(n),u=o.length,l=Wc(e),c=l.length;if(u!=c&&!s)return!1;for(var h=u;h--;){var f=o[h];if(!(s?f in e:s0.call(e,f)))return!1}var _=a.get(n),p=a.get(e);if(_&&p)return _==e&&p==n;var b=!0;a.set(n,e),a.set(e,n);for(var w=s;++h<u;){f=o[h];var m=n[f],g=e[f];if(r)var v=s?r(g,m,f,e,n,a):r(m,g,f,n,e,a);if(!(v===void 0?m===g||i(m,g,t,r,a):v)){b=!1;break}w||(w=f=="constructor")}if(b&&!w){var E=n.constructor,O=e.constructor;E!=O&&"constructor"in n&&"constructor"in e&&!(typeof E=="function"&&E instanceof E&&typeof O=="function"&&O instanceof O)&&(b=!1)}return a.delete(n),a.delete(e),b}var u0=1,tf="[object Arguments]",rf="[object Array]",ei="[object Object]",l0=Object.prototype,nf=l0.hasOwnProperty;function c0(n,e,t,r,i,a){var s=Oi(n),o=Oi(e),u=s?rf:At(n),l=o?rf:At(e);u=u==tf?ei:u,l=l==tf?ei:l;var c=u==ei,h=l==ei,f=u==l;if(f&&Ks(n)){if(!Ks(e))return!1;s=!0,c=!1}if(f&&!c)return a||(a=new It),s||Dd(n)?Ud(n,e,t,r,i,a):n0(n,e,u,t,r,i,a);if(!(t&u0)){var _=c&&nf.call(n,"__wrapped__"),p=h&&nf.call(e,"__wrapped__");if(_||p){var b=_?n.value():n,w=p?e.value():e;return a||(a=new It),i(b,w,t,r,a)}}return f?(a||(a=new It),o0(n,e,t,r,i,a)):!1}function Bd(n,e,t,r,i){return n===e?!0:n==null||e==null||!on(n)&&!on(e)?n!==n&&e!==e:c0(n,e,t,r,Bd,i)}function f0(n,e){return Bd(n,e)}class d0{constructor(){}capture(){}shutdown(){return Promise.resolve()}}class qd extends bt{get returnValues(){return["output"]}get allowedTools(){}_agentType(){throw new Error("Not implemented")}returnStoppedResponse(e,t,r,i){if(e==="force")return Promise.resolve({returnValues:{output:"Agent stopped due to max iterations."},log:""});throw new Error(`Invalid stopping method: ${e}`)}async prepareForOutput(e,t){return{}}}class h0 extends qd{_agentActionType(){return"single"}}class p0 extends qd{_agentActionType(){return"multi"}}function m0(n){return!Array.isArray(n)&&n?.tool!==void 0}function g0(n){return n.runnable!==void 0}class zd extends mt{constructor(){super(...arguments),Object.defineProperty(this,"streamRunnable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"singleAction",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}static fromRunnables([e,...t],r){const i=mt.from([e,...t],r.name);return i.singleAction=r.singleAction,i.streamRunnable=r.streamRunnable,i}static isAgentRunnableSequence(e){return typeof e.singleAction=="boolean"}}class y0 extends h0{get inputKeys(){return[]}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain","agents","runnable"]}),Object.defineProperty(this,"runnable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"streamRunnable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"defaultRunName",{enumerable:!0,configurable:!0,writable:!0,value:"RunnableAgent"}),this.runnable=e.runnable,this.defaultRunName=e.defaultRunName??this.runnable.name??this.defaultRunName,this.streamRunnable=e.streamRunnable??this.streamRunnable}async plan(e,t,r,i){const a={...t,steps:e},s=Ce(i,{callbacks:r,runName:this.defaultRunName});if(this.streamRunnable){const o=await this.runnable.stream(a,s);let u;for await(const l of o)if(u===void 0)u=l;else throw new Error(["Multiple agent actions/finishes received in streamed agent output.",'Set "streamRunnable: false" when initializing the agent to invoke this agent in non-streaming mode.'].join(`
|
|
138
|
+
`));if(u===void 0)throw new Error(["No streaming output received from underlying runnable.",'Set "streamRunnable: false" when initializing the agent to invoke this agent in non-streaming mode.'].join(`
|
|
139
|
+
`));return u}else return this.runnable.invoke(a,s)}}class af extends p0{get inputKeys(){return[]}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain","agents","runnable"]}),Object.defineProperty(this,"runnable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"defaultRunName",{enumerable:!0,configurable:!0,writable:!0,value:"RunnableAgent"}),Object.defineProperty(this,"stop",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"streamRunnable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),this.runnable=e.runnable,this.stop=e.stop,this.defaultRunName=e.defaultRunName??this.runnable.name??this.defaultRunName,this.streamRunnable=e.streamRunnable??this.streamRunnable}async plan(e,t,r,i){const a={...t,steps:e},s=Ce(i,{callbacks:r,runName:this.defaultRunName});let o;if(this.streamRunnable){const u=await this.runnable.stream(a,s);let l;for await(const c of u)if(l===void 0)l=c;else throw new Error(["Multiple agent actions/finishes received in streamed agent output.",'Set "streamRunnable: false" when initializing the agent to invoke this agent in non-streaming mode.'].join(`
|
|
140
|
+
`));if(l===void 0)throw new Error(["No streaming output received from underlying runnable.",'Set "streamRunnable: false" when initializing the agent to invoke this agent in non-streaming mode.'].join(`
|
|
141
|
+
`));o=l}else o=await this.runnable.invoke(a,s);return m0(o)?[o]:o}}class b0 extends S_{}class _0 extends bt{get finalOutputs(){return this._finalOutputs}async setFinalOutputs(e){if(this._finalOutputs=void 0,e){const t=await this.agentExecutor.prepOutputs(this.inputs,e,!0);this._finalOutputs=t}}get nameToToolMap(){const e=this.agentExecutor.tools.map(t=>({[t.name]:t}));return Object.assign({},...e)}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain","agents","executor_iterator"]}),Object.defineProperty(this,"agentExecutor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"inputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"callbacks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"runName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_finalOutputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"runManager",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"intermediateSteps",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"iterations",{enumerable:!0,configurable:!0,writable:!0,value:0}),this.agentExecutor=e.agentExecutor,this.inputs=e.inputs,this.callbacks=e.callbacks,this.tags=e.tags,this.metadata=e.metadata,this.runName=e.runName,this.runManager=e.runManager,this.config=e.config}reset(){this.intermediateSteps=[],this.iterations=0,this._finalOutputs=void 0}updateIterations(){this.iterations+=1}async*streamIterator(){for(this.reset();;)try{this.iterations===0&&await this.onFirstStep(),yield await this._callNext()}catch(e){if("message"in e&&e.message.startsWith("Final outputs already reached: ")){if(!this.finalOutputs)throw e;return this.finalOutputs}throw this.runManager&&await this.runManager.handleChainError(e),e}}async onFirstStep(){if(this.iterations===0){const e=await Fe.configure(this.callbacks??this.config?.callbacks,this.agentExecutor.callbacks,this.tags??this.config?.tags,this.agentExecutor.tags,this.metadata??this.config?.metadata,this.agentExecutor.metadata,{verbose:this.agentExecutor.verbose});this.runManager=await e?.handleChainStart(this.agentExecutor.toJSON(),this.inputs,this.config?.runId,void 0,this.tags??this.config?.tags,this.metadata??this.config?.metadata,this.runName??this.config?.runName),this.config!==void 0&&delete this.config.runId}}async _executeNextStep(e){return this.agentExecutor._takeNextStep(this.nameToToolMap,this.inputs,this.intermediateSteps,e,this.config)}async _processNextStepOutput(e,t){if("returnValues"in e){const i=await this.agentExecutor._return(e,this.intermediateSteps,t);return this.runManager&&await this.runManager.handleChainEnd(i),await this.setFinalOutputs(i),i}this.intermediateSteps=this.intermediateSteps.concat(e);let r={};if(Array.isArray(e)&&e.length===1){const i=e[0],a=await this.agentExecutor._getToolReturn(i);a&&(r=await this.agentExecutor._return(a,this.intermediateSteps,t),await this.runManager?.handleChainEnd(r),await this.setFinalOutputs(r))}return r={intermediateSteps:e},r}async _stop(){const e=await this.agentExecutor.agent.returnStoppedResponse(this.agentExecutor.earlyStoppingMethod,this.intermediateSteps,this.inputs),t=await this.agentExecutor._return(e,this.intermediateSteps,this.runManager);return await this.setFinalOutputs(t),await this.runManager?.handleChainEnd(t),t}async _callNext(){if(this.finalOutputs)throw new Error(`Final outputs already reached: ${JSON.stringify(this.finalOutputs,null,2)}`);if(!this.agentExecutor.shouldContinueGetter(this.iterations))return this._stop();const e=await this._executeNextStep(this.runManager),t=await this._processNextStepOutput(e,this.runManager);return this.updateIterations(),t}}class xs extends Ub{constructor(){super(...arguments),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"_Exception"}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:"Exception tool"})}async _call(e){return e}}class jo extends Vb{static lc_name(){return"AgentExecutor"}get lc_namespace(){return["langchain","agents","executor"]}get inputKeys(){return this.agent.inputKeys}get outputKeys(){return this.agent.returnValues}constructor(e){let t,r=!0;if(Ae.isRunnable(e.agent)?(zd.isAgentRunnableSequence(e.agent)?e.agent.singleAction?t=new y0({runnable:e.agent,streamRunnable:e.agent.streamRunnable}):t=new af({runnable:e.agent,streamRunnable:e.agent.streamRunnable}):t=new af({runnable:e.agent}),r=!1):(g0(e.agent)&&(r=!1),t=e.agent),super(e),Object.defineProperty(this,"agent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tools",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"returnIntermediateSteps",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"maxIterations",{enumerable:!0,configurable:!0,writable:!0,value:15}),Object.defineProperty(this,"earlyStoppingMethod",{enumerable:!0,configurable:!0,writable:!0,value:"force"}),Object.defineProperty(this,"returnOnlyOutputs",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"handleParsingErrors",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"handleToolRuntimeErrors",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.agent=t,this.tools=e.tools,this.handleParsingErrors=e.handleParsingErrors??this.handleParsingErrors,this.handleToolRuntimeErrors=e.handleToolRuntimeErrors,this.returnOnlyOutputs=r,this.agent._agentActionType()==="multi"){for(const i of this.tools)if(i.returnDirect)throw new Error(`Tool with return direct ${i.name} not supported for multi-action agent.`)}this.returnIntermediateSteps=e.returnIntermediateSteps??this.returnIntermediateSteps,this.maxIterations=e.maxIterations??this.maxIterations,this.earlyStoppingMethod=e.earlyStoppingMethod??this.earlyStoppingMethod}static fromAgentAndTools(e){return new jo(e)}get shouldContinueGetter(){return this.shouldContinue.bind(this)}shouldContinue(e){return this.maxIterations===void 0||e<this.maxIterations}async _call(e,t,r){const i=Object.fromEntries(this.tools.map(l=>[l.name.toLowerCase(),l])),a=[];let s=0;const o=async l=>{const{returnValues:c}=l,h=await this.agent.prepareForOutput(c,a);await t?.handleAgentEnd(l);let f;return this.returnIntermediateSteps?f={...c,intermediateSteps:a,...h}:f={...c,...h},this.returnOnlyOutputs||(f={...e,...f}),f};for(;this.shouldContinue(s);){let l;try{l=await this.agent.plan(a,e,t?.getChild(),r)}catch(p){if(p instanceof Si){let b,w=p.message;if(this.handleParsingErrors===!0)p.sendToLLM?(b=p.observation,w=p.llmOutput??""):b="Invalid or incomplete response";else if(typeof this.handleParsingErrors=="string")b=this.handleParsingErrors;else if(typeof this.handleParsingErrors=="function")b=this.handleParsingErrors(p);else throw p;l={tool:"_Exception",toolInput:b,log:w}}else throw p}if("returnValues"in l)return o(l);let c;Array.isArray(l)?c=l:c=[l];const h=await Promise.all(c.map(async p=>{await t?.handleAgentAction(p);const b=p.tool==="_Exception"?new xs:i[p.tool?.toLowerCase()];let w;try{if(w=b?await b.invoke(p.toolInput,Ce(r,{callbacks:t?.getChild()})):`${p.tool} is not a valid tool, try another one.`,typeof w!="string")throw new Error("Received unsupported non-string response from tool call.")}catch(m){if(m instanceof rn){if(this.handleParsingErrors===!0)w="Invalid or incomplete tool input. Please try again.";else if(typeof this.handleParsingErrors=="string")w=this.handleParsingErrors;else if(typeof this.handleParsingErrors=="function")w=this.handleParsingErrors(m);else throw m;return w=await new xs().call(w,t?.getChild()),{action:p,observation:w??""}}else this.handleToolRuntimeErrors!==void 0&&(w=this.handleToolRuntimeErrors(m))}return{action:p,observation:w??""}}));a.push(...h);const f=a[a.length-1];if(i[f.action.tool?.toLowerCase()]?.returnDirect)return o({returnValues:{[this.agent.returnValues[0]]:f.observation},log:""});s+=1}const u=await this.agent.returnStoppedResponse(this.earlyStoppingMethod,a,e);return o(u)}async _takeNextStep(e,t,r,i,a){let s;try{s=await this.agent.plan(r,t,i?.getChild(),a)}catch(l){if(l instanceof Si){let c,h=l.message;if(this.handleParsingErrors===!0)l.sendToLLM?(c=l.observation,h=l.llmOutput??""):c="Invalid or incomplete response";else if(typeof this.handleParsingErrors=="string")c=this.handleParsingErrors;else if(typeof this.handleParsingErrors=="function")c=this.handleParsingErrors(l);else throw l;s={tool:"_Exception",toolInput:c,log:h}}else throw l}if("returnValues"in s)return s;let o;Array.isArray(s)?o=s:o=[s];const u=[];for(const l of o){let c="";if(i&&await i?.handleAgentAction(l),l.tool in e){const h=e[l.tool];try{if(c=await h.call(l.toolInput,i?.getChild()),typeof c!="string")throw new Error("Received unsupported non-string response from tool call.")}catch(f){if(f instanceof rn){if(this.handleParsingErrors===!0)c="Invalid or incomplete tool input. Please try again.";else if(typeof this.handleParsingErrors=="string")c=this.handleParsingErrors;else if(typeof this.handleParsingErrors=="function")c=this.handleParsingErrors(f);else throw f;c=await new xs().call(c,i?.getChild())}}}else c=`${l.tool} is not a valid tool, try another available tool: ${Object.keys(e).join(", ")}`;u.push({action:l,observation:c})}return u}async _return(e,t,r){r&&await r.handleAgentEnd(e);const i=e.returnValues;return this.returnIntermediateSteps&&(i.intermediateSteps=t),i}async _getToolReturn(e){const{action:t,observation:r}=e,i=Object.fromEntries(this.tools.map(s=>[s.name.toLowerCase(),s])),[a="output"]=this.agent.returnValues;return t.tool in i&&i[t.tool].returnDirect?{returnValues:{[a]:r},log:""}:null}_returnStoppedResponse(e){if(e==="force")return{returnValues:{output:"Agent stopped due to iteration limit or time limit."},log:""};throw new Error(`Got unsupported early_stopping_method: ${e}`)}async*_streamIterator(e,t){const i=new _0({inputs:e,agentExecutor:this,config:t,metadata:t?.metadata,tags:t?.tags,callbacks:t?.callbacks}).streamIterator();for await(const a of i)a&&(yield a)}_chainType(){return"agent_executor"}serialize(){throw new Error("Cannot serialize an AgentExecutor")}}function v0(n){return new wr({tool_call_id:n.action.toolCallId,content:n.observation,additional_kwargs:{name:n.action.tool}})}function w0(n){return n.flatMap(({action:e,observation:t})=>"messageLog"in e&&e.messageLog!==void 0?e.messageLog.concat(v0({action:e,observation:t})):[new ot(e.log)])}function E0(n){const e=typeof n.content=="string"?n.content:JSON.stringify(n.content);let t=[];if(n.tool_calls!==void 0&&n.tool_calls.length>0)t=n.tool_calls;else{if(!n.additional_kwargs.tool_calls||n.additional_kwargs.tool_calls.length===0)return{returnValues:{output:n.content},log:e};for(const r of n.additional_kwargs.tool_calls??[]){const i=r.function?.name;try{const a=JSON.parse(r.function.arguments);t.push({name:i,args:a,id:r.id})}catch(a){throw new Si(`Failed to parse tool arguments from chat model response. Text: "${JSON.stringify(t)}". ${a}`)}}}return t.map((r,i)=>{const a=i===0?[n]:[],s=`Invoking "${r.name}" with ${JSON.stringify(r.args??{})}
|
|
142
|
+
${e}`;return{tool:r.name,toolInput:r.args,toolCallId:r.id??"",log:s,messageLog:a}})}class S0 extends b0{constructor(){super(...arguments),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain","agents","tool_calling"]})}static lc_name(){return"ToolCallingAgentOutputParser"}async parse(e){throw new Error(`ToolCallingAgentOutputParser can only parse messages.
|
|
143
|
+
Passed input: ${e}`)}async parseResult(e){if("message"in e[0]&&_o(e[0].message))return E0(e[0].message);throw new Error("parseResult on ToolCallingAgentOutputParser only works on ChatGeneration output")}getFormatInstructions(){throw new Error("getFormatInstructions not implemented inside ToolCallingAgentOutputParser.")}}function O0(n){const e=n;return typeof e._modelType=="function"&&e._modelType()==="base_chat_model"}function T0({llm:n,tools:e,prompt:t,streamRunnable:r}){if(!t.inputVariables.includes("agent_scratchpad"))throw new Error(['Prompt must have an input variable named "agent_scratchpad".',`Found ${JSON.stringify(t.inputVariables)} instead.`].join(`
|
|
144
|
+
`));let i;if(O0(n)){if(n.bindTools===void 0)throw new Error('This agent requires that the "bind_tools()" method be implemented on the input model.');i=n.bindTools(e)}else i=n;return zd.fromRunnables([Gb.assign({agent_scratchpad:s=>w0(s.steps)}),t,i,new S0],{name:"ToolCallingAgent",streamRunnable:r,singleAction:!1})}var As,sf;function P0(){return sf||(sf=1,As=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}),As}var x0=P0();const of=ch(x0);var Pi={},Yt,Hd=(Yt=class{disallowedTools;connectorToolMap=new Map;constructor(e){this.disallowedTools=e??[]}static async createTools(e,t){const r=new this(t);(!e.activeSessions||Object.keys(e.activeSessions).length===0)&&(A.info("No active sessions found, creating new ones..."),await e.createAllSessions());const i=e.getAllActiveSessions(),a=Object.values(i).map(s=>s.connector);return r.createToolsFromConnectors(a)}async loadToolsForConnector(e){if(this.connectorToolMap.has(e)){const i=this.connectorToolMap.get(e);return A.debug(`Returning ${i.length} existing tools for connector`),i}const t=[];if(!await this.ensureConnectorInitialized(e))return[];for(const i of e.tools){const a=this.convertTool(i,e);a&&t.push(a)}return this.connectorToolMap.set(e,t),A.debug(`Loaded ${t.length} new tools for connector: ${t.map(i=>i?.name??String(i)).join(", ")}`),t}async createToolsFromConnectors(e){const t=[];for(const r of e){const i=await this.loadToolsForConnector(r);t.push(...i)}return A.debug(`Available tools: ${t.length}`),t}checkConnectorInitialized(e){return!!(e.tools&&e.tools.length)}async ensureConnectorInitialized(e){if(!this.checkConnectorInitialized(e)){A.debug("Connector doesn't have tools, initializing it");try{return await e.initialize(),!0}catch(t){return A.error(`Error initializing connector: ${t}`),!1}}return!0}},le(Yt,"BaseAdapter"),Yt);function Gd(n){try{return om.convert(n)}catch(e){return A.warn(`Failed to convert JSON schema to Zod: ${e}`),pt()}}le(Gd,"schemaToZod");var Qt,kt=(Qt=class extends Hd{constructor(e=[]){super(e)}convertTool(e,t){if(this.disallowedTools.includes(e.name))return null;const r=e.inputSchema?Gd(e.inputSchema):lt({}).optional();return new Bb({name:e.name??"NO NAME",description:e.description??"",schema:r,func:le(async a=>{A.debug(`MCP tool "${e.name}" received input: ${JSON.stringify(a)}`);try{const s=await t.callTool(e.name,a);return JSON.stringify(s)}catch(s){return A.error(`Error executing MCP tool: ${s.message}`),`Error executing MCP tool: ${String(s)}`}},"func")})}},le(Qt,"LangChainAdapter"),Qt),Zt,Ui=(Zt=class extends Li{name="mcp_server_tool";description="Base tool for MCP server operations.";schema;_manager;constructor(e){super(),this._manager=e}async _call(e,t,r){throw new Error("Method not implemented.")}get manager(){return this._manager}},le(Zt,"MCPServerTool"),Zt),A0=lt({}),Xt,R0=(Xt=class extends Ui{name="get_active_mcp_server";description="Get the currently active MCP (Model Context Protocol) server";schema=A0;constructor(e){super(e)}async _call(){return this.manager.activeServer?`Currently active MCP server: ${this.manager.activeServer}`:"No MCP server is currently active. Use connect_to_mcp_server to connect to a server."}},le(Xt,"AcquireActiveMCPServerTool"),Xt),er,I0=(er=class extends Li{name="add_mcp_server_from_config";description="Adds a new MCP server to the client from a configuration object and connects to it, making its tools available.";schema=lt({serverName:cn().describe("The name for the new MCP server."),serverConfig:pt().describe('The configuration object for the server. This should not include the top-level "mcpServers" key.')});manager;constructor(e){super(),this.manager=e}async _call({serverName:e,serverConfig:t}){try{this.manager.client.addServer(e,t);let r=`Server '${e}' added to the client.`;A.debug(`Connecting to new server '${e}' and discovering tools.`);const a=(await this.manager.client.createSession(e)).connector,s=await this.manager.adapter.createToolsFromConnectors([a]);this.manager.serverTools[e]=s,this.manager.initializedServers[e]=!0,this.manager.activeServer=e;const o=s.length;return r+=` Session created and connected. '${e}' is now the active server with ${o} tools available.`,r+=`
|
|
145
|
+
|
|
146
|
+
${s.map(u=>u.name).join(`
|
|
147
|
+
`)}`,A.info(r),r}catch(r){return A.error(`Failed to add or connect to server '${e}': ${r.message}`),`Failed to add or connect to server '${e}': ${r.message}`}}},le(er,"AddMCPServerFromConfigTool"),er),C0=lt({serverName:cn().describe("The name of the MCP server.")}),tr,$0=(tr=class extends Ui{name="connect_to_mcp_server";description="Connect to a specific MCP (Model Context Protocol) server to use its tools. Use this tool to connect to a specific server and use its tools.";schema=C0;constructor(e){super(e)}async _call({serverName:e}){const t=this.manager.client.getServerNames();if(!t.includes(e)){const r=t.length>0?t.join(", "):"none";return`Server '${e}' not found. Available servers: ${r}`}if(this.manager.activeServer===e)return`Already connected to MCP server '${e}'`;try{let r=this.manager.client.getSession(e);if(A.debug(`Using existing session for server '${e}'`),r||(A.debug(`Creating new session for server '${e}'`),r=await this.manager.client.createSession(e)),this.manager.activeServer=e,this.manager.serverTools[e]){const s=r.connector,o=await this.manager.adapter.createToolsFromConnectors([s]);this.manager.serverTools[e]=o,this.manager.initializedServers[e]=!0}const a=(this.manager.serverTools[e]||[]).length;return`Connected to MCP server '${e}'. ${a} tools are now available.`}catch(r){return A.error(`Error connecting to server '${e}': ${String(r)}`),`Failed to connect to server '${e}': ${String(r)}`}}},le(tr,"ConnectMCPServerTool"),tr),j0=lt({}),rr,M0=(rr=class extends Ui{name="list_mcp_servers";description="Lists all available MCP (Model Context Protocol) servers that can be connected to, along with the tools available on each server. Use this tool to discover servers and see what functionalities they offer.";schema=j0;constructor(e){super(e)}async _call(){const e=this.manager.client.getServerNames();if(e.length===0)return"No MCP servers are currently defined.";const t=["Available MCP servers:"];for(const r of e){const a=r===this.manager.activeServer?" (ACTIVE)":"";t.push(`- ${r}${a}`);try{const s=this.manager.serverTools?.[r]??[],o=Array.isArray(s)?s.length:0;t.push(`${o} tools available for this server
|
|
148
|
+
`)}catch(s){A.error(`Unexpected error listing tools for server '${r}': ${String(s)}`)}}return t.join(`
|
|
149
|
+
`)}},le(rr,"ListMCPServersTool"),rr),k0=lt({}),nr,N0=(nr=class extends Ui{name="disconnect_from_mcp_server";description="Disconnect from the currently active MCP (Model Context Protocol) server";schema=k0;constructor(e){super(e)}async _call(){if(!this.manager.activeServer)return"No MCP server is currently active, so there's nothing to disconnect from.";const e=this.manager.activeServer;return this.manager.activeServer=null,`Successfully disconnected from MCP server '${e}'.`}},le(nr,"ReleaseMCPServerConnectionTool"),nr),ir,L0=(ir=class{initializedServers={};serverTools={};client;adapter;activeServer=null;overrideManagementTools;constructor(e,t,r){this.client=e,this.adapter=t,this.overrideManagementTools=r}setManagementTools(e){this.overrideManagementTools=e,A.info(`Overriding default management tools with a new set of ${e.length} tools.`)}logState(e){const t=this.client.getServerNames(),r=Object.keys(this.client.getAllActiveSessions());if(t.length===0){A.info("Server Manager State: No servers configured.");return}const i=t.map(a=>({"Server Name":a,Connected:r.includes(a)?"✅":"❌",Initialized:this.initializedServers[a]?"✅":"❌","Tool Count":this.serverTools[a]?.length??0,Active:this.activeServer===a?"✅":"❌"}));A.info(`Server Manager State: [${e}]`),console.table(i)}initialize(){(this.client.getServerNames?.()).length===0&&A.warn("No MCP servers defined in client configuration")}async prefetchServerTools(){const e=this.client.getServerNames();for(const t of e)try{let r=null;if(r=this.client.getSession(t),A.debug(`Using existing session for server '${t}' to prefetch tools.`),r||(r=await this.client.createSession(t).catch(i=>(A.warn(`Could not create session for '${t}' during prefetch: ${i}`),null)),A.debug(`Temporarily created session for '${t}' to prefetch tools.`)),r){const i=r.connector;let a=[];try{a=await this.adapter.createToolsFromConnectors([i])}catch(u){A.error(`Failed to create tools from connector for server '${t}': ${u}`);continue}const s=this.serverTools[t];!s||!f0(s,a)?(this.serverTools[t]=a,this.initializedServers[t]=!0,A.debug(`Prefetched ${a.length} tools for server '${t}'.`)):A.debug(`Tools for server '${t}' unchanged, using cached version.`)}}catch(r){A.error(`Error prefetching tools for server '${t}': ${r}`)}}get tools(){A.level==="debug"&&this.logState("Providing tools to agent");const e=this.overrideManagementTools??[new I0(this),new M0(this),new $0(this),new R0(this),new N0(this)];if(this.activeServer&&this.serverTools[this.activeServer]){const t=this.serverTools[this.activeServer];return A.debug(`Adding ${t.length} tools from active server '${this.activeServer}'`),[...e,...t]}return e}},le(ir,"ServerManager"),ir),ar,Xs=(ar=class{customCallbacks;availableHandlers=[];handlerNames=[];initialized=!1;verbose;observe;agentId;metadata;metadataProvider;tagsProvider;constructor(e={}){this.customCallbacks=e.customCallbacks,this.verbose=e.verbose??!1,this.observe=e.observe??!0,this.agentId=e.agentId,this.metadata=e.metadata,this.metadataProvider=e.metadataProvider,this.tagsProvider=e.tagsProvider}async collectAvailableHandlers(){if(!this.initialized){try{const{langfuseHandler:e,langfuseInitPromise:t}=await Me(async()=>{const{langfuseHandler:i,langfuseInitPromise:a}=await Promise.resolve().then(()=>uf);return{langfuseHandler:i,langfuseInitPromise:a}},void 0);if(this.agentId||this.metadata||this.metadataProvider||this.tagsProvider){const{initializeLangfuse:i}=await Me(async()=>{const{initializeLangfuse:a}=await Promise.resolve().then(()=>uf);return{initializeLangfuse:a}},void 0);await i(this.agentId,this.metadata,this.metadataProvider,this.tagsProvider),A.debug(`ObservabilityManager: Reinitialized Langfuse with agent ID: ${this.agentId}, metadata: ${JSON.stringify(this.metadata)}`)}else{const i=t();i&&await i}const r=e();r&&(this.availableHandlers.push(r),this.handlerNames.push("Langfuse"),A.debug("ObservabilityManager: Langfuse handler available"))}catch{A.debug("ObservabilityManager: Langfuse module not available")}this.initialized=!0}}async getCallbacks(){return this.observe?this.customCallbacks?(A.debug(`ObservabilityManager: Using ${this.customCallbacks.length} custom callbacks`),this.customCallbacks):(await this.collectAvailableHandlers(),this.availableHandlers.length>0?A.debug(`ObservabilityManager: Using ${this.availableHandlers.length} handlers`):A.debug("ObservabilityManager: No callbacks configured"),this.availableHandlers):(A.debug("ObservabilityManager: Observability disabled via observe=false"),[])}async getHandlerNames(){return this.observe?this.customCallbacks?this.customCallbacks.map(e=>e.constructor.name):(await this.collectAvailableHandlers(),this.handlerNames):[]}async hasCallbacks(){return this.observe?(await this.getCallbacks()).length>0:!1}addCallback(e){this.customCallbacks||(this.customCallbacks=[]),this.customCallbacks.push(e),A.debug(`ObservabilityManager: Added custom callback: ${e.constructor.name}`)}clearCallbacks(){this.customCallbacks=[],A.debug("ObservabilityManager: Cleared all custom callbacks")}async flush(){const e=await this.getCallbacks();for(const t of e)"flushAsync"in t&&typeof t.flushAsync=="function"&&await t.flushAsync();A.debug("ObservabilityManager: All traces flushed")}async shutdown(){await this.flush();const e=await this.getCallbacks();for(const t of e)"shutdownAsync"in t&&typeof t.shutdownAsync=="function"?await t.shutdownAsync():"shutdown"in t&&typeof t.shutdown=="function"&&await t.shutdown();A.debug("ObservabilityManager: All handlers shutdown")}toString(){const e=this.handlerNames;return e.length>0?`ObservabilityManager(handlers=${e.join(", ")})`:"ObservabilityManager(no handlers)"}},le(ar,"ObservabilityManager"),ar),sr,F0=(sr=class{},le(sr,"BaseTelemetryEvent"),sr),or,D0=(or=class extends F0{constructor(e){super(),this.data=e}get name(){return"mcp_agent_execution"}get properties(){return{execution_method:this.data.executionMethod,query:this.data.query,query_length:this.data.query.length,success:this.data.success,model_provider:this.data.modelProvider,model_name:this.data.modelName,server_count:this.data.serverCount,server_identifiers:this.data.serverIdentifiers,total_tools_available:this.data.totalToolsAvailable,tools_available_names:this.data.toolsAvailableNames,max_steps_configured:this.data.maxStepsConfigured,memory_enabled:this.data.memoryEnabled,use_server_manager:this.data.useServerManager,max_steps_used:this.data.maxStepsUsed,manage_connector:this.data.manageConnector,external_history_used:this.data.externalHistoryUsed,steps_taken:this.data.stepsTaken??null,tools_used_count:this.data.toolsUsedCount??null,tools_used_names:this.data.toolsUsedNames??null,response:this.data.response??null,response_length:this.data.response?this.data.response.length:null,execution_time_ms:this.data.executionTimeMs??null,error_type:this.data.errorType??null,conversation_history_length:this.data.conversationHistoryLength??null}}},le(or,"MCPAgentExecutionEvent"),or);function ii(){try{if(typeof __dirname>"u"||typeof Xr>"u")return"unknown";const n=Bt(__dirname,"../../package.json");return JSON.parse((void 0)(n,"utf-8")).version||"unknown"}catch{return"unknown"}}le(ii,"getPackageVersion");function Vd(n){return n._llm_type||n.constructor.name.toLowerCase()}le(Vd,"getModelProvider");function Wd(n){if("_identifyingParams"in n){const e=n._identifyingParams;if(typeof e=="object"&&e!==null){for(const t of["model","modelName","model_name","modelId","model_id","deploymentName","deployment_name"])if(t in e)return String(e[t])}}return n.model||n.modelName||n.constructor.name}le(Wd,"getModelName");function Jd(n){return[Vd(n),Wd(n)]}le(Jd,"extractModelInfo");function Zr(){try{return typeof navigator<"u"&&navigator.userAgent?.includes("Cloudflare-Workers")||typeof globalThis.EdgeRuntime<"u"||typeof globalThis.Deno<"u"?!1:typeof process<"u"&&!0&&typeof __dirname<"u"&&(typeof Xr<"u"&&typeof Xr<"u"&&!1)}catch{return!1}}le(Zr,"isNodeJSEnvironment");var ur,U0=(ur=class{endpoint;timeout;constructor(e,t=3e3){this.endpoint=e,this.timeout=t}async logEvent(e){try{const t=new AbortController,r=setTimeout(()=>t.abort(),this.timeout),i=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:t.signal});if(clearTimeout(r),!i.ok)throw new Error(`HTTP error! status: ${i.status}`)}catch(t){A.debug(`Failed to send Scarf event: ${t}`)}}},le(ur,"ScarfEventLogger"),ur);function eo(){if(!Zr())return"/tmp/mcp_use_cache";const n=Pi.XDG_CACHE_HOME;if(n&&oo(n))return n;const e=(void 0)();return Bt(e,".cache")}le(eo,"getCacheHome");var et,to=(et=class{USER_ID_PATH=Bt(eo(),"mcp_use_3","telemetry_user_id");VERSION_DOWNLOAD_PATH=Bt(eo(),"mcp_use","download_version");PROJECT_API_KEY="phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";HOST="https://eu.i.posthog.com";SCARF_GATEWAY_URL="https://mcpuse.gateway.scarf.sh/events-ts";UNKNOWN_USER_ID="UNKNOWN_USER_ID";_currUserId=null;_posthogClient=null;_scarfClient=null;_source="typescript";constructor(){const e=Zr(),t=typeof process<"u"&&Pi?.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase()==="false"||!1;if(this._source=typeof process<"u"&&Pi?.MCP_USE_TELEMETRY_SOURCE||"typescript",t)this._posthogClient=null,this._scarfClient=null,A.debug("Telemetry disabled via environment variable");else if(!e)this._posthogClient=null,this._scarfClient=null,A.debug("Telemetry disabled - non-Node.js environment detected (e.g., Cloudflare Workers)");else{A.info("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable.");try{this._posthogClient=new d0(this.PROJECT_API_KEY,{host:this.HOST,disableGeoip:!1})}catch(r){A.warn(`Failed to initialize PostHog telemetry: ${r}`),this._posthogClient=null}try{this._scarfClient=new U0(this.SCARF_GATEWAY_URL,3e3)}catch(r){A.warn(`Failed to initialize Scarf telemetry: ${r}`),this._scarfClient=null}}}static getInstance(){return et.instance||(et.instance=new et),et.instance}setSource(e){this._source=e,A.debug(`Telemetry source set to: ${e}`)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!Zr())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{if(!(void 0)(this.USER_ID_PATH)){A.debug(`Creating user ID path: ${this.USER_ID_PATH}`),(void 0)(li(this.USER_ID_PATH),{recursive:!0});const t=cf();(void 0)(this.USER_ID_PATH,t),this._currUserId=t,A.debug(`User ID path created: ${this.USER_ID_PATH}`)}this.trackPackageDownload({triggered_by:"user_id_property"}).catch(t=>A.debug(`Failed to track package download: ${t}`))}catch(e){A.debug(`Failed to get/create user ID: ${e}`),this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}async capture(e){if(!(!this._posthogClient&&!this._scarfClient)){if(this._posthogClient)try{const t={...e.properties};t.mcp_use_version=ii(),t.language="typescript",t.source=this._source,this._posthogClient.capture({distinctId:this.userId,event:e.name,properties:t})}catch(t){A.debug(`Failed to track PostHog event ${e.name}: ${t}`)}if(this._scarfClient)try{const t={};t.mcp_use_version=ii(),t.user_id=this.userId,t.event=e.name,t.language="typescript",t.source=this._source,await this._scarfClient.logEvent(t)}catch(t){A.debug(`Failed to track Scarf event ${e.name}: ${t}`)}}}async trackPackageDownload(e){if(this._scarfClient&&Zr())try{const t=ii();let r=!1,i=!1;if((void 0)(this.VERSION_DOWNLOAD_PATH)||(r=!0,i=!0,(void 0)(li(this.VERSION_DOWNLOAD_PATH),{recursive:!0}),(void 0)(this.VERSION_DOWNLOAD_PATH,t)),r){A.debug(`Tracking package download event with properties: ${JSON.stringify(e)}`);const a={...e||{}};a.mcp_use_version=t,a.user_id=this.userId,a.event="package_download",a.first_download=i,a.language="typescript",a.source=this._source,await this._scarfClient.logEvent(a)}}catch(t){A.debug(`Failed to track Scarf package_download event: ${t}`)}}async trackAgentExecution(e){const t=new D0(e);await this.capture(t)}flush(){if(this._posthogClient)try{this._posthogClient.flush(),A.debug("PostHog client telemetry queue flushed")}catch(e){A.debug(`Failed to flush PostHog client: ${e}`)}this._scarfClient&&A.debug("Scarf telemetry events sent immediately (no flush needed)")}shutdown(){if(this._posthogClient)try{this._posthogClient.shutdown(),A.debug("PostHog client shutdown successfully")}catch(e){A.debug(`Error shutting down PostHog client: ${e}`)}this._scarfClient&&A.debug("Scarf telemetry client shutdown (no action needed)")}},le(et,"Telemetry"),jr(et,"instance",null),et);function B0(n){to.getInstance().setSource(n)}le(B0,"setTelemetrySource");var q0="/api/v1/chats",z0="/api/v1/chats/{chat_id}/execute",lr,Kd=(lr=class{agentId;apiKey;baseUrl;chatId=null;constructor(e){this.agentId=e.agentId,this.baseUrl=e.baseUrl??"https://cloud.mcp-use.com";const t=e.apiKey??Pi.MCP_USE_API_KEY;if(!t)throw new Error("API key is required for remote execution. Please provide it as a parameter or set the MCP_USE_API_KEY environment variable. You can get an API key from https://cloud.mcp-use.com");this.apiKey=t}pydanticToJsonSchema(e){return Nt(e)}parseStructuredResponse(e,t){let r;if(typeof e=="object"&&e!==null)if("result"in e){const i=e.result;typeof i=="object"&&i!==null&&"result"in i?r=i.result:r=i}else r=e;else if(typeof e=="string")try{r=JSON.parse(e)}catch{r={content:e}}else r=e;try{return t.parse(r)}catch(i){A.warn(`Failed to parse structured output: ${i}`);const a=t._def?.shape();if(a&&"content"in a)return t.parse({content:String(r)});throw i}}async createChatSession(){const e={title:`Remote Agent Session - ${this.agentId}`,agent_id:this.agentId,type:"agent_execution"},t={"Content-Type":"application/json","x-api-key":this.apiKey},r=`${this.baseUrl}${q0}`;A.info(`📝 Creating chat session for agent ${this.agentId}`);try{const i=await fetch(r,{method:"POST",headers:t,body:JSON.stringify(e)});if(!i.ok){const o=await i.text(),u=i.status;throw u===404?new Error(`Agent not found: Agent '${this.agentId}' does not exist or you don't have access to it. Please verify the agent ID and ensure it exists in your account.`):new Error(`Failed to create chat session: ${u} - ${o}`)}const s=(await i.json()).id;return A.info(`✅ Chat session created: ${s}`),s}catch(i){throw i instanceof Error?new TypeError(`Failed to create chat session: ${i.message}`):new Error(`Failed to create chat session: ${String(i)}`)}}async run(e,t,r,i,a){i!==void 0&&A.warn("External history is not yet supported for remote execution");try{A.info(`🌐 Executing query on remote agent ${this.agentId}`),this.chatId===null&&(this.chatId=await this.createChatSession());const s=this.chatId,o={query:e,max_steps:t??10};a&&(o.output_schema=this.pydanticToJsonSchema(a),A.info("🔧 Using structured output with schema"));const u={"Content-Type":"application/json","x-api-key":this.apiKey},l=`${this.baseUrl}${z0.replace("{chat_id}",s)}`;A.info(`🚀 Executing agent in chat ${s}`);const c=await fetch(l,{method:"POST",headers:u,body:JSON.stringify(o),signal:AbortSignal.timeout(3e5)});if(!c.ok){const f=await c.text(),_=c.status;throw _===401?(A.error(`❌ Authentication failed: ${f}`),new Error("Authentication failed: Invalid or missing API key. Please check your API key and ensure the MCP_USE_API_KEY environment variable is set correctly.")):_===403?(A.error(`❌ Access forbidden: ${f}`),new Error(`Access denied: You don't have permission to execute agent '${this.agentId}'. Check if the agent exists and you have the necessary permissions.`)):_===404?(A.error(`❌ Agent not found: ${f}`),new Error(`Agent not found: Agent '${this.agentId}' does not exist or you don't have access to it. Please verify the agent ID and ensure it exists in your account.`)):_===422?(A.error(`❌ Validation error: ${f}`),new Error(`Request validation failed: ${f}. Please check your query parameters and output schema format.`)):_===500?(A.error(`❌ Server error: ${f}`),new Error("Internal server error occurred during agent execution. Please try again later or contact support if the issue persists.")):(A.error(`❌ Remote execution failed with status ${_}: ${f}`),new Error(`Remote agent execution failed: ${_} - ${f}`))}const h=await c.json();if(A.info(`🔧 Response: ${JSON.stringify(h)}`),A.info("✅ Remote execution completed successfully"),typeof h=="object"&&h!==null){if(h.status==="error"||h.error!==null){const f=h.error??String(h);throw A.error(`❌ Remote agent execution failed: ${f}`),new Error(`Remote agent execution failed: ${f}`)}if(String(h).includes("failed to initialize"))throw A.error(`❌ Agent initialization failed: ${h}`),new Error(`Agent initialization failed on remote server. This usually indicates:
|
|
150
|
+
• Invalid agent configuration (LLM model, system prompt)
|
|
151
|
+
• Missing or invalid MCP server configurations
|
|
152
|
+
• Network connectivity issues with MCP servers
|
|
153
|
+
• Missing environment variables or credentials
|
|
154
|
+
Raw error: ${h}`)}return a?this.parseStructuredResponse(h,a):typeof h=="object"&&h!==null&&"result"in h?h.result:typeof h=="string"?h:String(h)}catch(s){throw s instanceof Error?s.name==="AbortError"?(A.error(`❌ Remote execution timed out: ${s}`),new Error("Remote agent execution timed out. The server may be overloaded or the query is taking too long to process. Try again or use a simpler query.")):(A.error(`❌ Remote execution error: ${s}`),new Error(`Remote agent execution failed: ${s.message}`)):(A.error(`❌ Remote execution error: ${s}`),new Error(`Remote agent execution failed: ${String(s)}`))}}async*stream(e,t,r,i,a){return await this.run(e,t,r,i,a)}async close(){A.info("🔌 Remote agent client closed")}},le(lr,"RemoteAgent"),lr);function Yd(n,e){const t=new Set(e??[]),r=[];for(const i of n){if(t.has(i.name))continue;const a=i.description.replace(/\{/g,"{{").replace(/\}/g,"}}");r.push(`- ${i.name}: ${a}`)}return r}le(Yd,"generateToolDescriptions");function Qd(n,e,t){const r=e.join(`
|
|
155
|
+
`);let i;return n.includes("{tool_descriptions}")?i=n.replace("{tool_descriptions}",r):(console.warn("`{tool_descriptions}` placeholder not found; appending at end."),i=`${n}
|
|
156
|
+
|
|
157
|
+
Available tools:
|
|
158
|
+
${r}`),t&&(i+=`
|
|
159
|
+
|
|
160
|
+
${t}`),i}le(Qd,"buildSystemPromptContent");function Zd(n,e,t,r,i,a,s){if(a)return new yt({content:a});const o=r?t:e,u=Yd(n,i),l=Qd(o,u,s);return new yt({content:l})}le(Zd,"createSystemMessage");var H0=`You are a helpful AI assistant.
|
|
161
|
+
You have access to the following tools:
|
|
162
|
+
|
|
163
|
+
{tool_descriptions}
|
|
164
|
+
|
|
165
|
+
Use the following format:
|
|
166
|
+
|
|
167
|
+
Question: the input question you must answer
|
|
168
|
+
Thought: you should always think about what to do
|
|
169
|
+
Action: the action to take, should be one of the available tools
|
|
170
|
+
Action Input: the input to the action
|
|
171
|
+
Observation: the result of the action
|
|
172
|
+
... (this Thought/Action/Action Input/Observation can repeat N times)
|
|
173
|
+
Thought: I now know the final answer
|
|
174
|
+
Final Answer: the final answer to the original input question`,G0=`You are a helpful assistant designed to interact with MCP
|
|
175
|
+
(Model Context Protocol) servers. You can manage connections to different servers and use the tools
|
|
176
|
+
provided by the currently active server.
|
|
177
|
+
|
|
178
|
+
Important: The available tools change depending on which server is active.
|
|
179
|
+
If a request requires tools not listed below (e.g., file operations, web browsing,
|
|
180
|
+
image manipulation), you MUST first connect to the appropriate server using
|
|
181
|
+
'connect_to_mcp_server'.
|
|
182
|
+
Use 'list_mcp_servers' to find the relevant server if you are unsure.
|
|
183
|
+
Only after successfully connecting and seeing the new tools listed in
|
|
184
|
+
the response should you attempt to use those server-specific tools.
|
|
185
|
+
Before attempting a task that requires specific tools, you should
|
|
186
|
+
ensure you are connected to the correct server and aware of its
|
|
187
|
+
available tools. If unsure, use 'list_mcp_servers' to see options
|
|
188
|
+
or 'get_active_mcp_server' to check the current connection.
|
|
189
|
+
|
|
190
|
+
When you connect to a server using 'connect_to_mcp_server',
|
|
191
|
+
you will be informed about the new tools that become available.
|
|
192
|
+
You can then use these server-specific tools in subsequent steps.
|
|
193
|
+
|
|
194
|
+
Here are the tools *currently* available to you (this list includes server management tools and will
|
|
195
|
+
change when you connect to a server):
|
|
196
|
+
{tool_descriptions}
|
|
197
|
+
`,cr,V0=(cr=class{llm;client;connectors;maxSteps;autoInitialize;memoryEnabled;disallowedTools;additionalTools;useServerManager;verbose;observe;systemPrompt;systemPromptTemplateOverride;additionalInstructions;_initialized=!1;conversationHistory=[];_agentExecutor=null;sessions={};systemMessage=null;_tools=[];adapter;serverManager=null;telemetry;modelProvider;modelName;observabilityManager;callbacks=[];metadata={};tags=[];isRemote=!1;remoteAgent=null;constructor(e){if(e.agentId){this.isRemote=!0,this.remoteAgent=new Kd({agentId:e.agentId,apiKey:e.apiKey,baseUrl:e.baseUrl}),this.maxSteps=e.maxSteps??5,this.memoryEnabled=e.memoryEnabled??!0,this.autoInitialize=e.autoInitialize??!1,this.verbose=e.verbose??!1,this.observe=e.observe??!0,this.connectors=[],this.disallowedTools=[],this.additionalTools=[],this.useServerManager=!1,this.adapter=new kt,this.telemetry=to.getInstance(),this.modelProvider="remote",this.modelName="remote-agent",this.observabilityManager=new Xs({customCallbacks:e.callbacks,agentId:e.agentId}),this.callbacks=[];return}if(!e.llm)throw new Error("llm is required for local execution. For remote execution, provide agentId instead.");if(this.llm=e.llm,this.client=e.client,this.connectors=e.connectors??[],this.maxSteps=e.maxSteps??5,this.autoInitialize=e.autoInitialize??!1,this.memoryEnabled=e.memoryEnabled??!0,this.systemPrompt=e.systemPrompt??null,this.systemPromptTemplateOverride=e.systemPromptTemplate??null,this.additionalInstructions=e.additionalInstructions??null,this.disallowedTools=e.disallowedTools??[],this.additionalTools=e.additionalTools??[],this.useServerManager=e.useServerManager??!1,this.verbose=e.verbose??!1,this.observe=e.observe??!0,!this.client&&this.connectors.length===0)throw new Error("Either 'client' or at least one 'connector' must be provided.");if(this.useServerManager){if(!this.client)throw new Error("'client' must be provided when 'useServerManager' is true.");this.adapter=e.adapter??new kt(this.disallowedTools),this.serverManager=e.serverManagerFactory?.(this.client)??new L0(this.client,this.adapter)}else this.adapter=e.adapter??new kt(this.disallowedTools);if(this.telemetry=to.getInstance(),this.llm){const[t,r]=Jd(this.llm);this.modelProvider=t,this.modelName=r}else this.modelProvider="unknown",this.modelName="unknown";this.observabilityManager=new Xs({customCallbacks:e.callbacks,verbose:this.verbose,observe:this.observe,agentId:e.agentId,metadataProvider:le(()=>this.getMetadata(),"metadataProvider"),tagsProvider:le(()=>this.getTags(),"tagsProvider")}),Object.defineProperty(this,"agentExecutor",{get:le(()=>this._agentExecutor,"get"),configurable:!0}),Object.defineProperty(this,"tools",{get:le(()=>this._tools,"get"),configurable:!0}),Object.defineProperty(this,"initialized",{get:le(()=>this._initialized,"get"),configurable:!0})}async initialize(){if(this.isRemote){this._initialized=!0;return}A.info("🚀 Initializing MCP agent and connecting to services..."),this.callbacks=await this.observabilityManager.getCallbacks();const e=await this.observabilityManager.getHandlerNames();if(e.length>0&&A.info(`📊 Observability enabled with: ${e.join(", ")}`),this.useServerManager&&this.serverManager){await this.serverManager.initialize();const r=this.serverManager.tools;this._tools=r,this._tools.push(...this.additionalTools),A.info(`🔧 Server manager mode active with ${r.length} management tools`),await this.createSystemMessageFromTools(this._tools)}else{if(this.client)this.sessions=this.client.getAllActiveSessions(),A.info(`🔌 Found ${Object.keys(this.sessions).length} existing sessions`),Object.keys(this.sessions).length===0&&(A.info("🔄 No active sessions found, creating new ones..."),this.sessions=await this.client.createAllSessions(),A.info(`✅ Created ${Object.keys(this.sessions).length} new sessions`)),this._tools=await kt.createTools(this.client),this._tools.push(...this.additionalTools),A.info(`🛠️ Created ${this._tools.length} LangChain tools from client`);else{A.info(`🔗 Connecting to ${this.connectors.length} direct connectors...`);for(const r of this.connectors)r.isClientConnected||await r.connect();this._tools=await this.adapter.createToolsFromConnectors(this.connectors),this._tools.push(...this.additionalTools),A.info(`🛠️ Created ${this._tools.length} LangChain tools from connectors`)}A.info(`🧰 Found ${this._tools.length} tools across all connectors`),await this.createSystemMessageFromTools(this._tools)}this._agentExecutor=this.createAgent(),this._initialized=!0;const t=this.getMCPServerInfo();Object.keys(t).length>0&&(this.setMetadata(t),A.debug(`MCP server info added to metadata: ${JSON.stringify(t)}`)),A.info("✨ Agent initialization complete")}async createSystemMessageFromTools(e){const t=this.systemPromptTemplateOverride??H0;this.systemMessage=Zd(e,t,G0,this.useServerManager,this.disallowedTools,this.systemPrompt??void 0,this.additionalInstructions??void 0),this.memoryEnabled&&(this.conversationHistory=[this.systemMessage,...this.conversationHistory.filter(r=>!(r instanceof yt))])}createAgent(){if(!this.llm)throw new Error("LLM is required to create agent");const e=this.systemMessage?.content??"You are a helpful assistant.",t=Yr.fromMessages([["system",e],new Ei("chat_history"),["human","{input}"],new Ei("agent_scratchpad")]),r=T0({llm:this.llm,tools:this._tools,prompt:t});return new jo({agent:r,tools:this._tools,maxIterations:this.maxSteps,verbose:this.verbose,returnIntermediateSteps:!0,callbacks:this.callbacks})}getConversationHistory(){return[...this.conversationHistory]}clearConversationHistory(){this.conversationHistory=this.memoryEnabled&&this.systemMessage?[this.systemMessage]:[]}addToHistory(e){this.memoryEnabled&&this.conversationHistory.push(e)}getSystemMessage(){return this.systemMessage}setSystemMessage(e){this.systemMessage=new yt(e),this.memoryEnabled&&(this.conversationHistory=this.conversationHistory.filter(t=>!(t instanceof yt)),this.conversationHistory.unshift(this.systemMessage)),this._initialized&&this._tools.length&&(this._agentExecutor=this.createAgent(),A.debug("Agent recreated with new system message"))}setDisallowedTools(e){this.disallowedTools=e,this.adapter=new kt(this.disallowedTools),this._initialized&&A.debug("Agent already initialized. Changes will take effect on next initialization.")}getDisallowedTools(){return this.disallowedTools}setMetadata(e){const t=this.sanitizeMetadata(e);this.metadata={...this.metadata,...t},A.debug(`Metadata set: ${JSON.stringify(this.metadata)}`)}getMetadata(){return{...this.metadata}}setTags(e){const t=this.sanitizeTags(e);this.tags=[...new Set([...this.tags,...t])],A.debug(`Tags set: ${JSON.stringify(this.tags)}`)}getTags(){return[...this.tags]}sanitizeMetadata(e){const t={};for(const[r,i]of Object.entries(e)){if(typeof r!="string"||r.length===0){A.warn(`Invalid metadata key: ${r}. Skipping.`);continue}const a=r.replace(/[^\w-]/g,"_");if(i==null)t[a]=i;else if(typeof i=="string"||typeof i=="number"||typeof i=="boolean")t[a]=i;else if(Array.isArray(i)){const s=i.filter(o=>typeof o=="string"||typeof o=="number"||typeof o=="boolean");s.length>0&&(t[a]=s)}else if(typeof i=="object")try{const s=JSON.stringify(i);s.length>1e3?(A.warn(`Metadata value for key '${a}' is too large. Truncating.`),t[a]=`${s.substring(0,1e3)}...`):t[a]=i}catch(s){A.warn(`Failed to serialize metadata value for key '${a}': ${s}. Skipping.`)}else A.warn(`Unsupported metadata value type for key '${a}': ${typeof i}. Skipping.`)}return t}sanitizeTags(e){return e.filter(t=>typeof t=="string"&&t.length>0).map(t=>t.replace(/[^\w:-]/g,"_")).filter(t=>t.length<=50)}getMCPServerInfo(){const e={};try{if(this.client){const t=this.client.getServerNames();e.mcp_servers_count=t.length,e.mcp_server_names=t;const r={};for(const i of t)try{const a=this.client.getServerConfig(i);if(a){let s="unknown";a.command?s="command":a.url?s="http":a.ws_url&&(s="websocket"),r[i]={type:s,has_args:!!a.args,has_env:!!a.env,has_headers:!!a.headers,url:a.url||null,command:a.command||null}}}catch(a){A.warn(`Failed to get config for server '${i}': ${a}`),r[i]={type:"error",error:"config_unavailable"}}e.mcp_server_configs=r}else this.connectors&&this.connectors.length>0&&(e.mcp_servers_count=this.connectors.length,e.mcp_server_names=this.connectors.map(t=>t.publicIdentifier),e.mcp_server_types=this.connectors.map(t=>t.constructor.name))}catch(t){A.warn(`Failed to collect MCP server info: ${t}`),e.error="collection_failed"}return e}async _consumeAndReturn(e){for(;;){const{done:t,value:r}=await e.next();if(t)return r}}async run(e,t,r,i,a){if(this.isRemote&&this.remoteAgent)return this.remoteAgent.run(e,t,r,i,a);const s=this.stream(e,t,r,i,a);return this._consumeAndReturn(s)}async*stream(e,t,r=!0,i,a){if(this.isRemote&&this.remoteAgent)return await this.remoteAgent.run(e,t,r,i,a);let s="",o=!1;const u=Date.now(),l=[];let c=0;const h=!1,f={value:h};let _=null,p="";if(a){if(e=this._enhanceQueryWithSchema(e,a),A.debug(`🔄 Structured output requested, schema: ${JSON.stringify(Nt(a),null,2)}`),this.llm&&"withStructuredOutput"in this.llm&&typeof this.llm.withStructuredOutput=="function")_=this.llm.withStructuredOutput(a);else if(this.llm)_=this.llm;else throw new Error("LLM is required for structured output");p=JSON.stringify(Nt(a),null,2)}try{if(r&&!this._initialized?(await this.initialize(),o=!0):!this._initialized&&this.autoInitialize&&(await this.initialize(),o=!0),!this._agentExecutor)throw new Error("MCP agent failed to initialize");const b=t??this.maxSteps;this._agentExecutor.maxIterations=b;const w=e.length>50?`${e.slice(0,50).replace(/\n/g," ")}...`:e.replace(/\n/g," ");A.info(`💬 Received query: '${w}'`),this.memoryEnabled&&this.addToHistory(new Xe(e));const m=i??this.conversationHistory,g=[];for(const R of m)(R instanceof Xe||R instanceof ot)&&g.push(R);const v=[],E={input:e,chat_history:g};let O=Object.fromEntries(this._tools.map(R=>[R.name,R]));A.info(`🏁 Starting agent execution with max_steps=${b}`);let C;this.callbacks?.length>0&&(C=await new Fe(void 0,{handlers:this.callbacks,inheritableHandlers:this.callbacks}).handleChainStart({name:"MCPAgent (mcp-use)",id:["MCPAgent (mcp-use)"],lc:1,type:"not_implemented"},E));for(let R=0;R<b;R++){if(c=R+1,this.useServerManager&&this.serverManager){const I=this.serverManager.tools,$=new Set(I.map(B=>B.name)),M=new Set(this._tools.map(B=>B.name));(I.length!==this._tools.length||[...$].some(B=>!M.has(B)))&&(A.info(`🔄 Tools changed before step ${R+1}, updating agent. New tools: ${[...$].join(", ")}`),this._tools=I,this._tools.push(...this.additionalTools),await this.createSystemMessageFromTools(this._tools),this._agentExecutor=this.createAgent(),this._agentExecutor.maxIterations=b,O=Object.fromEntries(this._tools.map(B=>[B.name,B])))}A.info(`👣 Step ${R+1}/${b}`);try{A.debug("Starting agent step execution");const I=await this._agentExecutor._takeNextStep(O,E,v,C);if("returnValues"in I&&(A.info(`✅ Agent finished at step ${R+1}`),s=I.returnValues?.output??"No output generated",C?.handleChainEnd({output:s}),a&&_)){A.info("🔧 Attempting structured output...");const $=s;this._attemptStructuredOutput($,this.llm,a).then(M=>(this.memoryEnabled&&this.addToHistory(new ot(`Structured result: ${JSON.stringify(M)}`)),A.info("✅ Structured output successful"),f.value=!0,M)).catch(M=>{A.warn(`⚠️ Structured output failed: ${M}`);const z=`
|
|
198
|
+
The current result cannot be formatted into the required structure.
|
|
199
|
+
Error: ${String(M)}
|
|
200
|
+
|
|
201
|
+
Current information: ${$}
|
|
202
|
+
|
|
203
|
+
If information is missing, please continue working to gather the missing information needed for:
|
|
204
|
+
${p}
|
|
205
|
+
|
|
206
|
+
If the information is complete, please return the result in the required structure.
|
|
207
|
+
`;E.input=z,this.memoryEnabled&&this.addToHistory(new Xe(z)),A.info("🔄 Continuing execution to gather missing information...")})}if(Array.isArray(I)){const $=I;v.push(...$);for(const M of $){yield M;const{action:z,observation:B}=M,F=z.tool;l.push(F);let Y=typeof z.toolInput=="string"?z.toolInput:JSON.stringify(z.toolInput,null,2);Y.length>100&&(Y=`${Y.slice(0,97)}...`),A.info(`🔧 Tool call: ${F} with input: ${Y}`);let Z=String(B);Z.length>100&&(Z=`${Z.slice(0,97)}...`),Z=Z.replace(/\n/g," "),A.info(`📄 Tool result: ${Z}`)}if($.length){const M=$[$.length-1],z=await this._agentExecutor._getToolReturn(M);if(z){A.info(`🏆 Tool returned directly at step ${R+1}`),s=z.returnValues?.output??"No output generated";break}}}}catch(I){if(I instanceof Si){A.error(`❌ Output parsing error during step ${R+1}: ${I}`),s=`Agent stopped due to a parsing error: ${I}`,C?.handleChainError(s);break}A.error(`❌ Error during agent execution step ${R+1}: ${I}`),console.error(I),s=`Agent stopped due to an error: ${I}`,C?.handleChainError(s);break}}return s||(A.warn(`⚠️ Agent stopped after reaching max iterations (${b})`),s=`Agent stopped after reaching the maximum number of steps (${b}).`,C?.handleChainEnd({output:s})),A.info("🎉 Agent execution complete"),f.value=!0,s}catch(b){throw A.error(`❌ Error running query: ${b}`),o&&r&&(A.info("🧹 Cleaning up resources after initialization error in run"),await this.close()),b}finally{const b=Date.now()-u;let w=0;this.client?w=Object.keys(this.client.getAllActiveSessions()).length:this.connectors&&(w=this.connectors.length);const m=this.memoryEnabled?this.conversationHistory.length:0;await this.telemetry.trackAgentExecution({executionMethod:"stream",query:e,success:h,modelProvider:this.modelProvider,modelName:this.modelName,serverCount:w,serverIdentifiers:this.connectors.map(g=>g.publicIdentifier),totalToolsAvailable:this._tools.length,toolsAvailableNames:this._tools.map(g=>g.name),maxStepsConfigured:this.maxSteps,memoryEnabled:this.memoryEnabled,useServerManager:this.useServerManager,maxStepsUsed:t??null,manageConnector:r,externalHistoryUsed:i!==void 0,stepsTaken:c,toolsUsedCount:l.length,toolsUsedNames:l,response:s,executionTimeMs:b,errorType:"execution_error",conversationHistoryLength:m}),r&&!this.client&&o&&(A.info("🧹 Closing agent after query completion"),await this.close())}}async close(){if(this.isRemote&&this.remoteAgent){await this.remoteAgent.close();return}A.info("🔌 Closing MCPAgent resources…"),await this.observabilityManager.shutdown();try{if(this._agentExecutor=null,this._tools=[],this.client)A.info("🔄 Closing sessions through client"),await this.client.closeAllSessions(),this.sessions={};else for(const e of this.connectors)A.info("🔄 Disconnecting connector"),await e.disconnect();"connectorToolMap"in this.adapter&&(this.adapter=new kt)}finally{this._initialized=!1,A.info("👋 Agent closed successfully")}}async*streamEvents(e,t,r=!0,i,a){let s=!1;const o=Date.now();let u=!1,l=0,c=0,h="";a&&(e=this._enhanceQueryWithSchema(e,a));try{r&&!this._initialized?(await this.initialize(),s=!0):!this._initialized&&this.autoInitialize&&(await this.initialize(),s=!0);const f=this.agentExecutor;if(!f)throw new Error("MCP agent failed to initialize");const _=t??this.maxSteps;f.maxIterations=_;const p=e.length>50?`${e.slice(0,50).replace(/\n/g," ")}...`:e.replace(/\n/g," ");A.info(`💬 Received query for streamEvents: '${p}'`),this.memoryEnabled&&(A.info(`🔄 Adding user message to history: ${e}`),this.addToHistory(new Xe(e)));const b=i??this.conversationHistory,w=[];for(const v of b)v instanceof Xe||v instanceof ot||v instanceof wr?w.push(v):A.info(`⚠️ Skipped message of type: ${v.constructor.name}`);const m={input:e,chat_history:w};A.info("callbacks",this.callbacks);const g=f.streamEvents(m,{version:"v2",callbacks:this.callbacks.length>0?this.callbacks:void 0});for await(const v of g)if(l++,!(!v||typeof v!="object")&&(v.event==="on_chat_model_stream"&&v.data?.chunk?.content&&(c+=v.data.chunk.content.length),yield v,v.event==="on_chain_end"&&v.data?.output)){const E=v.data.output;Array.isArray(E)&&E.length>0&&E[0]?.text?h=E[0].text:typeof E=="string"?h=E:E&&typeof E=="object"&&"output"in E&&(h=E.output)}if(a&&h){A.info("🔧 Attempting structured output conversion...");try{let v=!1,E=null,O=null;const C=this._attemptStructuredOutput(h,this.llm,a).then(I=>(v=!0,E=I,I)).catch(I=>{throw v=!0,O=I,I});let R=0;for(;!v;)await new Promise(I=>setTimeout(I,2e3)),v||(R++,yield{event:"on_structured_output_progress",data:{message:`Converting to structured output... (${R*2}s)`,elapsed:R*2}});if(O)throw O;E&&(yield{event:"on_structured_output",data:{output:E}},this.memoryEnabled&&this.addToHistory(new ot(`Structured result: ${JSON.stringify(E)}`)),A.info("✅ Structured output successful"))}catch(v){A.warn(`⚠️ Structured output failed: ${v}`),yield{event:"on_structured_output_error",data:{error:v instanceof Error?v.message:String(v)}}}}else this.memoryEnabled&&h&&this.addToHistory(new ot(h));A.info(`🎉 StreamEvents complete - ${l} events emitted`),u=!0}catch(f){throw A.error(`❌ Error during streamEvents: ${f}`),s&&r&&(A.info("🧹 Cleaning up resources after initialization error in streamEvents"),await this.close()),f}finally{const f=Date.now()-o;let _=0;this.client?_=Object.keys(this.client.getAllActiveSessions()).length:this.connectors&&(_=this.connectors.length);const p=this.memoryEnabled?this.conversationHistory.length:0;await this.telemetry.trackAgentExecution({executionMethod:"streamEvents",query:e,success:u,modelProvider:this.modelProvider,modelName:this.modelName,serverCount:_,serverIdentifiers:this.connectors.map(b=>b.publicIdentifier),totalToolsAvailable:this._tools.length,toolsAvailableNames:this._tools.map(b=>b.name),maxStepsConfigured:this.maxSteps,memoryEnabled:this.memoryEnabled,useServerManager:this.useServerManager,maxStepsUsed:t??null,manageConnector:r,externalHistoryUsed:i!==void 0,response:`[STREAMED RESPONSE - ${c} chars]`,executionTimeMs:f,errorType:u?null:"streaming_error",conversationHistoryLength:p}),r&&!this.client&&s&&(A.info("🧹 Closing agent after streamEvents completion"),await this.close())}}async _attemptStructuredOutput(e,t,r){A.info(`🔄 Attempting structured output with schema: ${r}`),A.info(`🔄 Raw result: ${JSON.stringify(e,null,2)}`);let i=null,a="";if(A.debug(`🔄 Structured output requested, schema: ${JSON.stringify(Nt(r),null,2)}`),t&&"withStructuredOutput"in t&&typeof t.withStructuredOutput=="function")i=t.withStructuredOutput(r);else if(t)i=t;else throw new Error("LLM is required for structured output");a=JSON.stringify(Nt(r),null,2),A.info(`🔄 Schema description: ${a}`);let s="";typeof e=="string"?s=e:e&&typeof e=="object"&&(s=JSON.stringify(e)),s||(s=JSON.stringify(e));const o=3;let u="";for(let l=1;l<=o;l++){A.info(`🔄 Structured output attempt ${l}/${o}`);let c=`
|
|
208
|
+
Please format the following information according to the EXACT schema specified below.
|
|
209
|
+
You must use the exact field names and types as shown in the schema.
|
|
210
|
+
|
|
211
|
+
Required schema format:
|
|
212
|
+
${a}
|
|
213
|
+
|
|
214
|
+
Content to extract from:
|
|
215
|
+
${s}
|
|
216
|
+
|
|
217
|
+
IMPORTANT:
|
|
218
|
+
- Use ONLY the field names specified in the schema
|
|
219
|
+
- Match the data types exactly (string, number, boolean, array, etc.)
|
|
220
|
+
- Include ALL required fields
|
|
221
|
+
- Return valid JSON that matches the schema structure exactly
|
|
222
|
+
`;l>1&&(c+=`
|
|
223
|
+
|
|
224
|
+
PREVIOUS ATTEMPT FAILED with error: ${u}
|
|
225
|
+
Please fix the issues mentioned above and ensure the output matches the schema exactly.
|
|
226
|
+
`);try{A.info(`🔄 Structured output attempt ${l} - using streaming approach`);const h=await i.stream(c);let f=null,_=0;for await(const b of h){if(_++,A.info(`Chunk ${_}: ${JSON.stringify(b,null,2)}`),typeof b=="string")try{f=JSON.parse(b)}catch{A.warn(`🔄 Failed to parse string chunk as JSON: ${b}`)}else if(b&&typeof b=="object")f=b;else try{f=JSON.parse(String(b))}catch{A.warn(`🔄 Failed to parse chunk as JSON: ${b}`)}_%10===0&&A.info(`🔄 Structured output streaming: ${_} chunks`)}if(A.info(`🔄 Structured result attempt ${l}: ${JSON.stringify(f,null,2)}`),!f)throw new Error("No structured result received from stream");const p=this._validateStructuredResult(f,r);return A.info(`✅ Structured output successful on attempt ${l}`),p}catch(h){if(u=h instanceof Error?h.message:String(h),A.warn(`⚠️ Structured output attempt ${l} failed: ${u}`),l===o)throw A.error(`❌ All ${o} structured output attempts failed`),new Error(`Failed to generate valid structured output after ${o} attempts. Last error: ${u}`);continue}}throw new Error("Unexpected error in structured output generation")}_validateStructuredResult(e,t){try{const r=t.parse(e),i=t;if(i._def&&i._def.shape)for(const[a,s]of Object.entries(i._def.shape)){const o=s,u=o.isOptional?.()??o._def?.typeName==="ZodOptional",l=o.isNullable?.()??o._def?.typeName==="ZodNullable";if(!u&&!l){const c=r[a];if(c==null||typeof c=="string"&&!c.trim()||Array.isArray(c)&&c.length===0)throw new Error(`Required field '${a}' is missing or empty`)}}return r}catch(r){throw A.debug(`Validation details: ${r}`),r}}_enhanceQueryWithSchema(e,t){try{const r=JSON.stringify(Nt(t),null,2);return`
|
|
227
|
+
${e}
|
|
228
|
+
|
|
229
|
+
IMPORTANT: Your response must include sufficient information to populate the following structured output:
|
|
230
|
+
|
|
231
|
+
${r}
|
|
232
|
+
|
|
233
|
+
Make sure you gather ALL the required information during your task execution.
|
|
234
|
+
If any required information is missing, continue working to find it.
|
|
235
|
+
`}catch(r){return A.warn(`Could not extract schema details: ${r}`),e}}},le(cr,"MCPAgent"),cr),fr,Xd=(fr=class{connector;autoConnect;constructor(e,t=!0){this.connector=e,this.autoConnect=t}async connect(){await this.connector.connect()}async disconnect(){await this.connector.disconnect()}async initialize(){!this.isConnected&&this.autoConnect&&await this.connect(),await this.connector.initialize()}get isConnected(){return this.connector&&this.connector.isClientConnected}},le(fr,"MCPSession"),fr),dr,Mo=(dr=class{client=null;connectionManager=null;toolsCache=null;connected=!1;opts;constructor(e={}){this.opts=e}async disconnect(){if(!this.connected){A.debug("Not connected to MCP implementation");return}A.debug("Disconnecting from MCP implementation"),await this.cleanupResources(),this.connected=!1,A.debug("Disconnected from MCP implementation")}get isClientConnected(){return this.client!=null}async initialize(e=this.opts.defaultRequestOptions??{}){if(!this.client)throw new Error("MCP client is not connected");A.debug("Caching server capabilities & tools");const t=this.client.getServerCapabilities(),r=await this.client.listTools(void 0,e);return this.toolsCache=r.tools??[],A.debug(`Fetched ${this.toolsCache.length} tools from server`),t}get tools(){if(!this.toolsCache)throw new Error("MCP client is not initialized; call initialize() first");return this.toolsCache}async callTool(e,t,r){if(!this.client)throw new Error("MCP client is not connected");A.debug(`Calling tool '${e}' with args`,t);const i=await this.client.callTool({name:e,arguments:t},void 0,r);return A.debug(`Tool '${e}' returned`,i),i}async listResources(e,t){if(!this.client)throw new Error("MCP client is not connected");return A.debug("Listing resources",e?`with cursor: ${e}`:""),await this.client.listResources({cursor:e},t)}async listAllResources(e){if(!this.client)throw new Error("MCP client is not connected");A.debug("Listing all resources (with auto-pagination)");const t=[];let r;do{const i=await this.client.listResources({cursor:r},e);t.push(...i.resources||[]),r=i.nextCursor}while(r);return{resources:t}}async listResourceTemplates(e){if(!this.client)throw new Error("MCP client is not connected");return A.debug("Listing resource templates"),await this.client.listResourceTemplates(void 0,e)}async readResource(e,t){if(!this.client)throw new Error("MCP client is not connected");A.debug(`Reading resource ${e}`);const r=await this.client.readResource({uri:e},t);return{content:r.content,mimeType:r.mimeType}}async subscribeToResource(e,t){if(!this.client)throw new Error("MCP client is not connected");return A.debug(`Subscribing to resource: ${e}`),await this.client.subscribeResource({uri:e},t)}async unsubscribeFromResource(e,t){if(!this.client)throw new Error("MCP client is not connected");return A.debug(`Unsubscribing from resource: ${e}`),await this.client.unsubscribeResource({uri:e},t)}async listPrompts(){if(!this.client)throw new Error("MCP client is not connected");return A.debug("Listing prompt"),await this.client.listPrompts()}async getPrompt(e,t){if(!this.client)throw new Error("MCP client is not connected");return A.debug(`Getting prompt ${e}`),await this.client.getPrompt({name:e,arguments:t})}async request(e,t=null,r){if(!this.client)throw new Error("MCP client is not connected");return A.debug(`Sending raw request '${e}' with params`,t),await this.client.request({method:e,params:t??{}},void 0,r)}async cleanupResources(){const e=[];if(this.client)try{typeof this.client.close=="function"&&await this.client.close()}catch(t){const r=`Error closing client: ${t}`;A.warn(r),e.push(r)}finally{this.client=null}if(this.connectionManager)try{await this.connectionManager.stop()}catch(t){const r=`Error stopping connection manager: ${t}`;A.warn(r),e.push(r)}finally{this.connectionManager=null}this.toolsCache=null,e.length&&A.warn(`Resource cleanup finished with ${e.length} issue(s)`)}},le(dr,"BaseConnector"),dr),hr,ko=(hr=class{_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),A.debug(`Starting ${this.constructor.name}`),this._task=this.connectionTask(),await this._readyPromise,this._exception)throw this._exception;if(this._connection===null)throw new Error("Connection was not established");return this._connection}async stop(){if(this._task&&this._abortController){A.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(e){e instanceof Error&&e.name==="AbortError"?A.debug(`${this.constructor.name} task aborted successfully`):A.warn(`Error stopping ${this.constructor.name} task: ${e}`)}}await this._donePromise,A.debug(`${this.constructor.name} task completed`)}reset(){this._readyPromise=new Promise(e=>this._readyResolver=e),this._donePromise=new Promise(e=>this._doneResolver=e),this._exception=null,this._connection=null,this._task=null,this._abortController=new AbortController}async connectionTask(){A.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),A.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(e){this._exception=e,A.error(`Error in ${this.constructor.name} task: ${e}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(e){A.warn(`Error closing connection in ${this.constructor.name}: ${e}`)}this._connection=null}this._doneResolver()}}async waitForAbort(){return new Promise((e,t)=>{if(!this._abortController)return;const r=this._abortController.signal;if(r.aborted){e();return}const i=le(()=>{r.removeEventListener("abort",i),e()},"onAbort");r.addEventListener("abort",i)})}},le(hr,"ConnectionManager"),hr),pr,W0=(pr=class extends ko{url;opts;_transport=null;constructor(e,t){super(),this.url=typeof e=="string"?new URL(e):e,this.opts=t}async establishConnection(){return this._transport=new hh(this.url,this.opts),A.debug(`${this.constructor.name} connected successfully`),this._transport}async closeConnection(e){if(this._transport)try{await this._transport.close()}catch(t){A.warn(`Error closing SSE transport: ${t}`)}finally{this._transport=null}}},le(pr,"SseConnectionManager"),pr),mr,J0=(mr=class extends ko{url;opts;_transport=null;constructor(e,t){super(),this.url=typeof e=="string"?new URL(e):e,this.opts=t}async establishConnection(){return this._transport=new dh(this.url,this.opts),A.debug(`${this.constructor.name} created successfully`),this._transport}async closeConnection(e){if(this._transport)try{await this._transport.close()}catch(t){A.warn(`Error closing Streamable HTTP transport: ${t}`)}finally{this._transport=null}}get sessionId(){return this._transport?.sessionId}},le(mr,"StreamableHttpConnectionManager"),mr),gr,ro=(gr=class extends Mo{baseUrl;headers;timeout;sseReadTimeout;clientInfo;preferSse;transportType=null;constructor(e,t={}){super(t),this.baseUrl=e.replace(/\/$/,""),this.headers={...t.headers??{}},t.authToken&&(this.headers.Authorization=`Bearer ${t.authToken}`),this.timeout=t.timeout??3e4,this.sseReadTimeout=t.sseReadTimeout??3e5,this.clientInfo=t.clientInfo??{name:"http-connector",version:"1.0.0"},this.preferSse=t.preferSse??!1}async connect(){if(this.connected){A.debug("Already connected to MCP implementation");return}const e=this.baseUrl;if(this.preferSse){A.debug(`Connecting to MCP implementation via HTTP/SSE: ${e}`),await this.connectWithSse(e);return}A.debug(`Connecting to MCP implementation via HTTP: ${e}`);try{A.info("🔄 Attempting streamable HTTP transport..."),await this.connectWithStreamableHttp(e),A.info("✅ Successfully connected via streamable HTTP")}catch(t){let r="Unknown error";if(t instanceof fh)t.code===400&&t.message.includes("Missing session ID")?(r="Server requires session ID (FastMCP compatibility) - using SSE transport",A.warn(`⚠️ ${r}`)):t.code===404||t.code===405?(r=`Server returned ${t.code} - server likely doesn't support streamable HTTP`,A.debug(r)):(r=`Server returned ${t.code}: ${t.message}`,A.debug(r));else if(t instanceof Error){const i=t.toString(),a=t.message||"";i.includes("Missing session ID")||i.includes("Bad Request: Missing session ID")||a.includes("FastMCP session ID error")?(r="Server requires session ID (FastMCP compatibility) - using SSE transport",A.warn(`⚠️ ${r}`)):i.includes("405 Method Not Allowed")||i.includes("404 Not Found")?(r="Server doesn't support streamable HTTP (405/404)",A.debug(r)):(r=`Streamable HTTP failed: ${t.message}`,A.debug(r))}A.info("🔄 Falling back to SSE transport...");try{await this.connectWithSse(e)}catch(i){throw A.error("Failed to connect with both transports:"),A.error(` Streamable HTTP: ${r}`),A.error(` SSE: ${i}`),await this.cleanupResources(),new Error("Could not connect to server with any available transport")}}}async connectWithStreamableHttp(e){try{this.connectionManager=new J0(e,{requestInit:{headers:this.headers},reconnectionOptions:{maxReconnectionDelay:3e4,initialReconnectionDelay:1e3,reconnectionDelayGrowFactor:1.5,maxRetries:2}});const t=await this.connectionManager.start();this.client=new No(this.clientInfo,this.opts.clientOptions);try{await this.client.connect(t)}catch(r){if(r instanceof Error){const i=r.message||r.toString();if(i.includes("Missing session ID")||i.includes("Bad Request: Missing session ID")){const a=new Error(`FastMCP session ID error: ${i}`);throw a.cause=r,a}}throw r}this.connected=!0,this.transportType="streamable-http",A.debug(`Successfully connected to MCP implementation via streamable HTTP: ${e}`)}catch(t){throw await this.cleanupResources(),t}}async connectWithSse(e){try{this.connectionManager=new W0(e,{requestInit:{headers:this.headers}});const t=await this.connectionManager.start();this.client=new No(this.clientInfo,this.opts.clientOptions),await this.client.connect(t),this.connected=!0,this.transportType="sse",A.debug(`Successfully connected to MCP implementation via HTTP/SSE: ${e}`)}catch(t){throw await this.cleanupResources(),t}}get publicIdentifier(){return{type:"http",url:this.baseUrl,transport:this.transportType||"unknown"}}getTransportType(){return this.transportType}},le(gr,"HttpConnector"),gr),yr,K0=(yr=class extends ko{url;headers;_ws=null;constructor(e,t={}){super(),this.url=e,this.headers=t}async establishConnection(){return A.debug(`Connecting to WebSocket: ${this.url}`),new Promise((e,t)=>{const r=new of(this.url,{headers:this.headers});this._ws=r;const i=le(()=>{s(),A.debug("WebSocket connected successfully"),e(r)},"onOpen"),a=le(o=>{s(),A.error(`Failed to connect to WebSocket: ${o}`),t(o)},"onError"),s=le(()=>{r.off("open",i),r.off("error",a)},"cleanup");r.on("open",i),r.on("error",a)})}async closeConnection(e){return A.debug("Closing WebSocket connection"),new Promise(t=>{const r=le(()=>{e.off("close",r),this._ws=null,t()},"onClose");if(e.readyState===of.CLOSED){r();return}e.on("close",r);try{e.close()}catch(i){A.warn(`Error closing WebSocket connection: ${i}`),r()}})}},le(yr,"WebSocketConnectionManager"),yr),br,eh=(br=class extends Mo{url;headers;connectionManager=null;ws=null;receiverTask=null;pending=new Map;toolsCache=null;constructor(e,t={}){super(),this.url=e,this.headers={...t.headers??{}},t.authToken&&(this.headers.Authorization=`Bearer ${t.authToken}`)}async connect(){if(this.connected){A.debug("Already connected to MCP implementation");return}A.debug(`Connecting via WebSocket: ${this.url}`);try{this.connectionManager=new K0(this.url,this.headers),this.ws=await this.connectionManager.start(),this.receiverTask=this.receiveLoop(),this.connected=!0,A.debug("WebSocket connected successfully")}catch(e){throw A.error(`Failed to connect: ${e}`),await this.cleanupResources(),e}}async disconnect(){if(!this.connected){A.debug("Not connected to MCP implementation");return}A.debug("Disconnecting …"),await this.cleanupResources(),this.connected=!1}sendRequest(e,t=null){if(!this.ws)throw new Error("WebSocket is not connected");const r=cf(),i=JSON.stringify({id:r,method:e,params:t??{}});return new Promise((a,s)=>{this.pending.set(r,{resolve:a,reject:s}),this.ws.send(i,o=>{o&&(this.pending.delete(r),s(o))})})}async receiveLoop(){if(!this.ws)return;const e=this.ws,t=le(r=>{let i;try{i=JSON.parse(r.data??r)}catch(s){A.warn("Received non‑JSON frame",s);return}const a=i.id;if(a&&this.pending.has(a)){const{resolve:s,reject:o}=this.pending.get(a);this.pending.delete(a),"result"in i?s(i.result):"error"in i&&o(i.error)}else A.debug("Received unsolicited message",i)},"onMessage");return e.addEventListener?e.addEventListener("message",t):e.on("message",t),new Promise(r=>{const i=le(()=>{e.removeEventListener?e.removeEventListener("message",t):e.off("message",t),this.rejectAll(new Error("WebSocket closed")),r()},"onClose");e.addEventListener?e.addEventListener("close",i):e.on("close",i)})}rejectAll(e){for(const{reject:t}of this.pending.values())t(e);this.pending.clear()}async initialize(){A.debug("Initializing MCP session over WebSocket");const e=await this.sendRequest("initialize"),t=await this.listTools();return this.toolsCache=t.map(r=>r),A.debug(`Initialized with ${this.toolsCache.length} tools`),e}async listTools(){return(await this.sendRequest("tools/list")).tools??[]}async callTool(e,t){return await this.sendRequest("tools/call",{name:e,arguments:t})}async listResources(){const e=await this.sendRequest("resources/list");return{resources:Array.isArray(e)?e:[]}}async readResource(e){const t=await this.sendRequest("resources/read",{uri:e});return{content:t.content,mimeType:t.mimeType}}async request(e,t=null){return await this.sendRequest(e,t)}get tools(){if(!this.toolsCache)throw new Error("MCP client is not initialized");return this.toolsCache}async cleanupResources(){this.receiverTask&&await this.receiverTask.catch(()=>{}),this.receiverTask=null,this.rejectAll(new Error("WebSocket disconnected")),this.connectionManager&&(await this.connectionManager.stop(),this.connectionManager=null,this.ws=null),this.toolsCache=null}get publicIdentifier(){return{type:"websocket",url:this.url}}},le(br,"WebSocketConnector"),br);async function*th(n){for await(const e of n)if(e.event==="on_chat_model_stream"&&e.data?.chunk?.text){const t=e.data.chunk.text;typeof t=="string"&&t.length>0&&(yield t)}}le(th,"streamEventsToAISDK");function rh(n){return new ReadableStream({async start(e){try{for await(const t of n)e.enqueue(t);e.close()}catch(t){e.error(t)}}})}le(rh,"createReadableStreamFromGenerator");async function*nh(n){for await(const e of n)switch(e.event){case"on_chat_model_stream":if(e.data?.chunk?.text){const t=e.data.chunk.text;typeof t=="string"&&t.length>0&&(yield t)}break;case"on_tool_start":yield`
|
|
236
|
+
🔧 Using tool: ${e.name}
|
|
237
|
+
`;break;case"on_tool_end":yield`
|
|
238
|
+
✅ Tool completed: ${e.name}
|
|
239
|
+
`;break}}le(nh,"streamEventsToAISDKWithTools");var _r,Y0=(_r=class{config={};sessions={};activeSessions=[];constructor(e){e&&(this.config=e)}static fromDict(e){throw new Error("fromDict must be implemented by concrete class")}addServer(e,t){this.config.mcpServers=this.config.mcpServers||{},this.config.mcpServers[e]=t}removeServer(e){this.config.mcpServers?.[e]&&(delete this.config.mcpServers[e],this.activeSessions=this.activeSessions.filter(t=>t!==e))}getServerNames(){return Object.keys(this.config.mcpServers??{})}getServerConfig(e){return this.config.mcpServers?.[e]}getConfig(){return this.config??{}}async createSession(e,t=!0){const r=this.config.mcpServers??{};if(Object.keys(r).length===0&&A.warn("No MCP servers defined in config"),!r[e])throw new Error(`Server '${e}' not found in config`);const i=this.createConnectorFromConfig(r[e]),a=new Xd(i);return t&&await a.initialize(),this.sessions[e]=a,this.activeSessions.includes(e)||this.activeSessions.push(e),a}async createAllSessions(e=!0){const t=this.config.mcpServers??{};Object.keys(t).length===0&&A.warn("No MCP servers defined in config");for(const r of Object.keys(t))await this.createSession(r,e);return this.sessions}getSession(e){const t=this.sessions[e];return t||null}getAllActiveSessions(){return Object.fromEntries(this.activeSessions.map(e=>[e,this.sessions[e]]))}async closeSession(e){const t=this.sessions[e];if(!t){A.warn(`No session exists for server ${e}, nothing to close`);return}try{A.debug(`Closing session for server ${e}`),await t.disconnect()}catch(r){A.error(`Error closing session for server '${e}': ${r}`)}finally{delete this.sessions[e],this.activeSessions=this.activeSessions.filter(r=>r!==e)}}async closeAllSessions(){const e=Object.keys(this.sessions),t=[];for(const r of e)try{A.debug(`Closing session for server ${r}`),await this.closeSession(r)}catch(i){const a=`Failed to close session for server '${r}': ${i}`;A.error(a),t.push(a)}t.length?A.error(`Encountered ${t.length} errors while closing sessions`):A.debug("All sessions closed successfully")}},le(_r,"BaseMCPClient"),_r),Ut,Q0=(Ut=class extends Y0{constructor(e){super(e)}static fromDict(e){return new Ut(e)}createConnectorFromConfig(e){const{url:t,transport:r,headers:i,authToken:a}=e;if(!t)throw new Error("Server URL is required");const s={headers:i,authToken:a};return r==="websocket"||t.startsWith("ws://")||t.startsWith("wss://")?new eh(t,s):r==="http"||t.startsWith("http://")||t.startsWith("https://")?new ro(t,s):new ro(t,s)}},le(Ut,"BrowserMCPClient"),Ut);const uE=Object.freeze(Object.defineProperty({__proto__:null,AIMessage:ot,BaseAdapter:Hd,BaseConnector:Mo,BaseMessage:tt,BrowserOAuthClientProvider:ph,HttpConnector:ro,HumanMessage:Xe,LangChainAdapter:kt,Logger:fi,MCPAgent:V0,MCPClient:Q0,MCPSession:Xd,ObservabilityManager:Xs,RemoteAgent:Kd,SystemMessage:yt,ToolMessage:wr,WebSocketConnector:eh,createReadableStreamFromGenerator:rh,logger:A,onMcpAuthorization:mh,streamEventsToAISDK:th,streamEventsToAISDKWithTools:nh},Symbol.toStringTag,{value:"Module"})),uf=Object.freeze(Object.defineProperty({__proto__:null,initializeLangfuse:mo,langfuseHandler:am,langfuseInitPromise:sm},Symbol.toStringTag,{value:"Module"}));export{ot as A,qs as B,ji as C,Xe as H,Ke as P,Ae as R,yt as S,wr as T,Vb as a,tt as b,Ad as c,mn as d,$i as e,S_ as f,Ro as g,oE as h,Yr as i,b_ as j,Rd as k,uE as l,He as m,Rt as r};
|