@mcp-use/inspector 0.22.0 → 0.22.1

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.
Files changed (221) hide show
  1. package/dist/cdn/inspector.css +1 -1
  2. package/dist/cdn/inspector.js +55997 -65008
  3. package/dist/client/components/MCPAppsDebugControls.d.ts.map +1 -1
  4. package/dist/client/components/MCPAppsRenderer.d.ts +3 -1
  5. package/dist/client/components/MCPAppsRenderer.d.ts.map +1 -1
  6. package/dist/client/components/OpenAIComponentRenderer.d.ts +5 -1
  7. package/dist/client/components/OpenAIComponentRenderer.d.ts.map +1 -1
  8. package/dist/client/components/chat/ToolResultRenderer.d.ts.map +1 -1
  9. package/dist/client/components/tools/ToolResultDisplay.d.ts.map +1 -1
  10. package/dist/client/index.js +665 -587
  11. package/dist/web/assets/{1c-BWzch4JO.js → 1c-CuB6KJny.js} +1 -1
  12. package/dist/web/assets/{abnf-CT_zhnxW.js → abnf-331NRzq6.js} +1 -1
  13. package/dist/web/assets/{accesslog-cShhb8zs.js → accesslog-DPZ1SVBF.js} +1 -1
  14. package/dist/web/assets/{actionscript-Cq_Ed--N.js → actionscript-CuGZR-oV.js} +1 -1
  15. package/dist/web/assets/{ada-uJsdDpQf.js → ada-DRqvTj3B.js} +1 -1
  16. package/dist/web/assets/{angelscript-DrPTtC5L.js → angelscript-CP2_ypHm.js} +1 -1
  17. package/dist/web/assets/{apache-BGLo0lBQ.js → apache-DP5S1Xwo.js} +1 -1
  18. package/dist/web/assets/{applescript-C2ed31F3.js → applescript-CLh7Bl5g.js} +1 -1
  19. package/dist/web/assets/{arcade-wPY44wYa.js → arcade-L7ZIK7Vg.js} +1 -1
  20. package/dist/web/assets/{arduino-Ci84_OQ7.js → arduino-D38C-BRe.js} +1 -1
  21. package/dist/web/assets/{armasm-BT7fDyyc.js → armasm-BL0z-zkV.js} +1 -1
  22. package/dist/web/assets/{asciidoc-hcetSBLZ.js → asciidoc-BwOqzYyI.js} +1 -1
  23. package/dist/web/assets/{aspectj-qP5GW6zg.js → aspectj-CsfF5uHW.js} +1 -1
  24. package/dist/web/assets/{autohotkey-BRTSaEN9.js → autohotkey-BnfF2slP.js} +1 -1
  25. package/dist/web/assets/{autoit-1B-H0U7m.js → autoit-BUNufrnh.js} +1 -1
  26. package/dist/web/assets/{avrasm-D3Ji68Dt.js → avrasm-BUwC6GGa.js} +1 -1
  27. package/dist/web/assets/{awk-pRLtu3M7.js → awk-BAn6DoRI.js} +1 -1
  28. package/dist/web/assets/{axapta-CGXwOjn1.js → axapta-C5EQhsWz.js} +1 -1
  29. package/dist/web/assets/{bash-CL86Bo5U.js → bash-CXJ0QYm_.js} +1 -1
  30. package/dist/web/assets/{basic-713emR8B.js → basic-8InlTbNb.js} +1 -1
  31. package/dist/web/assets/{bnf-D5IR6nw6.js → bnf-zpEK5Wju.js} +1 -1
  32. package/dist/web/assets/{brainfuck-DzHDailX.js → brainfuck-BhgAAx-v.js} +1 -1
  33. package/dist/web/assets/{c-DvWo53J5.js → c-CDPkc2Ya.js} +1 -1
  34. package/dist/web/assets/{c-like-XXh9X4pX.js → c-like-Ds21bDLY.js} +1 -1
  35. package/dist/web/assets/{cal-CGXJawoG.js → cal-DWpElLgG.js} +1 -1
  36. package/dist/web/assets/{capnproto-B-81vtig.js → capnproto-96me6T8-.js} +1 -1
  37. package/dist/web/assets/{ceylon-C9jkMJyl.js → ceylon-Eu9VMqL5.js} +1 -1
  38. package/dist/web/assets/{clean-Bl5mmdRd.js → clean-Bw3NaeUf.js} +1 -1
  39. package/dist/web/assets/{client-DtN-_gPI.js → client-Dqtz8Ili.js} +3 -3
  40. package/dist/web/assets/{clojure-BukU2jlg.js → clojure-CcB35oPu.js} +1 -1
  41. package/dist/web/assets/{clojure-repl-9lcYFe-R.js → clojure-repl-UmCtFENG.js} +1 -1
  42. package/dist/web/assets/{cmake-D6hq-I__.js → cmake-BNsFX7mM.js} +1 -1
  43. package/dist/web/assets/{coffeescript-C_J7DXX1.js → coffeescript-BO-bY-7g.js} +1 -1
  44. package/dist/web/assets/{coq-gXkBAlvJ.js → coq-DxEbCmAp.js} +1 -1
  45. package/dist/web/assets/{core-LI0wjVSm.js → core-Ca6TmLdX.js} +1 -1
  46. package/dist/web/assets/{cos-BTplGz5w.js → cos-D7p4YQ1F.js} +1 -1
  47. package/dist/web/assets/{cpp-CI1760Ho.js → cpp-BfXjKrw-.js} +1 -1
  48. package/dist/web/assets/{crmsh-DH6-DvgY.js → crmsh-Cu_wHzWI.js} +1 -1
  49. package/dist/web/assets/{crystal-hjrHp7Yv.js → crystal-B4ffFRgA.js} +1 -1
  50. package/dist/web/assets/{csharp-CB3yKbly.js → csharp-F3YLadH3.js} +1 -1
  51. package/dist/web/assets/{csp-B00phXpq.js → csp-BLkoFjJ1.js} +1 -1
  52. package/dist/web/assets/{css-StInuocU.js → css-CBlOEu5y.js} +1 -1
  53. package/dist/web/assets/{d-CV5_tWwR.js → d-B8LLg7Ap.js} +1 -1
  54. package/dist/web/assets/{dart-DrmTIzw4.js → dart-Bg7_Weak.js} +1 -1
  55. package/dist/web/assets/{delphi-BcB6hhpr.js → delphi-CUFJtF08.js} +1 -1
  56. package/dist/web/assets/{diff-Pp2W_HQg.js → diff-D6IyExXS.js} +1 -1
  57. package/dist/web/assets/{display-A5IEINAP-CIXsdDM7.js → display-A5IEINAP-CalMK9h7.js} +2 -2
  58. package/dist/web/assets/{django-DET02Zuf.js → django-B-UTY01C.js} +1 -1
  59. package/dist/web/assets/{dns-4f_7PIO9.js → dns-DfGDf7is.js} +1 -1
  60. package/dist/web/assets/{dockerfile-vEZJ0uxd.js → dockerfile-BYeQ3jyi.js} +1 -1
  61. package/dist/web/assets/{dos-BixYFWhs.js → dos-B_5-_6xr.js} +1 -1
  62. package/dist/web/assets/{dsconfig-BnZ9x7Vm.js → dsconfig-uyDAQQAU.js} +1 -1
  63. package/dist/web/assets/{dts-Bcw323rr.js → dts-D75DwEM4.js} +1 -1
  64. package/dist/web/assets/{dust-BiiBiKFU.js → dust-JsNLCukW.js} +1 -1
  65. package/dist/web/assets/{ebnf-I_IglJLf.js → ebnf-BP6c5l4a.js} +1 -1
  66. package/dist/web/assets/{elixir-BJEHSyvP.js → elixir-CUhtoXbR.js} +1 -1
  67. package/dist/web/assets/{elm-cM6RkEze.js → elm-CKMhE8ah.js} +1 -1
  68. package/dist/web/assets/{embeddings-CnYfeC12.js → embeddings-LX6aYruq.js} +1 -1
  69. package/dist/web/assets/{erb-Nv9XiE06.js → erb-CIx8MUO5.js} +1 -1
  70. package/dist/web/assets/{erlang-k6hoIbAZ.js → erlang-CkXPsz4M.js} +1 -1
  71. package/dist/web/assets/{erlang-repl-DV3N7nkq.js → erlang-repl-k7jT--Ou.js} +1 -1
  72. package/dist/web/assets/{excel-Bxh_DxOW.js → excel-C5SkgBGz.js} +1 -1
  73. package/dist/web/assets/{fix-g6kXHsfa.js → fix-_4ZjoSTH.js} +1 -1
  74. package/dist/web/assets/{flix-Cryw522y.js → flix-DnrR-dRx.js} +1 -1
  75. package/dist/web/assets/{fortran-BD0HhvEj.js → fortran-CD6uDQX4.js} +1 -1
  76. package/dist/web/assets/{fsharp-vMayoDV0.js → fsharp-DTtzfUsx.js} +1 -1
  77. package/dist/web/assets/{gams-C1Wn9txH.js → gams-CQk2cq7o.js} +1 -1
  78. package/dist/web/assets/{gauss-DsKIEzQY.js → gauss-CtDmpxAf.js} +1 -1
  79. package/dist/web/assets/{gcode-DU2tUCEF.js → gcode-B_EYK0Vg.js} +1 -1
  80. package/dist/web/assets/{gherkin-DeUH7cEV.js → gherkin-DVcj5Cvn.js} +1 -1
  81. package/dist/web/assets/{glsl-DYiVBLqm.js → glsl-BoRlfwJN.js} +1 -1
  82. package/dist/web/assets/{gml-gas72WV-.js → gml-DwXf4s-K.js} +1 -1
  83. package/dist/web/assets/{go-BcwxmCu3.js → go-jKSz3kk6.js} +1 -1
  84. package/dist/web/assets/{golo-zePT5_Bc.js → golo-Dz5XOjjS.js} +1 -1
  85. package/dist/web/assets/{gradle-1GIWcZRP.js → gradle-CG3C4PH5.js} +1 -1
  86. package/dist/web/assets/{groovy-F95cfGVA.js → groovy-SRcDLXTF.js} +1 -1
  87. package/dist/web/assets/{haml-Csn-F8TT.js → haml-CJsy3-F-.js} +1 -1
  88. package/dist/web/assets/{handlebars-CJUa8Oym.js → handlebars-LN8E0NSL.js} +1 -1
  89. package/dist/web/assets/{haskell-BWMYMGc0.js → haskell-ZP5N77Rb.js} +1 -1
  90. package/dist/web/assets/{haxe-DShjNAaD.js → haxe-S_8gGOoI.js} +1 -1
  91. package/dist/web/assets/{hsp-BYg3woMs.js → hsp-KqF2E7-o.js} +1 -1
  92. package/dist/web/assets/{htmlbars-DESfSS0b.js → htmlbars-Bw_UyB1p.js} +1 -1
  93. package/dist/web/assets/{http-CmDctLNs.js → http-BI5U1FE3.js} +1 -1
  94. package/dist/web/assets/{hy-CL-17rgL.js → hy-BAOLWsZC.js} +1 -1
  95. package/dist/web/assets/index-B53yBrEF.css +1 -0
  96. package/dist/web/assets/{index-B1hmvbOl.js → index-BJOEo8tI.js} +1 -1
  97. package/dist/web/assets/{index-IBr5XNeV.js → index-Bmd2u1yJ.js} +1 -1
  98. package/dist/web/assets/{index-DXXcD1Qg.js → index-ChIi2Veb.js} +1 -1
  99. package/dist/web/assets/{index-BMhVR8vU.js → index-Cz7z8sOR.js} +1 -1
  100. package/dist/web/assets/{index-uEj4g89g.js → index-DUSfaXA6.js} +1 -1
  101. package/dist/web/assets/{index-DEX9beXi.js → index-DtyH_PEF.js} +1 -1
  102. package/dist/web/assets/index-YcAOTRMN.js +2005 -0
  103. package/dist/web/assets/{inform7-DV3NXpQ5.js → inform7-DgEbiTHe.js} +1 -1
  104. package/dist/web/assets/{ini-8iBTslYp.js → ini-VsC63Yhp.js} +1 -1
  105. package/dist/web/assets/{irpf90-OKqjue6L.js → irpf90-BPXrE0Br.js} +1 -1
  106. package/dist/web/assets/{isbl-BIO2oFCV.js → isbl-Dz4HkKrY.js} +1 -1
  107. package/dist/web/assets/{java-BIc--hdi.js → java-C5QDkp3s.js} +1 -1
  108. package/dist/web/assets/{javascript-B7yKBThj.js → javascript-Qw1A7HIi.js} +1 -1
  109. package/dist/web/assets/{jboss-cli-DC-_tFfH.js → jboss-cli-DjxxWoe7.js} +1 -1
  110. package/dist/web/assets/{json-PFyQrwyu.js → json-DwXmVB99.js} +1 -1
  111. package/dist/web/assets/{julia-Dmc9vUNO.js → julia-_UEF-d-n.js} +1 -1
  112. package/dist/web/assets/{julia-repl-B-AGoEfG.js → julia-repl-BmGjKqDN.js} +1 -1
  113. package/dist/web/assets/{kotlin-CSISp0y1.js → kotlin-BGX09JNe.js} +1 -1
  114. package/dist/web/assets/{langfuse-U2OEF7K7-uZdZcMU4.js → langfuse-U2OEF7K7-oUFfuCA2.js} +24 -24
  115. package/dist/web/assets/{lasso-uHxA2qvQ.js → lasso-CMKn1wD1.js} +1 -1
  116. package/dist/web/assets/{latex-Di4WjkOv.js → latex-CSuZLxub.js} +1 -1
  117. package/dist/web/assets/{ldif-Bvwv1mY0.js → ldif-DtYZcb6_.js} +1 -1
  118. package/dist/web/assets/{leaf-ScGR4pgd.js → leaf-Dm7kHn1u.js} +1 -1
  119. package/dist/web/assets/{less-C_yutJld.js → less-BduOo7w1.js} +1 -1
  120. package/dist/web/assets/{lisp-eMkPYcv6.js → lisp-CTN_y443.js} +1 -1
  121. package/dist/web/assets/{livecodeserver-B1TcgaLa.js → livecodeserver-Bt_3a5Le.js} +1 -1
  122. package/dist/web/assets/{livescript-DdG6soNy.js → livescript-fany4WHq.js} +1 -1
  123. package/dist/web/assets/{llms-DfKXFwBa.js → llms-CaZsx5qn.js} +1 -1
  124. package/dist/web/assets/{llvm-BmiTBJX_.js → llvm-BPeNPow9.js} +1 -1
  125. package/dist/web/assets/{lsl-OzzojTdy.js → lsl-CUkRosfV.js} +1 -1
  126. package/dist/web/assets/{lua-CwCsCmNp.js → lua-BYvWg4jg.js} +1 -1
  127. package/dist/web/assets/{makefile-BgYLIf-U.js → makefile-oS53Vg0z.js} +1 -1
  128. package/dist/web/assets/{markdown-fAPd4l7n.js → markdown-D_B0fAXx.js} +1 -1
  129. package/dist/web/assets/{mathematica-BjKA6SaI.js → mathematica-DKe-IuUK.js} +1 -1
  130. package/dist/web/assets/{matlab-BPH3IYVZ.js → matlab-D_21Tl-L.js} +1 -1
  131. package/dist/web/assets/{maxima-CTpKKknl.js → maxima-DUtL1egA.js} +1 -1
  132. package/dist/web/assets/{mel-Bib6Tv-L.js → mel-LAIz87bj.js} +1 -1
  133. package/dist/web/assets/{mercury-CALdU6Ge.js → mercury-zYnf0BJA.js} +1 -1
  134. package/dist/web/assets/{mipsasm-CqdP7SS2.js → mipsasm-By1nFx6c.js} +1 -1
  135. package/dist/web/assets/{mizar-DEE5bHZf.js → mizar-Bzhf-tV1.js} +1 -1
  136. package/dist/web/assets/{mojolicious-hZVHxmhq.js → mojolicious-B8QJxbI8.js} +1 -1
  137. package/dist/web/assets/{monkey-DNdkILnH.js → monkey-Z_CyDrLh.js} +1 -1
  138. package/dist/web/assets/{moonscript-DgK0T-HS.js → moonscript-CoDseIDC.js} +1 -1
  139. package/dist/web/assets/{n1ql-CIlKRRs6.js → n1ql-BEBUEhhE.js} +1 -1
  140. package/dist/web/assets/{nginx-DpOexGSF.js → nginx-BGCHEvnU.js} +1 -1
  141. package/dist/web/assets/{nim-BCPh1ovx.js → nim-Ctrpw--E.js} +1 -1
  142. package/dist/web/assets/{nix-B2-gxrbR.js → nix-Caa5UC27.js} +1 -1
  143. package/dist/web/assets/{node-repl-GjXp6CLP.js → node-repl-sr3s7jQZ.js} +1 -1
  144. package/dist/web/assets/{nsis-O9G0lH29.js → nsis-CzkCLfi2.js} +1 -1
  145. package/dist/web/assets/{objectivec-B3b_RACR.js → objectivec-jvD65_0I.js} +1 -1
  146. package/dist/web/assets/{ocaml-DtfZ5tri.js → ocaml-DhDYdcp2.js} +1 -1
  147. package/dist/web/assets/{openscad-BejXLlQ2.js → openscad-BqnRwGZd.js} +1 -1
  148. package/dist/web/assets/{oxygene-DNd9sLzW.js → oxygene-Cd0jRim3.js} +1 -1
  149. package/dist/web/assets/{parser3-DRtE79m9.js → parser3-BETxqEki.js} +1 -1
  150. package/dist/web/assets/{perl-Dip9KECA.js → perl-knvs0MzJ.js} +1 -1
  151. package/dist/web/assets/{pf-lt9Y1lR8.js → pf-DiXaovgm.js} +1 -1
  152. package/dist/web/assets/{pgsql-BQL9JHoh.js → pgsql-BWEvOXP5.js} +1 -1
  153. package/dist/web/assets/{php-Bi6324i6.js → php-fyvUpIS6.js} +1 -1
  154. package/dist/web/assets/{php-template-Dm96hKrh.js → php-template-Bvb-N_hu.js} +1 -1
  155. package/dist/web/assets/{plaintext-DMCXt4YO.js → plaintext-Dwt8jzyJ.js} +1 -1
  156. package/dist/web/assets/{pony-Bia0W3TW.js → pony-Cfelzwqf.js} +1 -1
  157. package/dist/web/assets/{powershell-xoiy_WI4.js → powershell-2b2YR7rM.js} +1 -1
  158. package/dist/web/assets/{processing-is58fA9K.js → processing-CgyyQkLr.js} +1 -1
  159. package/dist/web/assets/{profile-BOoDppKU.js → profile-CHSonwOR.js} +1 -1
  160. package/dist/web/assets/{prolog-BYxlSk9o.js → prolog-CArpL4nb.js} +1 -1
  161. package/dist/web/assets/{properties-BO1Iq-dJ.js → properties-B7x5j4f3.js} +1 -1
  162. package/dist/web/assets/{protobuf-Srgh7iT4.js → protobuf-DbZMyS9y.js} +1 -1
  163. package/dist/web/assets/{puppet-DWSUFkvp.js → puppet-CyK4RmCj.js} +1 -1
  164. package/dist/web/assets/{purebasic-DxNUDCE4.js → purebasic-Bu9BNLQf.js} +1 -1
  165. package/dist/web/assets/{python-DovuYhDu.js → python-DpcgEz0v.js} +1 -1
  166. package/dist/web/assets/{python-repl-B1OBOSTn.js → python-repl-BAoj7DrU.js} +1 -1
  167. package/dist/web/assets/{q-42rDkXms.js → q-aLpDzBqb.js} +1 -1
  168. package/dist/web/assets/{qml-CBCHfIu7.js → qml-CF8YT9EP.js} +1 -1
  169. package/dist/web/assets/{r-CaE923HL.js → r-DJifPsK_.js} +1 -1
  170. package/dist/web/assets/{reasonml-BYrYCrep.js → reasonml-DYlZCQtf.js} +1 -1
  171. package/dist/web/assets/{rib-Bhv7NbId.js → rib-BWlooZzU.js} +1 -1
  172. package/dist/web/assets/{roboconf-BfZ1K6KL.js → roboconf-B3mKPOxb.js} +1 -1
  173. package/dist/web/assets/{routeros-BXIpVeBP.js → routeros-Ri82AIpo.js} +1 -1
  174. package/dist/web/assets/{rsl-Bjm5MqAG.js → rsl-YFzXeAfb.js} +1 -1
  175. package/dist/web/assets/{ruby-CPet6iCi.js → ruby-CjV_PTlL.js} +1 -1
  176. package/dist/web/assets/{ruleslanguage-DK-1k2MI.js → ruleslanguage-DJCtPhmJ.js} +1 -1
  177. package/dist/web/assets/{rust-9ntsz2kE.js → rust-T_ZZbr83.js} +1 -1
  178. package/dist/web/assets/{sas-91qluzca.js → sas-DnThN-QA.js} +1 -1
  179. package/dist/web/assets/{scala-QAnm6LqO.js → scala-CiCGCGBM.js} +1 -1
  180. package/dist/web/assets/{scheme-CbCu1C1B.js → scheme-C81ecRNU.js} +1 -1
  181. package/dist/web/assets/{scilab-CrQkRgM7.js → scilab-yIe92bs8.js} +1 -1
  182. package/dist/web/assets/{scss-D_KOChRt.js → scss-BGCT6i58.js} +1 -1
  183. package/dist/web/assets/{shell-TLeode3j.js → shell-CtJaW7qj.js} +1 -1
  184. package/dist/web/assets/{smali-DLlQwRbQ.js → smali-D9JxR6Ok.js} +1 -1
  185. package/dist/web/assets/{smalltalk-EAR6TTRw.js → smalltalk-Cc681-eJ.js} +1 -1
  186. package/dist/web/assets/{sml-N2cejLu1.js → sml-CTRWATz0.js} +1 -1
  187. package/dist/web/assets/{sqf-C22NGT13.js → sqf-DSWEsa4V.js} +1 -1
  188. package/dist/web/assets/{sql-CWTNbFDI.js → sql-CDB6g9ay.js} +1 -1
  189. package/dist/web/assets/{sql_more-CnZjQWQO.js → sql_more-CpMC6pU4.js} +1 -1
  190. package/dist/web/assets/{stan-BK8Qdckq.js → stan-BHnXBW_m.js} +1 -1
  191. package/dist/web/assets/{stata-DyqAXFWa.js → stata-84iUAWPp.js} +1 -1
  192. package/dist/web/assets/{stdio-MPKB6J4F-B0j-te4c.js → stdio-ZJFIZK2F-DAa98oll.js} +1 -1
  193. package/dist/web/assets/{step21-DHjUfeMe.js → step21-DDfRrzcc.js} +1 -1
  194. package/dist/web/assets/{stylus-YUPPnLVL.js → stylus-6UGB2DbU.js} +1 -1
  195. package/dist/web/assets/{subunit-B8m1GQqo.js → subunit-CI6BjWYM.js} +1 -1
  196. package/dist/web/assets/{swift-DhFAtG6r.js → swift-gZKjqZzX.js} +1 -1
  197. package/dist/web/assets/{taggerscript-BX_x0Ial.js → taggerscript-4a4rpAZe.js} +1 -1
  198. package/dist/web/assets/{tap-6j4jJ06c.js → tap-1yGDzo5T.js} +1 -1
  199. package/dist/web/assets/{tcl-BMqmGvnI.js → tcl-Blqm3M6H.js} +1 -1
  200. package/dist/web/assets/{thrift-BHwGzm9d.js → thrift-SCSYAnoo.js} +1 -1
  201. package/dist/web/assets/{tp-Br6ODkD7.js → tp-CJiYvF2Z.js} +1 -1
  202. package/dist/web/assets/{twig-BUg1tStP.js → twig-CwKcbSAY.js} +1 -1
  203. package/dist/web/assets/{typescript-DPw_D4qy.js → typescript-Dfq7Dw6S.js} +1 -1
  204. package/dist/web/assets/{vala-B9ZbKGNt.js → vala-CwjTTkCe.js} +1 -1
  205. package/dist/web/assets/{vbnet-CUnYo6Nq.js → vbnet-DkyZUDFs.js} +1 -1
  206. package/dist/web/assets/{vbscript-DqeU3ZVU.js → vbscript-D7mSa0kc.js} +1 -1
  207. package/dist/web/assets/{vbscript-html-m-WQzabX.js → vbscript-html-4muOpfOP.js} +1 -1
  208. package/dist/web/assets/{verilog-BUjbit38.js → verilog-CTx73zAb.js} +1 -1
  209. package/dist/web/assets/{vhdl-DarKCYnW.js → vhdl-bNkZElSZ.js} +1 -1
  210. package/dist/web/assets/{vim-IIbsNuQT.js → vim-BEHLt-ak.js} +1 -1
  211. package/dist/web/assets/{x86asm-DfuTazNN.js → x86asm-LPghO6jq.js} +1 -1
  212. package/dist/web/assets/{xl-BzrAs-xW.js → xl-C1a1l7dp.js} +1 -1
  213. package/dist/web/assets/{xml-BkJvQlqf.js → xml-DkVcEWrP.js} +1 -1
  214. package/dist/web/assets/{xquery-B8FbSCV_.js → xquery-BC8Ygt24.js} +1 -1
  215. package/dist/web/assets/{yaml-5ajRw-Fq.js → yaml-dlNOCKmh.js} +1 -1
  216. package/dist/web/assets/{zephir-CulEk9fW.js → zephir-Bif85EPV.js} +1 -1
  217. package/dist/web/index.html +3 -3
  218. package/package.json +2 -2
  219. package/dist/web/assets/index-CZUbUtgl.css +0 -1
  220. package/dist/web/assets/index-DKfT2EtL.js +0 -2044
  221. package/dist/web/assets/index-Dre4ow2N.js +0 -7
@@ -1,2 +1,2 @@
1
- import{c as at,f as rt,g as Ct,O as Ot,h as yt,J as It,R as U}from"./index-uEj4g89g.js";import{b as ut,bZ as vt,b_ as _t,b$ as Et,c0 as Tt,c1 as wt,c2 as St,c3 as At,y as lt,c4 as Rt,c5 as xt,c6 as k,x as kt,c7 as ct,c8 as bt}from"./index-DKfT2EtL.js";import{E as Nt,c as Mt}from"./embeddings-CnYfeC12.js";function I(t){if(typeof t=="object"&&t!==null){const e={...t};"additionalProperties"in e&&delete e.additionalProperties,"$schema"in e&&delete e.$schema,"strict"in e&&delete e.strict;for(const n in e)n in e&&(Array.isArray(e[n])?e[n]=e[n].map(I):typeof e[n]=="object"&&e[n]!==null&&(e[n]=I(e[n])));return e}return t}function N(t){const{$schema:e,...n}=I(ut(t)?vt(t):t);return n}function Dt(t){const{$schema:e,...n}=I(t);return n}function E(t,e,n=[]){if(t==null||typeof t!="object")return;const s=t;if(Array.isArray(s.enum)&&s.enum.some(i=>i==="")){const i=n.length?` at path "${n.join(".")}"`:"",o=e?` in tool "${e}"`:"";throw new Error(`Invalid enum: empty string not allowed${o}${i}. Gemini API rejects empty strings in enums.`)}if(s.type==="object"&&s.properties&&typeof s.properties=="object")for(const[i,o]of Object.entries(s.properties))E(o,e,[...n,i]);s.items&&E(s.items,e,[...n,"[]"]);for(const i of["anyOf","oneOf","allOf"]){const o=s[i];Array.isArray(o)&&o.forEach((a,u)=>E(a,e,[...n,`${i}[${u}]`]))}s.additionalProperties&&typeof s.additionalProperties=="object"&&E(s.additionalProperties,e,[...n,"additionalProperties"])}const h=[];for(let t=0;t<256;++t)h.push((t+256).toString(16).slice(1));function Gt(t,e=0){return(h[t[e+0]]+h[t[e+1]]+h[t[e+2]]+h[t[e+3]]+"-"+h[t[e+4]]+h[t[e+5]]+"-"+h[t[e+6]]+h[t[e+7]]+"-"+h[t[e+8]]+h[t[e+9]]+"-"+h[t[e+10]]+h[t[e+11]]+h[t[e+12]]+h[t[e+13]]+h[t[e+14]]+h[t[e+15]]).toLowerCase()}let b;const Ut=new Uint8Array(16);function Lt(){if(!b){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");b=crypto.getRandomValues.bind(crypto)}return b(Ut)}const Pt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),L={randomUUID:Pt};function dt(t,e,n){if(L.randomUUID&&!t)return L.randomUUID();t=t||{};const s=t.random??t.rng?.()??Lt();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Gt(s)}const D="__gemini_function_call_thought_signatures__",jt="ErYCCrMCAdHtim9kOoOkrPiCNVsmlpMIKd7ZMxgiFbVQOkgp7nlLcDMzVsZwIzvuT7nQROivoXA72ccC2lSDvR0Gh7dkWaGuj7ctv6t7ZceHnecx0QYa+ix8tYpRfjhyWozQ49lWiws6+YGjCt10KRTyWsZ2h6O7iHTYJwKIRwGUHRKy/qK/6kFxJm5ML00gLq4D8s5Z6DBpp2ZlR+uF4G8jJgeWQgyHWVdx2wGYElaceVAc66tZdPQRdOHpWtgYSI1YdaXgVI8KHY3/EfNc2YqqMIulvkDBAnuMhkAjV9xmBa54Tq+ih3Im4+r3DzqhGqYdsSkhS0kZMwte4Hjs65dZzCw9lANxIqYi1DJ639WNPYihp/DCJCos7o+/EeSPJaio5sgWDyUnMGkY1atsJZ+m7pj7DD5tvQ==",Kt=t=>t();function Ft(t){return St.isInstance(t)?t.role:t.type}function Ht(t){switch(t){case"supervisor":case"ai":case"model":return"model";case"system":return"system";case"human":return"user";case"tool":case"function":return"function";default:throw new Error(`Unknown / unsupported author: ${t}`)}}function $t(t){if("mimeType"in t&&"data"in t)return{inlineData:{mimeType:t.mimeType,data:t.data}};if("mimeType"in t&&"fileUri"in t)return{fileData:{mimeType:t.mimeType,fileUri:t.fileUri}};throw new Error("Invalid media content")}function Yt(t,e){return e.map(n=>lt(n)?n.tool_calls??[]:[]).flat().find(n=>n.id===t.tool_call_id)?.name}function Bt(t){return{providerName:"Google Gemini",fromStandardTextBlock(e){return{text:e.text}},fromStandardImageBlock(e){if(!t)throw new Error("This model does not support images");if(e.source_type==="url"){const n=k({dataUrl:e.url});return n?{inlineData:{mimeType:n.mime_type,data:n.data}}:{fileData:{mimeType:e.mime_type??"",fileUri:e.url}}}if(e.source_type==="base64")return{inlineData:{mimeType:e.mime_type??"",data:e.data}};throw new Error(`Unsupported source type: ${e.source_type}`)},fromStandardAudioBlock(e){if(!t)throw new Error("This model does not support audio");if(e.source_type==="url"){const n=k({dataUrl:e.url});return n?{inlineData:{mimeType:n.mime_type,data:n.data}}:{fileData:{mimeType:e.mime_type??"",fileUri:e.url}}}if(e.source_type==="base64")return{inlineData:{mimeType:e.mime_type??"",data:e.data}};throw new Error(`Unsupported source type: ${e.source_type}`)},fromStandardFileBlock(e){if(!t)throw new Error("This model does not support files");if(e.source_type==="text")return{text:e.text};if(e.source_type==="url"){const n=k({dataUrl:e.url});return n?{inlineData:{mimeType:n.mime_type,data:n.data}}:{fileData:{mimeType:e.mime_type??"",fileUri:e.url}}}if(e.source_type==="base64")return{inlineData:{mimeType:e.mime_type??"",data:e.data}};throw new Error(`Unsupported source type: ${e.source_type}`)}}}function P(t,e){if(Rt(t))return xt(t,Bt(e));if(t.type==="text")return{text:t.text};if(t.type==="executableCode")return{executableCode:t.executableCode};if(t.type==="codeExecutionResult")return{codeExecutionResult:t.codeExecutionResult};if(t.type==="image_url"){if(!e)throw new Error("This model does not support images");let n;if(typeof t.image_url=="string")n=t.image_url;else if(typeof t.image_url=="object"&&"url"in t.image_url)n=t.image_url.url;else throw new Error("Please provide image as base64 encoded data URL");const[s,i]=n.split(",");if(!s.startsWith("data:"))throw new Error("Please provide image as base64 encoded data URL");const[o,a]=s.replace(/^data:/,"").split(";");if(a!=="base64")throw new Error("Please provide image as base64 encoded data URL");return{inlineData:{data:i,mimeType:o}}}else{if(t.type==="media")return $t(t);if(t.type==="tool_use")return{functionCall:{name:t.name,args:t.input}};if(t.type==="tool_call")return{functionCall:{name:t.name,args:t.args}};if(t.type?.includes("/")&&t.type.split("/").length===2&&"data"in t&&typeof t.data=="string")return{inlineData:{mimeType:t.type,data:t.data}};if("functionCall"in t)return;throw"type"in t?new Error(`Unknown content type ${t.type}`):new Error(`Unknown content ${JSON.stringify(t)}`)}}function qt(t,e,n,s){if(At(t)){const u=t.name??Yt(t,n);if(u===void 0)throw new Error(`Google requires a tool name for each tool call response, and we could not infer a called tool name for ToolMessage "${t.id}" from your passed messages. Please populate a "name" field on that ToolMessage explicitly.`);const d=Array.isArray(t.content)?t.content.map(p=>P(p,e)).filter(p=>p!==void 0):t.content;return t.status==="error"?[{functionResponse:{name:u,response:{error:{details:d}}}}]:[{functionResponse:{name:u,response:{result:d}}}]}let i=[];const o=[];typeof t.content=="string"&&t.content&&o.push({text:t.content}),Array.isArray(t.content)&&o.push(...t.content.map(u=>P(u,e)).filter(u=>u!==void 0));const a=t.additional_kwargs?.[D];return lt(t)&&t.tool_calls?.length&&(i=t.tool_calls.map(u=>{const d=Kt(()=>{if(u.id){const p=a?.[u.id];if(p)return p}return s?.includes("gemini-3")?jt:""});return{functionCall:{name:u.name,args:u.args},...d?{thoughtSignature:d}:{}}})),[...o,...i]}function j(t,e,n=!1,s){return t.reduce((i,o,a)=>{if(!_t(o))throw new Error("Unsupported message input");const u=Ft(o);if(u==="system"&&a!==0)throw new Error("System message should be the first one");const d=Ht(u),p=i.content[i.content.length];if(!i.mergeWithPreviousContent&&p&&p.role===d)throw new Error("Google Generative AI requires alternate messages between authors");const l=qt(o,e,t.slice(0,a),s);if(i.mergeWithPreviousContent){const f=i.content[i.content.length-1];if(!f)throw new Error("There was a problem parsing your system message. Please try a prompt without one.");return f.parts.push(...l),{mergeWithPreviousContent:!1,content:i.content}}let r=d;(r==="function"||r==="system"&&!n)&&(r="user");const c={role:r,parts:l};return{mergeWithPreviousContent:u==="system"&&!n,content:[...i.content,c]}},{content:[],mergeWithPreviousContent:!1}).content}function Vt(t,e){if(!t.candidates||t.candidates.length===0||!t.candidates[0])return{generations:[],llmOutput:{filters:t.promptFeedback}};const[n]=t.candidates,{content:s,...i}=n,o=s.parts?.reduce((l,r)=>("functionCall"in r&&r.functionCall&&l.push({...r,id:"id"in r.functionCall&&typeof r.functionCall.id=="string"?r.functionCall.id:dt()}),l),[]);let a;const u=s?.parts;Array.isArray(u)&&u.length===1&&"text"in u[0]&&u[0].text&&!u[0].thought?a=u[0].text:Array.isArray(u)&&u.length>0?a=u.map(l=>l.thought&&"text"in l&&l.text?{type:"thinking",thinking:l.text,...l.thoughtSignature?{signature:l.thoughtSignature}:{}}:"text"in l?{type:"text",text:l.text}:"inlineData"in l?{type:"inlineData",inlineData:l.inlineData}:"functionCall"in l?{type:"functionCall",functionCall:l.functionCall}:"functionResponse"in l?{type:"functionResponse",functionResponse:l.functionResponse}:"fileData"in l?{type:"fileData",fileData:l.fileData}:"executableCode"in l?{type:"executableCode",executableCode:l.executableCode}:"codeExecutionResult"in l?{type:"codeExecutionResult",codeExecutionResult:l.codeExecutionResult}:l):a=[];const d=o?.reduce((l,r)=>("thoughtSignature"in r&&typeof r.thoughtSignature=="string"&&(l[r.id]=r.thoughtSignature),l),{});let p="";return typeof a=="string"?p=a:Array.isArray(a)&&a.length>0&&(p=a.find(l=>"text"in l)?.text??p),{generations:[{text:p,message:new Et({content:a??"",tool_calls:o?.map(l=>({type:"tool_call",id:l.id,name:l.functionCall.name,args:l.functionCall.args})),additional_kwargs:{...i,[D]:d},usage_metadata:e?.usageMetadata}),generationInfo:i}],llmOutput:{tokenUsage:{promptTokens:e?.usageMetadata?.input_tokens,completionTokens:e?.usageMetadata?.output_tokens,totalTokens:e?.usageMetadata?.total_tokens}}}}function Wt(t,e){if(!t.candidates||t.candidates.length===0)return null;const[n]=t.candidates,{content:s,...i}=n,o=s.parts?.reduce((r,c)=>("functionCall"in c&&c.functionCall&&r.push({...c,id:"id"in c.functionCall&&typeof c.functionCall.id=="string"?c.functionCall.id:dt()}),r),[]);let a;const u=s?.parts;Array.isArray(u)&&u.every(r=>"text"in r&&!r.thought)?a=u.map(r=>r.text).join(""):Array.isArray(u)?a=u.map(r=>r.thought&&"text"in r&&r.text?{type:"thinking",thinking:r.text,...r.thoughtSignature?{signature:r.thoughtSignature}:{}}:"text"in r?{type:"text",text:r.text}:"inlineData"in r?{type:"inlineData",inlineData:r.inlineData}:"functionCall"in r?{type:"functionCall",functionCall:r.functionCall}:"functionResponse"in r?{type:"functionResponse",functionResponse:r.functionResponse}:"fileData"in r?{type:"fileData",fileData:r.fileData}:"executableCode"in r?{type:"executableCode",executableCode:r.executableCode}:"codeExecutionResult"in r?{type:"codeExecutionResult",codeExecutionResult:r.codeExecutionResult}:r):a=[];let d="";a&&typeof a=="string"?d=a:Array.isArray(a)&&(d=a.find(r=>"text"in r)?.text??"");const p=[];o&&p.push(...o.map(r=>({type:"tool_call_chunk",id:r.id,name:r.functionCall.name,args:JSON.stringify(r.functionCall.args)})));const l=o?.reduce((r,c)=>("thoughtSignature"in c&&typeof c.thoughtSignature=="string"&&(r[c.id]=c.thoughtSignature),r),{});return new Tt({text:d,message:new wt({content:a||"",name:s?s.role:void 0,tool_call_chunks:p,additional_kwargs:{[D]:l},response_metadata:{model_provider:"google-genai"},usage_metadata:e.usageMetadata}),generationInfo:i})}function Jt(t){return t.every(e=>"functionDeclarations"in e&&Array.isArray(e.functionDeclarations))?t:[{functionDeclarations:t.map(e=>{if(at(e)){const n=N(e.schema);return n.type==="object"&&"properties"in n&&Object.keys(n.properties).length===0?{name:e.name,description:e.description}:(E(n,e.name),{name:e.name,description:e.description,parameters:n})}if(rt(e)){const n=Dt(e.function.parameters);return E(n,e.function.name),{name:e.function.name,description:e.function.description??"A function available to call.",parameters:n}}return e})}]}function K(t,e){const n={input_tokens:t?.promptTokenCount??0,output_tokens:t?.candidatesTokenCount??0,total_tokens:t?.totalTokenCount??0};if(t?.cachedContentTokenCount&&(n.input_token_details??={},n.input_token_details.cache_read=t.cachedContentTokenCount),e==="gemini-3-pro-preview"){const s=Math.max(0,t?.promptTokenCount??-2e5),i=Math.max(0,t?.cachedContentTokenCount??-2e5);s&&(n.input_token_details={...n.input_token_details,over_200k:s}),i&&(n.input_token_details={...n.input_token_details,cache_read_over_200k:i})}return n}var F=class extends Ct{static lc_name(){return"GoogleGenerativeAIToolsOutputParser"}lc_namespace=["langchain","google_genai","output_parsers"];returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(t){super(t),this.keyName=t.keyName,this.returnSingle=t.returnSingle??this.returnSingle,this.zodSchema=t.zodSchema}async _validateResult(t){if(this.zodSchema===void 0)return t;const e=await kt(this.zodSchema,t);if(e.success)return e.data;throw new Ot(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(e.error.issues)}`,JSON.stringify(t,null,2))}async parseResult(t){const e=t.flatMap(s=>{const{message:i}=s;return!("tool_calls"in i)||!Array.isArray(i.tool_calls)?[]:i.tool_calls});if(e[0]===void 0)throw new Error("No parseable tool calls provided to GoogleGenerativeAIToolsOutputParser.");const[n]=e;return await this._validateResult(n.args)}},H;(function(t){t.STRING="string",t.NUMBER="number",t.INTEGER="integer",t.BOOLEAN="boolean",t.ARRAY="array",t.OBJECT="object"})(H||(H={}));var $;(function(t){t.LANGUAGE_UNSPECIFIED="language_unspecified",t.PYTHON="python"})($||($={}));var Y;(function(t){t.OUTCOME_UNSPECIFIED="outcome_unspecified",t.OUTCOME_OK="outcome_ok",t.OUTCOME_FAILED="outcome_failed",t.OUTCOME_DEADLINE_EXCEEDED="outcome_deadline_exceeded"})(Y||(Y={}));const B=["user","model","function","system"];var q;(function(t){t.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",t.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",t.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",t.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",t.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",t.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY"})(q||(q={}));var V;(function(t){t.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",t.BLOCK_NONE="BLOCK_NONE"})(V||(V={}));var W;(function(t){t.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",t.NEGLIGIBLE="NEGLIGIBLE",t.LOW="LOW",t.MEDIUM="MEDIUM",t.HIGH="HIGH"})(W||(W={}));var J;(function(t){t.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",t.SAFETY="SAFETY",t.OTHER="OTHER"})(J||(J={}));var w;(function(t){t.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",t.STOP="STOP",t.MAX_TOKENS="MAX_TOKENS",t.SAFETY="SAFETY",t.RECITATION="RECITATION",t.LANGUAGE="LANGUAGE",t.BLOCKLIST="BLOCKLIST",t.PROHIBITED_CONTENT="PROHIBITED_CONTENT",t.SPII="SPII",t.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",t.OTHER="OTHER"})(w||(w={}));var z;(function(t){t.TASK_TYPE_UNSPECIFIED="TASK_TYPE_UNSPECIFIED",t.RETRIEVAL_QUERY="RETRIEVAL_QUERY",t.RETRIEVAL_DOCUMENT="RETRIEVAL_DOCUMENT",t.SEMANTIC_SIMILARITY="SEMANTIC_SIMILARITY",t.CLASSIFICATION="CLASSIFICATION",t.CLUSTERING="CLUSTERING"})(z||(z={}));var T;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.AUTO="AUTO",t.ANY="ANY",t.NONE="NONE"})(T||(T={}));var Q;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.MODE_DYNAMIC="MODE_DYNAMIC"})(Q||(Q={}));class m extends Error{constructor(e){super(`[GoogleGenerativeAI Error]: ${e}`)}}class _ extends m{constructor(e,n){super(e),this.response=n}}class ft extends m{constructor(e,n,s,i){super(e),this.status=n,this.statusText=s,this.errorDetails=i}}class y extends m{}class pt extends m{}const zt="https://generativelanguage.googleapis.com",Qt="v1beta",Zt="0.24.1",Xt="genai-js";var v;(function(t){t.GENERATE_CONTENT="generateContent",t.STREAM_GENERATE_CONTENT="streamGenerateContent",t.COUNT_TOKENS="countTokens",t.EMBED_CONTENT="embedContent",t.BATCH_EMBED_CONTENTS="batchEmbedContents"})(v||(v={}));class te{constructor(e,n,s,i,o){this.model=e,this.task=n,this.apiKey=s,this.stream=i,this.requestOptions=o}toString(){var e,n;const s=((e=this.requestOptions)===null||e===void 0?void 0:e.apiVersion)||Qt;let o=`${((n=this.requestOptions)===null||n===void 0?void 0:n.baseUrl)||zt}/${s}/${this.model}:${this.task}`;return this.stream&&(o+="?alt=sse"),o}}function ee(t){const e=[];return t?.apiClient&&e.push(t.apiClient),e.push(`${Xt}/${Zt}`),e.join(" ")}async function ne(t){var e;const n=new Headers;n.append("Content-Type","application/json"),n.append("x-goog-api-client",ee(t.requestOptions)),n.append("x-goog-api-key",t.apiKey);let s=(e=t.requestOptions)===null||e===void 0?void 0:e.customHeaders;if(s){if(!(s instanceof Headers))try{s=new Headers(s)}catch(i){throw new y(`unable to convert customHeaders value ${JSON.stringify(s)} to Headers: ${i.message}`)}for(const[i,o]of s.entries()){if(i==="x-goog-api-key")throw new y(`Cannot set reserved header name ${i}`);if(i==="x-goog-api-client")throw new y(`Header name ${i} can only be set using the apiClient field`);n.append(i,o)}}return n}async function se(t,e,n,s,i,o){const a=new te(t,e,n,s,o);return{url:a.toString(),fetchOptions:Object.assign(Object.assign({},re(o)),{method:"POST",headers:await ne(a),body:i})}}async function R(t,e,n,s,i,o={},a=fetch){const{url:u,fetchOptions:d}=await se(t,e,n,s,i,o);return ie(u,d,a)}async function ie(t,e,n=fetch){let s;try{s=await n(t,e)}catch(i){oe(i,t)}return s.ok||await ae(s,t),s}function oe(t,e){let n=t;throw n.name==="AbortError"?(n=new pt(`Request aborted when fetching ${e.toString()}: ${t.message}`),n.stack=t.stack):t instanceof ft||t instanceof y||(n=new m(`Error fetching from ${e.toString()}: ${t.message}`),n.stack=t.stack),n}async function ae(t,e){let n="",s;try{const i=await t.json();n=i.error.message,i.error.details&&(n+=` ${JSON.stringify(i.error.details)}`,s=i.error.details)}catch{}throw new ft(`Error fetching from ${e.toString()}: [${t.status} ${t.statusText}] ${n}`,t.status,t.statusText,s)}function re(t){const e={};if(t?.signal!==void 0||t?.timeout>=0){const n=new AbortController;t?.timeout>=0&&setTimeout(()=>n.abort(),t.timeout),t?.signal&&t.signal.addEventListener("abort",()=>{n.abort()}),e.signal=n.signal}return e}function G(t){return t.text=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.`),x(t.candidates[0]))throw new _(`${O(t)}`,t);return ue(t)}else if(t.promptFeedback)throw new _(`Text not available. ${O(t)}`,t);return""},t.functionCall=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),x(t.candidates[0]))throw new _(`${O(t)}`,t);return console.warn("response.functionCall() is deprecated. Use response.functionCalls() instead."),Z(t)[0]}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t.functionCalls=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),x(t.candidates[0]))throw new _(`${O(t)}`,t);return Z(t)}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t}function ue(t){var e,n,s,i;const o=[];if(!((n=(e=t.candidates)===null||e===void 0?void 0:e[0].content)===null||n===void 0)&&n.parts)for(const a of(i=(s=t.candidates)===null||s===void 0?void 0:s[0].content)===null||i===void 0?void 0:i.parts)a.text&&o.push(a.text),a.executableCode&&o.push("\n```"+a.executableCode.language+`
1
+ import{c as at,f as rt,g as Ct,O as Ot,h as yt,J as It,R as U}from"./index-DUSfaXA6.js";import{b as ut,Q as vt,S as _t,U as Et,V as Tt,W as wt,X as St,Y as At,y as lt,Z as Rt,$ as xt,a0 as k,x as kt,a1 as ct,a2 as bt}from"./index-YcAOTRMN.js";import{E as Nt,c as Mt}from"./embeddings-LX6aYruq.js";function I(t){if(typeof t=="object"&&t!==null){const e={...t};"additionalProperties"in e&&delete e.additionalProperties,"$schema"in e&&delete e.$schema,"strict"in e&&delete e.strict;for(const n in e)n in e&&(Array.isArray(e[n])?e[n]=e[n].map(I):typeof e[n]=="object"&&e[n]!==null&&(e[n]=I(e[n])));return e}return t}function N(t){const{$schema:e,...n}=I(ut(t)?vt(t):t);return n}function Dt(t){const{$schema:e,...n}=I(t);return n}function E(t,e,n=[]){if(t==null||typeof t!="object")return;const s=t;if(Array.isArray(s.enum)&&s.enum.some(i=>i==="")){const i=n.length?` at path "${n.join(".")}"`:"",o=e?` in tool "${e}"`:"";throw new Error(`Invalid enum: empty string not allowed${o}${i}. Gemini API rejects empty strings in enums.`)}if(s.type==="object"&&s.properties&&typeof s.properties=="object")for(const[i,o]of Object.entries(s.properties))E(o,e,[...n,i]);s.items&&E(s.items,e,[...n,"[]"]);for(const i of["anyOf","oneOf","allOf"]){const o=s[i];Array.isArray(o)&&o.forEach((a,u)=>E(a,e,[...n,`${i}[${u}]`]))}s.additionalProperties&&typeof s.additionalProperties=="object"&&E(s.additionalProperties,e,[...n,"additionalProperties"])}const h=[];for(let t=0;t<256;++t)h.push((t+256).toString(16).slice(1));function Gt(t,e=0){return(h[t[e+0]]+h[t[e+1]]+h[t[e+2]]+h[t[e+3]]+"-"+h[t[e+4]]+h[t[e+5]]+"-"+h[t[e+6]]+h[t[e+7]]+"-"+h[t[e+8]]+h[t[e+9]]+"-"+h[t[e+10]]+h[t[e+11]]+h[t[e+12]]+h[t[e+13]]+h[t[e+14]]+h[t[e+15]]).toLowerCase()}let b;const Ut=new Uint8Array(16);function Lt(){if(!b){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");b=crypto.getRandomValues.bind(crypto)}return b(Ut)}const Pt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),L={randomUUID:Pt};function dt(t,e,n){if(L.randomUUID&&!t)return L.randomUUID();t=t||{};const s=t.random??t.rng?.()??Lt();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Gt(s)}const D="__gemini_function_call_thought_signatures__",jt="ErYCCrMCAdHtim9kOoOkrPiCNVsmlpMIKd7ZMxgiFbVQOkgp7nlLcDMzVsZwIzvuT7nQROivoXA72ccC2lSDvR0Gh7dkWaGuj7ctv6t7ZceHnecx0QYa+ix8tYpRfjhyWozQ49lWiws6+YGjCt10KRTyWsZ2h6O7iHTYJwKIRwGUHRKy/qK/6kFxJm5ML00gLq4D8s5Z6DBpp2ZlR+uF4G8jJgeWQgyHWVdx2wGYElaceVAc66tZdPQRdOHpWtgYSI1YdaXgVI8KHY3/EfNc2YqqMIulvkDBAnuMhkAjV9xmBa54Tq+ih3Im4+r3DzqhGqYdsSkhS0kZMwte4Hjs65dZzCw9lANxIqYi1DJ639WNPYihp/DCJCos7o+/EeSPJaio5sgWDyUnMGkY1atsJZ+m7pj7DD5tvQ==",Kt=t=>t();function Ft(t){return St.isInstance(t)?t.role:t.type}function Ht(t){switch(t){case"supervisor":case"ai":case"model":return"model";case"system":return"system";case"human":return"user";case"tool":case"function":return"function";default:throw new Error(`Unknown / unsupported author: ${t}`)}}function $t(t){if("mimeType"in t&&"data"in t)return{inlineData:{mimeType:t.mimeType,data:t.data}};if("mimeType"in t&&"fileUri"in t)return{fileData:{mimeType:t.mimeType,fileUri:t.fileUri}};throw new Error("Invalid media content")}function Yt(t,e){return e.map(n=>lt(n)?n.tool_calls??[]:[]).flat().find(n=>n.id===t.tool_call_id)?.name}function Bt(t){return{providerName:"Google Gemini",fromStandardTextBlock(e){return{text:e.text}},fromStandardImageBlock(e){if(!t)throw new Error("This model does not support images");if(e.source_type==="url"){const n=k({dataUrl:e.url});return n?{inlineData:{mimeType:n.mime_type,data:n.data}}:{fileData:{mimeType:e.mime_type??"",fileUri:e.url}}}if(e.source_type==="base64")return{inlineData:{mimeType:e.mime_type??"",data:e.data}};throw new Error(`Unsupported source type: ${e.source_type}`)},fromStandardAudioBlock(e){if(!t)throw new Error("This model does not support audio");if(e.source_type==="url"){const n=k({dataUrl:e.url});return n?{inlineData:{mimeType:n.mime_type,data:n.data}}:{fileData:{mimeType:e.mime_type??"",fileUri:e.url}}}if(e.source_type==="base64")return{inlineData:{mimeType:e.mime_type??"",data:e.data}};throw new Error(`Unsupported source type: ${e.source_type}`)},fromStandardFileBlock(e){if(!t)throw new Error("This model does not support files");if(e.source_type==="text")return{text:e.text};if(e.source_type==="url"){const n=k({dataUrl:e.url});return n?{inlineData:{mimeType:n.mime_type,data:n.data}}:{fileData:{mimeType:e.mime_type??"",fileUri:e.url}}}if(e.source_type==="base64")return{inlineData:{mimeType:e.mime_type??"",data:e.data}};throw new Error(`Unsupported source type: ${e.source_type}`)}}}function P(t,e){if(Rt(t))return xt(t,Bt(e));if(t.type==="text")return{text:t.text};if(t.type==="executableCode")return{executableCode:t.executableCode};if(t.type==="codeExecutionResult")return{codeExecutionResult:t.codeExecutionResult};if(t.type==="image_url"){if(!e)throw new Error("This model does not support images");let n;if(typeof t.image_url=="string")n=t.image_url;else if(typeof t.image_url=="object"&&"url"in t.image_url)n=t.image_url.url;else throw new Error("Please provide image as base64 encoded data URL");const[s,i]=n.split(",");if(!s.startsWith("data:"))throw new Error("Please provide image as base64 encoded data URL");const[o,a]=s.replace(/^data:/,"").split(";");if(a!=="base64")throw new Error("Please provide image as base64 encoded data URL");return{inlineData:{data:i,mimeType:o}}}else{if(t.type==="media")return $t(t);if(t.type==="tool_use")return{functionCall:{name:t.name,args:t.input}};if(t.type==="tool_call")return{functionCall:{name:t.name,args:t.args}};if(t.type?.includes("/")&&t.type.split("/").length===2&&"data"in t&&typeof t.data=="string")return{inlineData:{mimeType:t.type,data:t.data}};if("functionCall"in t)return;throw"type"in t?new Error(`Unknown content type ${t.type}`):new Error(`Unknown content ${JSON.stringify(t)}`)}}function qt(t,e,n,s){if(At(t)){const u=t.name??Yt(t,n);if(u===void 0)throw new Error(`Google requires a tool name for each tool call response, and we could not infer a called tool name for ToolMessage "${t.id}" from your passed messages. Please populate a "name" field on that ToolMessage explicitly.`);const d=Array.isArray(t.content)?t.content.map(p=>P(p,e)).filter(p=>p!==void 0):t.content;return t.status==="error"?[{functionResponse:{name:u,response:{error:{details:d}}}}]:[{functionResponse:{name:u,response:{result:d}}}]}let i=[];const o=[];typeof t.content=="string"&&t.content&&o.push({text:t.content}),Array.isArray(t.content)&&o.push(...t.content.map(u=>P(u,e)).filter(u=>u!==void 0));const a=t.additional_kwargs?.[D];return lt(t)&&t.tool_calls?.length&&(i=t.tool_calls.map(u=>{const d=Kt(()=>{if(u.id){const p=a?.[u.id];if(p)return p}return s?.includes("gemini-3")?jt:""});return{functionCall:{name:u.name,args:u.args},...d?{thoughtSignature:d}:{}}})),[...o,...i]}function j(t,e,n=!1,s){return t.reduce((i,o,a)=>{if(!_t(o))throw new Error("Unsupported message input");const u=Ft(o);if(u==="system"&&a!==0)throw new Error("System message should be the first one");const d=Ht(u),p=i.content[i.content.length];if(!i.mergeWithPreviousContent&&p&&p.role===d)throw new Error("Google Generative AI requires alternate messages between authors");const l=qt(o,e,t.slice(0,a),s);if(i.mergeWithPreviousContent){const f=i.content[i.content.length-1];if(!f)throw new Error("There was a problem parsing your system message. Please try a prompt without one.");return f.parts.push(...l),{mergeWithPreviousContent:!1,content:i.content}}let r=d;(r==="function"||r==="system"&&!n)&&(r="user");const c={role:r,parts:l};return{mergeWithPreviousContent:u==="system"&&!n,content:[...i.content,c]}},{content:[],mergeWithPreviousContent:!1}).content}function Vt(t,e){if(!t.candidates||t.candidates.length===0||!t.candidates[0])return{generations:[],llmOutput:{filters:t.promptFeedback}};const[n]=t.candidates,{content:s,...i}=n,o=s.parts?.reduce((l,r)=>("functionCall"in r&&r.functionCall&&l.push({...r,id:"id"in r.functionCall&&typeof r.functionCall.id=="string"?r.functionCall.id:dt()}),l),[]);let a;const u=s?.parts;Array.isArray(u)&&u.length===1&&"text"in u[0]&&u[0].text&&!u[0].thought?a=u[0].text:Array.isArray(u)&&u.length>0?a=u.map(l=>l.thought&&"text"in l&&l.text?{type:"thinking",thinking:l.text,...l.thoughtSignature?{signature:l.thoughtSignature}:{}}:"text"in l?{type:"text",text:l.text}:"inlineData"in l?{type:"inlineData",inlineData:l.inlineData}:"functionCall"in l?{type:"functionCall",functionCall:l.functionCall}:"functionResponse"in l?{type:"functionResponse",functionResponse:l.functionResponse}:"fileData"in l?{type:"fileData",fileData:l.fileData}:"executableCode"in l?{type:"executableCode",executableCode:l.executableCode}:"codeExecutionResult"in l?{type:"codeExecutionResult",codeExecutionResult:l.codeExecutionResult}:l):a=[];const d=o?.reduce((l,r)=>("thoughtSignature"in r&&typeof r.thoughtSignature=="string"&&(l[r.id]=r.thoughtSignature),l),{});let p="";return typeof a=="string"?p=a:Array.isArray(a)&&a.length>0&&(p=a.find(l=>"text"in l)?.text??p),{generations:[{text:p,message:new Et({content:a??"",tool_calls:o?.map(l=>({type:"tool_call",id:l.id,name:l.functionCall.name,args:l.functionCall.args})),additional_kwargs:{...i,[D]:d},usage_metadata:e?.usageMetadata}),generationInfo:i}],llmOutput:{tokenUsage:{promptTokens:e?.usageMetadata?.input_tokens,completionTokens:e?.usageMetadata?.output_tokens,totalTokens:e?.usageMetadata?.total_tokens}}}}function Wt(t,e){if(!t.candidates||t.candidates.length===0)return null;const[n]=t.candidates,{content:s,...i}=n,o=s.parts?.reduce((r,c)=>("functionCall"in c&&c.functionCall&&r.push({...c,id:"id"in c.functionCall&&typeof c.functionCall.id=="string"?c.functionCall.id:dt()}),r),[]);let a;const u=s?.parts;Array.isArray(u)&&u.every(r=>"text"in r&&!r.thought)?a=u.map(r=>r.text).join(""):Array.isArray(u)?a=u.map(r=>r.thought&&"text"in r&&r.text?{type:"thinking",thinking:r.text,...r.thoughtSignature?{signature:r.thoughtSignature}:{}}:"text"in r?{type:"text",text:r.text}:"inlineData"in r?{type:"inlineData",inlineData:r.inlineData}:"functionCall"in r?{type:"functionCall",functionCall:r.functionCall}:"functionResponse"in r?{type:"functionResponse",functionResponse:r.functionResponse}:"fileData"in r?{type:"fileData",fileData:r.fileData}:"executableCode"in r?{type:"executableCode",executableCode:r.executableCode}:"codeExecutionResult"in r?{type:"codeExecutionResult",codeExecutionResult:r.codeExecutionResult}:r):a=[];let d="";a&&typeof a=="string"?d=a:Array.isArray(a)&&(d=a.find(r=>"text"in r)?.text??"");const p=[];o&&p.push(...o.map(r=>({type:"tool_call_chunk",id:r.id,name:r.functionCall.name,args:JSON.stringify(r.functionCall.args)})));const l=o?.reduce((r,c)=>("thoughtSignature"in c&&typeof c.thoughtSignature=="string"&&(r[c.id]=c.thoughtSignature),r),{});return new Tt({text:d,message:new wt({content:a||"",name:s?s.role:void 0,tool_call_chunks:p,additional_kwargs:{[D]:l},response_metadata:{model_provider:"google-genai"},usage_metadata:e.usageMetadata}),generationInfo:i})}function Jt(t){return t.every(e=>"functionDeclarations"in e&&Array.isArray(e.functionDeclarations))?t:[{functionDeclarations:t.map(e=>{if(at(e)){const n=N(e.schema);return n.type==="object"&&"properties"in n&&Object.keys(n.properties).length===0?{name:e.name,description:e.description}:(E(n,e.name),{name:e.name,description:e.description,parameters:n})}if(rt(e)){const n=Dt(e.function.parameters);return E(n,e.function.name),{name:e.function.name,description:e.function.description??"A function available to call.",parameters:n}}return e})}]}function K(t,e){const n={input_tokens:t?.promptTokenCount??0,output_tokens:t?.candidatesTokenCount??0,total_tokens:t?.totalTokenCount??0};if(t?.cachedContentTokenCount&&(n.input_token_details??={},n.input_token_details.cache_read=t.cachedContentTokenCount),e==="gemini-3-pro-preview"){const s=Math.max(0,t?.promptTokenCount??-2e5),i=Math.max(0,t?.cachedContentTokenCount??-2e5);s&&(n.input_token_details={...n.input_token_details,over_200k:s}),i&&(n.input_token_details={...n.input_token_details,cache_read_over_200k:i})}return n}var F=class extends Ct{static lc_name(){return"GoogleGenerativeAIToolsOutputParser"}lc_namespace=["langchain","google_genai","output_parsers"];returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(t){super(t),this.keyName=t.keyName,this.returnSingle=t.returnSingle??this.returnSingle,this.zodSchema=t.zodSchema}async _validateResult(t){if(this.zodSchema===void 0)return t;const e=await kt(this.zodSchema,t);if(e.success)return e.data;throw new Ot(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(e.error.issues)}`,JSON.stringify(t,null,2))}async parseResult(t){const e=t.flatMap(s=>{const{message:i}=s;return!("tool_calls"in i)||!Array.isArray(i.tool_calls)?[]:i.tool_calls});if(e[0]===void 0)throw new Error("No parseable tool calls provided to GoogleGenerativeAIToolsOutputParser.");const[n]=e;return await this._validateResult(n.args)}},H;(function(t){t.STRING="string",t.NUMBER="number",t.INTEGER="integer",t.BOOLEAN="boolean",t.ARRAY="array",t.OBJECT="object"})(H||(H={}));var $;(function(t){t.LANGUAGE_UNSPECIFIED="language_unspecified",t.PYTHON="python"})($||($={}));var Y;(function(t){t.OUTCOME_UNSPECIFIED="outcome_unspecified",t.OUTCOME_OK="outcome_ok",t.OUTCOME_FAILED="outcome_failed",t.OUTCOME_DEADLINE_EXCEEDED="outcome_deadline_exceeded"})(Y||(Y={}));const B=["user","model","function","system"];var q;(function(t){t.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",t.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",t.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",t.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",t.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",t.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY"})(q||(q={}));var V;(function(t){t.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",t.BLOCK_NONE="BLOCK_NONE"})(V||(V={}));var W;(function(t){t.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",t.NEGLIGIBLE="NEGLIGIBLE",t.LOW="LOW",t.MEDIUM="MEDIUM",t.HIGH="HIGH"})(W||(W={}));var J;(function(t){t.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",t.SAFETY="SAFETY",t.OTHER="OTHER"})(J||(J={}));var w;(function(t){t.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",t.STOP="STOP",t.MAX_TOKENS="MAX_TOKENS",t.SAFETY="SAFETY",t.RECITATION="RECITATION",t.LANGUAGE="LANGUAGE",t.BLOCKLIST="BLOCKLIST",t.PROHIBITED_CONTENT="PROHIBITED_CONTENT",t.SPII="SPII",t.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",t.OTHER="OTHER"})(w||(w={}));var z;(function(t){t.TASK_TYPE_UNSPECIFIED="TASK_TYPE_UNSPECIFIED",t.RETRIEVAL_QUERY="RETRIEVAL_QUERY",t.RETRIEVAL_DOCUMENT="RETRIEVAL_DOCUMENT",t.SEMANTIC_SIMILARITY="SEMANTIC_SIMILARITY",t.CLASSIFICATION="CLASSIFICATION",t.CLUSTERING="CLUSTERING"})(z||(z={}));var T;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.AUTO="AUTO",t.ANY="ANY",t.NONE="NONE"})(T||(T={}));var Q;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.MODE_DYNAMIC="MODE_DYNAMIC"})(Q||(Q={}));class m extends Error{constructor(e){super(`[GoogleGenerativeAI Error]: ${e}`)}}class _ extends m{constructor(e,n){super(e),this.response=n}}class ft extends m{constructor(e,n,s,i){super(e),this.status=n,this.statusText=s,this.errorDetails=i}}class y extends m{}class pt extends m{}const zt="https://generativelanguage.googleapis.com",Qt="v1beta",Zt="0.24.1",Xt="genai-js";var v;(function(t){t.GENERATE_CONTENT="generateContent",t.STREAM_GENERATE_CONTENT="streamGenerateContent",t.COUNT_TOKENS="countTokens",t.EMBED_CONTENT="embedContent",t.BATCH_EMBED_CONTENTS="batchEmbedContents"})(v||(v={}));class te{constructor(e,n,s,i,o){this.model=e,this.task=n,this.apiKey=s,this.stream=i,this.requestOptions=o}toString(){var e,n;const s=((e=this.requestOptions)===null||e===void 0?void 0:e.apiVersion)||Qt;let o=`${((n=this.requestOptions)===null||n===void 0?void 0:n.baseUrl)||zt}/${s}/${this.model}:${this.task}`;return this.stream&&(o+="?alt=sse"),o}}function ee(t){const e=[];return t?.apiClient&&e.push(t.apiClient),e.push(`${Xt}/${Zt}`),e.join(" ")}async function ne(t){var e;const n=new Headers;n.append("Content-Type","application/json"),n.append("x-goog-api-client",ee(t.requestOptions)),n.append("x-goog-api-key",t.apiKey);let s=(e=t.requestOptions)===null||e===void 0?void 0:e.customHeaders;if(s){if(!(s instanceof Headers))try{s=new Headers(s)}catch(i){throw new y(`unable to convert customHeaders value ${JSON.stringify(s)} to Headers: ${i.message}`)}for(const[i,o]of s.entries()){if(i==="x-goog-api-key")throw new y(`Cannot set reserved header name ${i}`);if(i==="x-goog-api-client")throw new y(`Header name ${i} can only be set using the apiClient field`);n.append(i,o)}}return n}async function se(t,e,n,s,i,o){const a=new te(t,e,n,s,o);return{url:a.toString(),fetchOptions:Object.assign(Object.assign({},re(o)),{method:"POST",headers:await ne(a),body:i})}}async function R(t,e,n,s,i,o={},a=fetch){const{url:u,fetchOptions:d}=await se(t,e,n,s,i,o);return ie(u,d,a)}async function ie(t,e,n=fetch){let s;try{s=await n(t,e)}catch(i){oe(i,t)}return s.ok||await ae(s,t),s}function oe(t,e){let n=t;throw n.name==="AbortError"?(n=new pt(`Request aborted when fetching ${e.toString()}: ${t.message}`),n.stack=t.stack):t instanceof ft||t instanceof y||(n=new m(`Error fetching from ${e.toString()}: ${t.message}`),n.stack=t.stack),n}async function ae(t,e){let n="",s;try{const i=await t.json();n=i.error.message,i.error.details&&(n+=` ${JSON.stringify(i.error.details)}`,s=i.error.details)}catch{}throw new ft(`Error fetching from ${e.toString()}: [${t.status} ${t.statusText}] ${n}`,t.status,t.statusText,s)}function re(t){const e={};if(t?.signal!==void 0||t?.timeout>=0){const n=new AbortController;t?.timeout>=0&&setTimeout(()=>n.abort(),t.timeout),t?.signal&&t.signal.addEventListener("abort",()=>{n.abort()}),e.signal=n.signal}return e}function G(t){return t.text=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.`),x(t.candidates[0]))throw new _(`${O(t)}`,t);return ue(t)}else if(t.promptFeedback)throw new _(`Text not available. ${O(t)}`,t);return""},t.functionCall=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),x(t.candidates[0]))throw new _(`${O(t)}`,t);return console.warn("response.functionCall() is deprecated. Use response.functionCalls() instead."),Z(t)[0]}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t.functionCalls=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),x(t.candidates[0]))throw new _(`${O(t)}`,t);return Z(t)}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t}function ue(t){var e,n,s,i;const o=[];if(!((n=(e=t.candidates)===null||e===void 0?void 0:e[0].content)===null||n===void 0)&&n.parts)for(const a of(i=(s=t.candidates)===null||s===void 0?void 0:s[0].content)===null||i===void 0?void 0:i.parts)a.text&&o.push(a.text),a.executableCode&&o.push("\n```"+a.executableCode.language+`
2
2
  `+a.executableCode.code+"\n```\n"),a.codeExecutionResult&&o.push("\n```\n"+a.codeExecutionResult.output+"\n```\n");return o.length>0?o.join(""):""}function Z(t){var e,n,s,i;const o=[];if(!((n=(e=t.candidates)===null||e===void 0?void 0:e[0].content)===null||n===void 0)&&n.parts)for(const a of(i=(s=t.candidates)===null||s===void 0?void 0:s[0].content)===null||i===void 0?void 0:i.parts)a.functionCall&&o.push(a.functionCall);if(o.length>0)return o}const le=[w.RECITATION,w.SAFETY,w.LANGUAGE];function x(t){return!!t.finishReason&&le.includes(t.finishReason)}function O(t){var e,n,s;let i="";if((!t.candidates||t.candidates.length===0)&&t.promptFeedback)i+="Response was blocked",!((e=t.promptFeedback)===null||e===void 0)&&e.blockReason&&(i+=` due to ${t.promptFeedback.blockReason}`),!((n=t.promptFeedback)===null||n===void 0)&&n.blockReasonMessage&&(i+=`: ${t.promptFeedback.blockReasonMessage}`);else if(!((s=t.candidates)===null||s===void 0)&&s[0]){const o=t.candidates[0];x(o)&&(i+=`Candidate was blocked due to ${o.finishReason}`,o.finishMessage&&(i+=`: ${o.finishMessage}`))}return i}function S(t){return this instanceof S?(this.v=t,this):new S(t)}function ce(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=n.apply(t,e||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(c){s[c]&&(i[c]=function(f){return new Promise(function(g,C){o.push([c,f,g,C])>1||u(c,f)})})}function u(c,f){try{d(s[c](f))}catch(g){r(o[0][3],g)}}function d(c){c.value instanceof S?Promise.resolve(c.value.v).then(p,l):r(o[0][2],c)}function p(c){u("next",c)}function l(c){u("throw",c)}function r(c,f){c(f),o.shift(),o.length&&u(o[0][0],o[0][1])}}const X=/^data\: (.*)(?:\n\n|\r\r|\r\n\r\n)/;function de(t){const e=t.body.pipeThrough(new TextDecoderStream("utf8",{fatal:!0})),n=ge(e),[s,i]=n.tee();return{stream:pe(s),response:fe(i)}}async function fe(t){const e=[],n=t.getReader();for(;;){const{done:s,value:i}=await n.read();if(s)return G(he(e));e.push(i)}}function pe(t){return ce(this,arguments,function*(){const n=t.getReader();for(;;){const{value:s,done:i}=yield S(n.read());if(i)break;yield yield S(G(s))}})}function ge(t){const e=t.getReader();return new ReadableStream({start(s){let i="";return o();function o(){return e.read().then(({value:a,done:u})=>{if(u){if(i.trim()){s.error(new m("Failed to parse stream"));return}s.close();return}i+=a;let d=i.match(X),p;for(;d;){try{p=JSON.parse(d[1])}catch{s.error(new m(`Error parsing JSON response: "${d[1]}"`));return}s.enqueue(p),i=i.substring(d[0].length),d=i.match(X)}return o()}).catch(a=>{let u=a;throw u.stack=a.stack,u.name==="AbortError"?u=new pt("Request aborted when reading from the stream"):u=new m("Error reading from the stream"),u})}}})}function he(t){const e=t[t.length-1],n={promptFeedback:e?.promptFeedback};for(const s of t){if(s.candidates){let i=0;for(const o of s.candidates)if(n.candidates||(n.candidates=[]),n.candidates[i]||(n.candidates[i]={index:i}),n.candidates[i].citationMetadata=o.citationMetadata,n.candidates[i].groundingMetadata=o.groundingMetadata,n.candidates[i].finishReason=o.finishReason,n.candidates[i].finishMessage=o.finishMessage,n.candidates[i].safetyRatings=o.safetyRatings,o.content&&o.content.parts){n.candidates[i].content||(n.candidates[i].content={role:o.content.role||"user",parts:[]});const a={};for(const u of o.content.parts)u.text&&(a.text=u.text),u.functionCall&&(a.functionCall=u.functionCall),u.executableCode&&(a.executableCode=u.executableCode),u.codeExecutionResult&&(a.codeExecutionResult=u.codeExecutionResult),Object.keys(a).length===0&&(a.text=""),n.candidates[i].content.parts.push(a)}i++}s.usageMetadata&&(n.usageMetadata=s.usageMetadata)}return n}async function gt(t,e,n,s){const i=await R(e,v.STREAM_GENERATE_CONTENT,t,!0,JSON.stringify(n),s);return de(i)}async function ht(t,e,n,s){const o=await(await R(e,v.GENERATE_CONTENT,t,!1,JSON.stringify(n),s)).json();return{response:G(o)}}function mt(t){if(t!=null){if(typeof t=="string")return{role:"system",parts:[{text:t}]};if(t.text)return{role:"system",parts:[t]};if(t.parts)return t.role?t:{role:"system",parts:t.parts}}}function A(t){let e=[];if(typeof t=="string")e=[{text:t}];else for(const n of t)typeof n=="string"?e.push({text:n}):e.push(n);return me(e)}function me(t){const e={role:"user",parts:[]},n={role:"function",parts:[]};let s=!1,i=!1;for(const o of t)"functionResponse"in o?(n.parts.push(o),i=!0):(e.parts.push(o),s=!0);if(s&&i)throw new m("Within a single message, FunctionResponse cannot be mixed with other type of part in the request for sending chat message.");if(!s&&!i)throw new m("No content is provided for sending chat message.");return s?e:n}function Ce(t,e){var n;let s={model:e?.model,generationConfig:e?.generationConfig,safetySettings:e?.safetySettings,tools:e?.tools,toolConfig:e?.toolConfig,systemInstruction:e?.systemInstruction,cachedContent:(n=e?.cachedContent)===null||n===void 0?void 0:n.name,contents:[]};const i=t.generateContentRequest!=null;if(t.contents){if(i)throw new y("CountTokensRequest must have one of contents or generateContentRequest, not both.");s.contents=t.contents}else if(i)s=Object.assign(Object.assign({},s),t.generateContentRequest);else{const o=A(t);s.contents=[o]}return{generateContentRequest:s}}function tt(t){let e;return t.contents?e=t:e={contents:[A(t)]},t.systemInstruction&&(e.systemInstruction=mt(t.systemInstruction)),e}function Oe(t){return typeof t=="string"||Array.isArray(t)?{content:A(t)}:t}const et=["text","inlineData","functionCall","functionResponse","executableCode","codeExecutionResult"],ye={user:["text","inlineData"],function:["functionResponse"],model:["text","functionCall","executableCode","codeExecutionResult"],system:["text"]};function Ie(t){let e=!1;for(const n of t){const{role:s,parts:i}=n;if(!e&&s!=="user")throw new m(`First content should be with role 'user', got ${s}`);if(!B.includes(s))throw new m(`Each item should include role field. Got ${s} but valid roles are: ${JSON.stringify(B)}`);if(!Array.isArray(i))throw new m("Content should have 'parts' property with an array of Parts");if(i.length===0)throw new m("Each Content should have at least one part");const o={text:0,inlineData:0,functionCall:0,functionResponse:0,fileData:0,executableCode:0,codeExecutionResult:0};for(const u of i)for(const d of et)d in u&&(o[d]+=1);const a=ye[s];for(const u of et)if(!a.includes(u)&&o[u]>0)throw new m(`Content with role '${s}' can't contain '${u}' part`);e=!0}}function nt(t){var e;if(t.candidates===void 0||t.candidates.length===0)return!1;const n=(e=t.candidates[0])===null||e===void 0?void 0:e.content;if(n===void 0||n.parts===void 0||n.parts.length===0)return!1;for(const s of n.parts)if(s===void 0||Object.keys(s).length===0||s.text!==void 0&&s.text==="")return!1;return!0}const st="SILENT_ERROR";class ve{constructor(e,n,s,i={}){this.model=n,this.params=s,this._requestOptions=i,this._history=[],this._sendPromise=Promise.resolve(),this._apiKey=e,s?.history&&(Ie(s.history),this._history=s.history)}async getHistory(){return await this._sendPromise,this._history}async sendMessage(e,n={}){var s,i,o,a,u,d;await this._sendPromise;const p=A(e),l={safetySettings:(s=this.params)===null||s===void 0?void 0:s.safetySettings,generationConfig:(i=this.params)===null||i===void 0?void 0:i.generationConfig,tools:(o=this.params)===null||o===void 0?void 0:o.tools,toolConfig:(a=this.params)===null||a===void 0?void 0:a.toolConfig,systemInstruction:(u=this.params)===null||u===void 0?void 0:u.systemInstruction,cachedContent:(d=this.params)===null||d===void 0?void 0:d.cachedContent,contents:[...this._history,p]},r=Object.assign(Object.assign({},this._requestOptions),n);let c;return this._sendPromise=this._sendPromise.then(()=>ht(this._apiKey,this.model,l,r)).then(f=>{var g;if(nt(f.response)){this._history.push(p);const C=Object.assign({parts:[],role:"model"},(g=f.response.candidates)===null||g===void 0?void 0:g[0].content);this._history.push(C)}else{const C=O(f.response);C&&console.warn(`sendMessage() was unsuccessful. ${C}. Inspect response object for details.`)}c=f}).catch(f=>{throw this._sendPromise=Promise.resolve(),f}),await this._sendPromise,c}async sendMessageStream(e,n={}){var s,i,o,a,u,d;await this._sendPromise;const p=A(e),l={safetySettings:(s=this.params)===null||s===void 0?void 0:s.safetySettings,generationConfig:(i=this.params)===null||i===void 0?void 0:i.generationConfig,tools:(o=this.params)===null||o===void 0?void 0:o.tools,toolConfig:(a=this.params)===null||a===void 0?void 0:a.toolConfig,systemInstruction:(u=this.params)===null||u===void 0?void 0:u.systemInstruction,cachedContent:(d=this.params)===null||d===void 0?void 0:d.cachedContent,contents:[...this._history,p]},r=Object.assign(Object.assign({},this._requestOptions),n),c=gt(this._apiKey,this.model,l,r);return this._sendPromise=this._sendPromise.then(()=>c).catch(f=>{throw new Error(st)}).then(f=>f.response).then(f=>{if(nt(f)){this._history.push(p);const g=Object.assign({},f.candidates[0].content);g.role||(g.role="model"),this._history.push(g)}else{const g=O(f);g&&console.warn(`sendMessageStream() was unsuccessful. ${g}. Inspect response object for details.`)}}).catch(f=>{f.message!==st&&console.error(f)}),c}}async function _e(t,e,n,s){return(await R(e,v.COUNT_TOKENS,t,!1,JSON.stringify(n),s)).json()}async function Ee(t,e,n,s){return(await R(e,v.EMBED_CONTENT,t,!1,JSON.stringify(n),s)).json()}async function Te(t,e,n,s){const i=n.requests.map(a=>Object.assign(Object.assign({},a),{model:e}));return(await R(e,v.BATCH_EMBED_CONTENTS,t,!1,JSON.stringify({requests:i}),s)).json()}class it{constructor(e,n,s={}){this.apiKey=e,this._requestOptions=s,n.model.includes("/")?this.model=n.model:this.model=`models/${n.model}`,this.generationConfig=n.generationConfig||{},this.safetySettings=n.safetySettings||[],this.tools=n.tools,this.toolConfig=n.toolConfig,this.systemInstruction=mt(n.systemInstruction),this.cachedContent=n.cachedContent}async generateContent(e,n={}){var s;const i=tt(e),o=Object.assign(Object.assign({},this._requestOptions),n);return ht(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(s=this.cachedContent)===null||s===void 0?void 0:s.name},i),o)}async generateContentStream(e,n={}){var s;const i=tt(e),o=Object.assign(Object.assign({},this._requestOptions),n);return gt(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(s=this.cachedContent)===null||s===void 0?void 0:s.name},i),o)}startChat(e){var n;return new ve(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(n=this.cachedContent)===null||n===void 0?void 0:n.name},e),this._requestOptions)}async countTokens(e,n={}){const s=Ce(e,{model:this.model,generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:this.cachedContent}),i=Object.assign(Object.assign({},this._requestOptions),n);return _e(this.apiKey,this.model,s,i)}async embedContent(e,n={}){const s=Oe(e),i=Object.assign(Object.assign({},this._requestOptions),n);return Ee(this.apiKey,this.model,s,i)}async batchEmbedContents(e,n={}){const s=Object.assign(Object.assign({},this._requestOptions),n);return Te(this.apiKey,this.model,e,s)}}class M{constructor(e){this.apiKey=e}getGenerativeModel(e,n){if(!e.model)throw new m("Must provide a model name. Example: genai.getGenerativeModel({ model: 'my-model-name' })");return new it(this.apiKey,e,n)}getGenerativeModelFromCachedContent(e,n,s){if(!e.name)throw new y("Cached content must contain a `name` field.");if(!e.model)throw new y("Cached content must contain a `model` field.");const i=["model","systemInstruction"];for(const a of i)if(n?.[a]&&e[a]&&n?.[a]!==e[a]){if(a==="model"){const u=n.model.startsWith("models/")?n.model.replace("models/",""):n.model,d=e.model.startsWith("models/")?e.model.replace("models/",""):e.model;if(u===d)continue}throw new y(`Different value for "${a}" specified in modelParams (${n[a]}) and cachedContent (${e[a]})`)}const o=Object.assign(Object.assign({},n),{model:e.model,tools:e.tools,toolConfig:e.toolConfig,systemInstruction:e.systemInstruction,cachedContent:e});return new it(this.apiKey,o,s)}}function ot(t,e){const n=we(t);return{tools:n,toolConfig:Ae(n,e)}}function we(t){let e=[];const n=[];return t.forEach(s=>{if(at(s)){const[i]=Jt([s]);i.functionDeclarations&&e.push(...i.functionDeclarations)}else if(rt(s)){const{functionDeclarations:i}=Se(s);if(i)e.push(...i);else throw new Error("Failed to convert OpenAI structured tool to GenerativeAI tool")}else n.push(s)}),n.find(s=>"functionDeclarations"in s)?n.map(s=>{if(e?.length>0&&"functionDeclarations"in s){const i={functionDeclarations:[...s.functionDeclarations||[],...e]};return e=[],i}return s}):[...n,...e.length>0?[{functionDeclarations:e}]:[]]}function Se(t){return{functionDeclarations:[{name:t.function.name,description:t.function.description,parameters:I(t.function.parameters)}]}}function Ae(t,e){if(!t.length||!e)return;const{toolChoice:n,allowedFunctionNames:s}=e,i={any:T.ANY,auto:T.AUTO,none:T.NONE};if(n&&["any","auto","none"].includes(n))return{functionCallingConfig:{mode:i[n]??"MODE_UNSPECIFIED",allowedFunctionNames:s}};if(typeof n=="string"||s)return{functionCallingConfig:{mode:T.ANY,allowedFunctionNames:[...s??[],...n&&typeof n=="string"?[n]:[]]}}}const Re={"gemini-embedding-001":{maxInputTokens:2048,imageInputs:!1,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:3072,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.5-flash-lite-preview-09-2025":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-pro-preview-06-05":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash-preview-04-17":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.5-flash-preview-09-2025":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-pro-preview-05-06":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash-preview-05-20":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-live-2.5-flash":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-3-flash-preview":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-live-2.5-flash-preview-native-audio":{maxInputTokens:131072,imageInputs:!1,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.5-flash-lite":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash-preview-tts":{maxInputTokens:8e3,imageInputs:!1,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:16e3,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-flash-latest":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash-lite-preview-06-17":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.5-flash-image":{maxInputTokens:32768,imageInputs:!0,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:32768,reasoningOutput:!0,imageOutputs:!0,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.5-pro-preview-tts":{maxInputTokens:8e3,imageInputs:!1,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:16e3,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.5-flash-image-preview":{maxInputTokens:32768,imageInputs:!0,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:32768,reasoningOutput:!0,imageOutputs:!0,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-1.5-flash-8b":{maxInputTokens:1e6,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-3-pro-preview":{maxInputTokens:1e6,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:64e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.0-flash-lite":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-1.5-flash":{maxInputTokens:1e6,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-flash-lite-latest":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-pro":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.0-flash":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-1.5-pro":{maxInputTokens:1e6,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1}};var Ne=class extends yt{static lc_name(){return"ChatGoogleGenerativeAI"}lc_serializable=!0;get lc_secrets(){return{apiKey:"GOOGLE_API_KEY"}}lc_namespace=["langchain","chat_models","google_genai"];get lc_aliases(){return{apiKey:"google_api_key"}}model;temperature;maxOutputTokens;topP;topK;stopSequences=[];safetySettings;apiKey;streaming=!1;json;streamUsage=!0;convertSystemMessageToHumanContent;thinkingConfig;client;get _isMultimodalModel(){return this.model.includes("vision")||this.model.startsWith("gemini-1.5")||this.model.startsWith("gemini-2")||this.model.startsWith("gemma-3-")&&!this.model.startsWith("gemma-3-1b")||this.model.startsWith("gemini-3")}constructor(t){if(super(t),this.model=t.model.replace(/^models\//,""),this.maxOutputTokens=t.maxOutputTokens??this.maxOutputTokens,this.maxOutputTokens&&this.maxOutputTokens<0)throw new Error("`maxOutputTokens` must be a positive integer");if(this.temperature=t.temperature??this.temperature,this.temperature&&(this.temperature<0||this.temperature>2))throw new Error("`temperature` must be in the range of [0.0,2.0]");if(this.topP=t.topP??this.topP,this.topP&&this.topP<0)throw new Error("`topP` must be a positive integer");if(this.topP&&this.topP>1)throw new Error("`topP` must be below 1.");if(this.topK=t.topK??this.topK,this.topK&&this.topK<0)throw new Error("`topK` must be a positive integer");if(this.stopSequences=t.stopSequences??this.stopSequences,this.apiKey=t.apiKey??ct("GOOGLE_API_KEY"),!this.apiKey)throw new Error("Please set an API key for Google GenerativeAI in the environment variable GOOGLE_API_KEY or in the `apiKey` field of the ChatGoogleGenerativeAI constructor");if(this.safetySettings=t.safetySettings??this.safetySettings,this.safetySettings&&this.safetySettings.length>0&&new Set(this.safetySettings.map(e=>e.category)).size!==this.safetySettings.length)throw new Error("The categories in `safetySettings` array must be unique");this.streaming=t.streaming??this.streaming,this.json=t.json,this.thinkingConfig=t.thinkingConfig??this.thinkingConfig,this.client=new M(this.apiKey).getGenerativeModel({model:this.model,safetySettings:this.safetySettings,generationConfig:{stopSequences:this.stopSequences,maxOutputTokens:this.maxOutputTokens,temperature:this.temperature,topP:this.topP,topK:this.topK,...this.json?{responseMimeType:"application/json"}:{},...this.thinkingConfig?{thinkingConfig:this.thinkingConfig}:{}}},{apiVersion:t.apiVersion,baseUrl:t.baseUrl,customHeaders:t.customHeaders}),this.streamUsage=t.streamUsage??this.streamUsage}useCachedContent(t,e,n){this.apiKey&&(this.client=new M(this.apiKey).getGenerativeModelFromCachedContent(t,e,n))}get useSystemInstruction(){return typeof this.convertSystemMessageToHumanContent=="boolean"?!this.convertSystemMessageToHumanContent:this.computeUseSystemInstruction}get computeUseSystemInstruction(){return this.model==="gemini-1.0-pro-001"||this.model.startsWith("gemini-pro-vision")||this.model.startsWith("gemini-1.0-pro-vision")?!1:this.model!=="gemini-pro"}getLsParams(t){return{ls_provider:"google_genai",ls_model_name:this.model,ls_model_type:"chat",ls_temperature:this.client.generationConfig.temperature,ls_max_tokens:this.client.generationConfig.maxOutputTokens,ls_stop:t.stop}}_combineLLMOutput(){return[]}_llmType(){return"googlegenerativeai"}bindTools(t,e){return this.withConfig({tools:ot(t)?.tools,...e})}invocationParams(t){const e=t?.tools?.length?ot(t.tools,{toolChoice:t.tool_choice,allowedFunctionNames:t.allowedFunctionNames}):void 0;return t?.responseSchema?(this.client.generationConfig.responseSchema=t.responseSchema,this.client.generationConfig.responseMimeType="application/json"):(this.client.generationConfig.responseSchema=void 0,this.client.generationConfig.responseMimeType=this.json?"application/json":void 0),{...e?.tools?{tools:e.tools}:{},...e?.toolConfig?{toolConfig:e.toolConfig}:{}}}async _generate(t,e,n){e.signal?.throwIfAborted();const s=j(t,this._isMultimodalModel,this.useSystemInstruction,this.model);let i=s;if(s[0].role==="system"){const[p]=s;this.client.systemInstruction=p,i=s.slice(1)}const o=this.invocationParams(e);if(this.streaming){const p={},l=this._streamResponseChunks(t,e,n),r=[];for await(const c of l){const f=c.generationInfo?.completion??0;r[f]===void 0?r[f]=c:r[f]=r[f].concat(c)}return{generations:r.filter(c=>c!==void 0),llmOutput:{estimatedTokenUsage:p}}}const a=await this.completionWithRetry({...o,contents:i});let u;"usageMetadata"in a.response&&(u=K(a.response.usageMetadata,this.model));const d=Vt(a.response,{usageMetadata:u});return d.generations?.length>0&&await n?.handleLLMNewToken(d.generations[0]?.text??""),d}async*_streamResponseChunks(t,e,n){const s=j(t,this._isMultimodalModel,this.useSystemInstruction,this.model);let i=s;if(s[0].role==="system"){const[r]=s;this.client.systemInstruction=r,i=s.slice(1)}const o={...this.invocationParams(e),contents:i},a=await this.caller.callWithOptions({signal:e?.signal},async()=>{const{stream:r}=await this.client.generateContentStream(o,{signal:e?.signal});return r});let u,d=0,p=0,l=0;for await(const r of a){if(e.signal?.aborted)return;if("usageMetadata"in r&&r.usageMetadata!==void 0&&this.streamUsage!==!1&&e.streamUsage!==!1){u=K(r.usageMetadata,this.model);const f=r.usageMetadata.promptTokenCount??0;u.input_tokens=Math.max(0,f-d),d=f;const g=r.usageMetadata.candidatesTokenCount??0;u.output_tokens=Math.max(0,g-p),p=g;const C=r.usageMetadata.totalTokenCount??0;u.total_tokens=Math.max(0,C-l),l=C}const c=Wt(r,{usageMetadata:u});c&&(yield c,await n?.handleLLMNewToken(c.text??""))}}async completionWithRetry(t,e){return this.caller.callWithOptions({signal:e?.signal},async()=>{try{return await this.client.generateContent(t,{signal:e?.signal})}catch(n){throw n.message?.includes("400 Bad Request")&&(n.status=400),n}})}get profile(){return Re[this.model]??{}}withStructuredOutput(t,e){const n=t,s=e?.name,i=e?.method,o=e?.includeRaw;if(i==="jsonMode")throw new Error('ChatGoogleGenerativeAI only supports "jsonSchema" or "functionCalling" as a method.');let a,u;if(i==="functionCalling"){let r=s??"extract",c;if(ut(n)){const f=N(n);c=[{functionDeclarations:[{name:r,description:f.description??"A function available to call.",parameters:f}]}],u=new F({returnSingle:!0,keyName:r,zodSchema:n})}else{let f;typeof n.name=="string"&&typeof n.parameters=="object"&&n.parameters!=null?(f=n,f.parameters=I(n.parameters),r=n.name):f={name:r,description:n.description??"",parameters:I(n)},c=[{functionDeclarations:[f]}],u=new F({returnSingle:!0,keyName:r})}a=this.bindTools(c).withConfig({allowedFunctionNames:[r]})}else{const r=N(n);a=this.withConfig({responseSchema:r}),u=new It}if(!o)return a.pipe(u).withConfig({runName:"ChatGoogleGenerativeAIStructuredOutput"});const d=U.assign({parsed:(r,c)=>u.invoke(r.raw,c)}),p=U.assign({parsed:()=>null}),l=d.withFallbacks({fallbacks:[p]});return bt.from([{raw:a},l]).withConfig({runName:"StructuredOutputRunnable"})}},Me=class extends Nt{apiKey;modelName="embedding-001";model="embedding-001";taskType;title;stripNewLines=!0;maxBatchSize=100;client;constructor(t){if(super(t??{}),this.modelName=t?.model?.replace(/^models\//,"")??t?.modelName?.replace(/^models\//,"")??this.modelName,this.model=this.modelName,this.taskType=t?.taskType??this.taskType,this.title=t?.title??this.title,this.title&&this.taskType!=="RETRIEVAL_DOCUMENT")throw new Error("title can only be sepcified with TaskType.RETRIEVAL_DOCUMENT");if(this.apiKey=t?.apiKey??ct("GOOGLE_API_KEY"),!this.apiKey)throw new Error("Please set an API key for Google GenerativeAI in the environmentb variable GOOGLE_API_KEY or in the `apiKey` field of the GoogleGenerativeAIEmbeddings constructor");this.client=new M(this.apiKey).getGenerativeModel({model:this.model},{baseUrl:t?.baseUrl})}_convertToContent(t){return{content:{role:"user",parts:[{text:this.stripNewLines?t.replace(/\n/g," "):t}]},taskType:this.taskType,title:this.title}}async _embedQueryContent(t){const e=this._convertToContent(t);return(await this.client.embedContent(e)).embedding.values??[]}async _embedDocumentsContent(t){const e=Mt(t,this.maxBatchSize),n=e.map(s=>({requests:s.map(i=>this._convertToContent(i))}));return(await Promise.allSettled(n.map(s=>this.client.batchEmbedContents(s)))).flatMap((s,i)=>s.status==="fulfilled"?s.value.embeddings.map(o=>o.values||[]):Array(e[i].length).fill([]))}embedQuery(t){return this.caller.call(this._embedQueryContent.bind(this),t)}embedDocuments(t){return this.caller.call(this._embedDocumentsContent.bind(this),t)}};export{Ne as ChatGoogleGenerativeAI,Me as GoogleGenerativeAIEmbeddings};
@@ -1,4 +1,4 @@
1
- import{c2 as Zs,dk as Za,dl as x,dm as Ja,cj as Ha,ci as Va,bZ as Me,dn as Xa,c7 as R,b as et,cC as Ga,cP as Ya,c8 as Qa,c4 as Js,c5 as Hs,b$ as Ce,l as bt,dp as ei,c1 as vn,dq as rs,dr as ti,ds as ni,dt as si,c6 as as,du as is,dv as ri,y as ai,c0 as sn,G as ii,d8 as Z,de as xn,dg as te,di as Vs,dh as W,d9 as Mt,df as Q,dw as oi,p as ui,A as li,a as ci}from"./index-DKfT2EtL.js";import{c as pi,j as di,h as hi,f as Xs,S as os,J as us,R as ls,k as fi}from"./index-uEj4g89g.js";import{J as cs,c as mi,p as Gs,m as lt,B as gi}from"./llms-DfKXFwBa.js";import{c as rn,E as _i}from"./embeddings-CnYfeC12.js";import{T as yi,t as zt,D as wi}from"./index-BMhVR8vU.js";function tt(e,t){return e.lc_error_code=t,e.message=`${e.message}
1
+ import{X as Zs,be as Za,bf as x,bg as Ja,ad as Ha,ac as Va,Q as Me,bh as Xa,a1 as R,b as et,aw as Ga,aJ as Ya,a2 as Qa,Z as Js,$ as Hs,U as Ce,l as bt,bi as ei,W as vn,bj as rs,bk as ti,bl as ni,bm as si,a0 as as,bn as is,bo as ri,y as ai,V as sn,G as ii,b2 as Z,b8 as xn,ba as te,bc as Vs,bb as W,b3 as Mt,b9 as Q,bp as oi,p as ui,A as li,a as ci}from"./index-YcAOTRMN.js";import{c as pi,j as di,h as hi,f as Xs,S as os,J as us,R as ls,k as fi}from"./index-DUSfaXA6.js";import{J as cs,c as mi,p as Gs,m as lt,B as gi}from"./llms-CaZsx5qn.js";import{c as rn,E as _i}from"./embeddings-LX6aYruq.js";import{T as yi,t as zt,D as wi}from"./index-Cz7z8sOR.js";function tt(e,t){return e.lc_error_code=t,e.message=`${e.message}
2
2
 
3
3
  Troubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${t}/
4
4
  `,e}function O(e,t,n,s,r){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}function p(e,t,n,s){if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?s:n==="a"?s.call(e):s?s.value:t.get(e)}let Ys=function(){const{crypto:e}=globalThis;if(e?.randomUUID)return Ys=e.randomUUID.bind(e),e.randomUUID();const t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,s=>(+s^n()&15>>+s/4).toString(16))};function an(e){return typeof e=="object"&&e!==null&&("name"in e&&e.name==="AbortError"||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}const on=e=>{if(e instanceof Error)return e;if(typeof e=="object"&&e!==null){try{if(Object.prototype.toString.call(e)==="[object Error]"){const t=new Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return new Error(JSON.stringify(e))}catch{}}return new Error(e)};class A extends Error{}class q extends A{constructor(t,n,s,r){super(`${q.makeMessage(t,n,s)}`),this.status=t,this.headers=r,this.requestID=r?.get("x-request-id"),this.error=n;const a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(t,n,s){const r=n?.message?typeof n.message=="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):s;return t&&r?`${t} ${r}`:t?`${t} status code (no body)`:r||"(no status code or body)"}static generate(t,n,s,r){if(!t||!r)return new Ut({message:s,cause:on(n)});const a=n?.error;return t===400?new Qs(t,a,s,r):t===401?new er(t,a,s,r):t===403?new tr(t,a,s,r):t===404?new nr(t,a,s,r):t===409?new sr(t,a,s,r):t===422?new rr(t,a,s,r):t===429?new ar(t,a,s,r):t>=500?new ir(t,a,s,r):new q(t,a,s,r)}}class ee extends q{constructor({message:t}={}){super(void 0,void 0,t||"Request was aborted.",void 0)}}class Ut extends q{constructor({message:t,cause:n}){super(void 0,void 0,t||"Connection error.",void 0),n&&(this.cause=n)}}class Lt extends Ut{constructor({message:t}={}){super({message:t??"Request timed out."})}}class Qs extends q{}class er extends q{}class tr extends q{}class nr extends q{}class sr extends q{}class rr extends q{}class ar extends q{}class ir extends q{}class or extends A{constructor(){super("Could not parse response content as the length limit was reached")}}class ur extends A{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}class ze extends Error{constructor(t){super(t)}}const bi=/^[a-z][a-z0-9+.-]*:/i,Ai=e=>bi.test(e);let V=e=>(V=Array.isArray,V(e)),ps=V;function lr(e){return typeof e!="object"?{}:e??{}}function Ii(e){if(!e)return!0;for(const t in e)return!1;return!0}function Oi(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ct(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}const vi=(e,t)=>{if(typeof t!="number"||!Number.isInteger(t))throw new A(`${e} must be an integer`);if(t<0)throw new A(`${e} must be a positive integer`);return t},xi=e=>{try{return JSON.parse(e)}catch{return}},Ve=e=>new Promise(t=>setTimeout(t,e)),ve="6.17.0",ki=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function Ti(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}const Ci=()=>{const e=Ti();if(e==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"X-Stainless-OS":hs(Deno.build.os),"X-Stainless-Arch":ds(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(e==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"X-Stainless-OS":hs(globalThis.process.platform??"unknown"),"X-Stainless-Arch":ds(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const t=Si();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function Si(){if(typeof navigator>"u"||!navigator)return null;const e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:t,pattern:n}of e){const s=n.exec(navigator.userAgent);if(s){const r=s[1]||0,a=s[2]||0,i=s[3]||0;return{browser:t,version:`${r}.${a}.${i}`}}}return null}const ds=e=>e==="x32"?"x32":e==="x86_64"||e==="x64"?"x64":e==="arm"?"arm":e==="aarch64"||e==="arm64"?"arm64":e?`other:${e}`:"unknown",hs=e=>(e=e.toLowerCase(),e.includes("ios")?"iOS":e==="android"?"Android":e==="darwin"?"MacOS":e==="win32"?"Windows":e==="freebsd"?"FreeBSD":e==="openbsd"?"OpenBSD":e==="linux"?"Linux":e?`Other:${e}`:"Unknown");let fs;const Pi=()=>fs??(fs=Ci());function Ri(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function cr(...e){const t=globalThis.ReadableStream;if(typeof t>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function pr(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return cr({start(){},async pull(n){const{done:s,value:r}=await t.next();s?n.close():n.enqueue(r)},async cancel(){await t.return?.()}})}function dr(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const n=await t.read();return n?.done&&t.releaseLock(),n}catch(n){throw t.releaseLock(),n}},async return(){const n=t.cancel();return t.releaseLock(),await n,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function Ei(e){if(e===null||typeof e!="object")return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}const t=e.getReader(),n=t.cancel();t.releaseLock(),await n}const $i=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)}),hr="RFC3986",fr=e=>String(e),ms={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:fr},Ni="RFC1738";let un=(e,t)=>(un=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),un(e,t));const ae=(()=>{const e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})(),Vt=1024,Mi=(e,t,n,s,r)=>{if(e.length===0)return e;let a=e;if(typeof e=="symbol"?a=Symbol.prototype.toString.call(e):typeof e!="string"&&(a=String(e)),n==="iso-8859-1")return escape(a).replace(/%u[0-9a-f]{4}/gi,function(o){return"%26%23"+parseInt(o.slice(2),16)+"%3B"});let i="";for(let o=0;o<a.length;o+=Vt){const l=a.length>=Vt?a.slice(o,o+Vt):a,u=[];for(let m=0;m<l.length;++m){let d=l.charCodeAt(m);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||r===Ni&&(d===40||d===41)){u[u.length]=l.charAt(m);continue}if(d<128){u[u.length]=ae[d];continue}if(d<2048){u[u.length]=ae[192|d>>6]+ae[128|d&63];continue}if(d<55296||d>=57344){u[u.length]=ae[224|d>>12]+ae[128|d>>6&63]+ae[128|d&63];continue}m+=1,d=65536+((d&1023)<<10|l.charCodeAt(m)&1023),u[u.length]=ae[240|d>>18]+ae[128|d>>12&63]+ae[128|d>>6&63]+ae[128|d&63]}i+=u.join("")}return i};function zi(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function gs(e,t){if(V(e)){const n=[];for(let s=0;s<e.length;s+=1)n.push(t(e[s]));return n}return t(e)}const mr={brackets(e){return String(e)+"[]"},comma:"comma",indices(e,t){return String(e)+"["+t+"]"},repeat(e){return String(e)}},gr=function(e,t){Array.prototype.push.apply(e,V(t)?t:[t])};let _s;const U={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Mi,encodeValuesOnly:!1,format:hr,formatter:fr,indices:!1,serializeDate(e){return(_s??(_s=Function.prototype.call.bind(Date.prototype.toISOString)))(e)},skipNulls:!1,strictNullHandling:!1};function Ui(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"}const Xt={};function _r(e,t,n,s,r,a,i,o,l,u,m,d,f,c,w,b,C,h){let g=e,k=h,S=0,J=!1;for(;(k=k.get(Xt))!==void 0&&!J;){const $=k.get(e);if(S+=1,typeof $<"u"){if($===S)throw new RangeError("Cyclic object value");J=!0}typeof k.get(Xt)>"u"&&(S=0)}if(typeof u=="function"?g=u(t,g):g instanceof Date?g=f?.(g):n==="comma"&&V(g)&&(g=gs(g,function($){return $ instanceof Date?f?.($):$})),g===null){if(a)return l&&!b?l(t,U.encoder,C,"key",c):t;g=""}if(Ui(g)||zi(g)){if(l){const $=b?t:l(t,U.encoder,C,"key",c);return[w?.($)+"="+w?.(l(g,U.encoder,C,"value",c))]}return[w?.(t)+"="+w?.(String(g))]}const L=[];if(typeof g>"u")return L;let E;if(n==="comma"&&V(g))b&&l&&(g=gs(g,l)),E=[{value:g.length>0?g.join(",")||null:void 0}];else if(V(u))E=u;else{const $=Object.keys(g);E=m?$.sort(m):$}const B=o?String(t).replace(/\./g,"%2E"):String(t),D=s&&V(g)&&g.length===1?B+"[]":B;if(r&&V(g)&&g.length===0)return D+"[]";for(let $=0;$<E.length;++$){const M=E[$],ns=typeof M=="object"&&typeof M.value<"u"?M.value:g[M];if(i&&ns===null)continue;const Ht=d&&o?M.replace(/\./g,"%2E"):M,Wa=V(g)?typeof n=="function"?n(D,Ht):D:D+(d?"."+Ht:"["+Ht+"]");h.set(e,S);const ss=new WeakMap;ss.set(Xt,h),gr(L,_r(ns,Wa,n,s,r,a,i,o,n==="comma"&&b&&V(g)?null:l,u,m,d,f,c,w,b,C,ss))}return L}function Li(e=U){if(typeof e.allowEmptyArrays<"u"&&typeof e.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof e.encodeDotInKeys<"u"&&typeof e.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(e.encoder!==null&&typeof e.encoder<"u"&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");const t=e.charset||U.charset;if(typeof e.charset<"u"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let n=hr;if(typeof e.format<"u"){if(!un(ms,e.format))throw new TypeError("Unknown format option provided.");n=e.format}const s=ms[n];let r=U.filter;(typeof e.filter=="function"||V(e.filter))&&(r=e.filter);let a;if(e.arrayFormat&&e.arrayFormat in mr?a=e.arrayFormat:"indices"in e?a=e.indices?"indices":"repeat":a=U.arrayFormat,"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");const i=typeof e.allowDots>"u"?e.encodeDotInKeys?!0:U.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:U.addQueryPrefix,allowDots:i,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:U.allowEmptyArrays,arrayFormat:a,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:U.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:typeof e.delimiter>"u"?U.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:U.encode,encodeDotInKeys:typeof e.encodeDotInKeys=="boolean"?e.encodeDotInKeys:U.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:U.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:U.encodeValuesOnly,filter:r,format:n,formatter:s,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:U.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:U.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:U.strictNullHandling}}function Di(e,t={}){let n=e;const s=Li(t);let r,a;typeof s.filter=="function"?(a=s.filter,n=a("",n)):V(s.filter)&&(a=s.filter,r=a);const i=[];if(typeof n!="object"||n===null)return"";const o=mr[s.arrayFormat],l=o==="comma"&&s.commaRoundTrip;r||(r=Object.keys(n)),s.sort&&r.sort(s.sort);const u=new WeakMap;for(let f=0;f<r.length;++f){const c=r[f];s.skipNulls&&n[c]===null||gr(i,_r(n[c],c,o,l,s.allowEmptyArrays,s.strictNullHandling,s.skipNulls,s.encodeDotInKeys,s.encode?s.encoder:null,s.filter,s.sort,s.allowDots,s.serializeDate,s.format,s.formatter,s.encodeValuesOnly,s.charset,u))}const m=i.join(s.delimiter);let d=s.addQueryPrefix===!0?"?":"";return s.charsetSentinel&&(s.charset==="iso-8859-1"?d+="utf8=%26%2310003%3B&":d+="utf8=%E2%9C%93&"),m.length>0?d+m:""}function ji(e){let t=0;for(const r of e)t+=r.length;const n=new Uint8Array(t);let s=0;for(const r of e)n.set(r,s),s+=r.length;return n}let ys;function kn(e){let t;return(ys??(t=new globalThis.TextEncoder,ys=t.encode.bind(t)))(e)}let ws;function bs(e){let t;return(ws??(t=new globalThis.TextDecoder,ws=t.decode.bind(t)))(e)}var X,G;class Dt{constructor(){X.set(this,void 0),G.set(this,void 0),O(this,X,new Uint8Array),O(this,G,null)}decode(t){if(t==null)return[];const n=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?kn(t):t;O(this,X,ji([p(this,X,"f"),n]));const s=[];let r;for(;(r=Bi(p(this,X,"f"),p(this,G,"f")))!=null;){if(r.carriage&&p(this,G,"f")==null){O(this,G,r.index);continue}if(p(this,G,"f")!=null&&(r.index!==p(this,G,"f")+1||r.carriage)){s.push(bs(p(this,X,"f").subarray(0,p(this,G,"f")-1))),O(this,X,p(this,X,"f").subarray(p(this,G,"f"))),O(this,G,null);continue}const a=p(this,G,"f")!==null?r.preceding-1:r.preceding,i=bs(p(this,X,"f").subarray(0,a));s.push(i),O(this,X,p(this,X,"f").subarray(r.index)),O(this,G,null)}return s}flush(){return p(this,X,"f").length?this.decode(`
@@ -1,4 +1,4 @@
1
- import{g as Ss,O as jt,h as ks,c as qt,f as Ts,J as Ms,S as vs,R as Dt}from"./index-uEj4g89g.js";import{x as Os,d8 as y,d9 as Wt,da as Is,db as As,dc as Ft,c6 as kn,b$ as ve,cG as Ht,c4 as Rs,c5 as Cs,c1 as N,c7 as Ps,b as ot,bZ as ie,c0 as Es,c8 as Ns,dd as Us,de as tt,df as b,dg as w,dh as E,di as Bs,dj as At}from"./index-DKfT2EtL.js";import{t as Ie}from"./index-BMhVR8vU.js";var Jt=class extends Ss{static lc_name(){return"AnthropicToolsOutputParser"}lc_namespace=["langchain","anthropic","output_parsers"];returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(t){super(t),this.keyName=t.keyName,this.returnSingle=t.returnSingle??this.returnSingle,this.zodSchema=t.zodSchema}async _validateResult(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(r){throw new jt(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(r.message)}`,t)}else e=t;if(this.zodSchema===void 0)return e;const n=await Os(this.zodSchema,e);if(n.success)return n.data;throw new jt(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(n.error.issues)}`,JSON.stringify(e,null,2))}async parseResult(t){const e=t.flatMap(s=>{const{message:a}=s;return Array.isArray(a.content)?Tn(a.content)[0]:[]});if(e[0]===void 0)throw new Error("No parseable tool calls provided to AnthropicToolsOutputParser.");const[n]=e;return await this._validateResult(n.args)}};function Tn(t){const e=[];for(const n of t)n.type==="tool_use"&&e.push({name:n.name,args:n.input,id:n.id,type:"tool_call"});return e}function $s(t){if(t)return t==="any"?{type:"any"}:t==="auto"?{type:"auto"}:t==="none"?{type:"none"}:typeof t=="string"?{type:"tool",name:t}:t}const Ls=y({cache_control:As().optional().nullable(),defer_loading:Is().optional(),input_examples:Wt(Ft()).optional(),allowed_callers:Wt(Ft()).optional()}),Kt={tool_search_tool_regex_20251119:"advanced-tool-use-2025-11-20",tool_search_tool_bm25_20251119:"advanced-tool-use-2025-11-20",memory_20250818:"context-management-2025-06-27",web_fetch_20250910:"web-fetch-2025-09-10",code_execution_20250825:"code-execution-2025-08-25",computer_20251124:"computer-use-2025-11-24",computer_20250124:"computer-use-2025-01-24",mcp_toolset:"mcp-client-2025-11-20"};function js(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="thinking"}function qs(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="redacted_thinking"}function Ds(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="search_result"}function Ws(t){return typeof t!="object"||t==null||!("type"in t)||t.type!=="image"||!("source"in t)||typeof t.source!="object"||t.source==null||!("type"in t.source)?!1:t.source.type==="base64"?!(!("media_type"in t.source)||typeof t.source.media_type!="string"||!("data"in t.source)||typeof t.source.data!="string"):t.source.type==="url"?!(!("url"in t.source)||typeof t.source.url!="string"):!1}const Fs={providerName:"anthropic",fromStandardTextBlock(t){return{type:"text",text:t.text,..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}}},fromStandardImageBlock(t){if(t.source_type==="url"){const e=kn({dataUrl:t.url,asTypedArray:!1});return e?{type:"image",source:{type:"base64",data:e.data,media_type:e.mime_type},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}}:{type:"image",source:{type:"url",url:t.url},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}}}else{if(t.source_type==="base64")return{type:"image",source:{type:"base64",data:t.data,media_type:t.mime_type??""},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}};throw new Error(`Unsupported image source type: ${t.source_type}`)}},fromStandardFileBlock(t){const e=(t.mime_type??"").split(";")[0];if(t.source_type==="url"){if(e==="application/pdf"||e==="")return{type:"document",source:{type:"url",url:t.url},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};throw new Error(`Unsupported file mime type for file url source: ${t.mime_type}`)}else if(t.source_type==="text"){if(e==="text/plain"||e==="")return{type:"document",source:{type:"text",data:t.text,media_type:t.mime_type??""},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};throw new Error(`Unsupported file mime type for file text source: ${t.mime_type}`)}else if(t.source_type==="base64"){if(e==="application/pdf"||e==="")return{type:"document",source:{type:"base64",data:t.data,media_type:"application/pdf"},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};if(["image/jpeg","image/png","image/gif","image/webp"].includes(e))return{type:"document",source:{type:"content",content:[{type:"image",source:{type:"base64",data:t.data,media_type:e}}]},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};throw new Error(`Unsupported file mime type for file base64 source: ${t.mime_type}`)}else throw new Error(`Unsupported file source type: ${t.source_type}`)}},Hs=t=>t();function Js(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="citation"}function Ks(t){function*e(){for(const n of t)Js(n)&&(n.source==="char"?yield{type:"char_location",file_id:n.url??"",start_char_index:n.startIndex??0,end_char_index:n.endIndex??0,document_title:n.title??null,document_index:0,cited_text:n.citedText??""}:n.source==="page"?yield{type:"page_location",file_id:n.url??"",start_page_number:n.startIndex??0,end_page_number:n.endIndex??0,document_title:n.title??null,document_index:0,cited_text:n.citedText??""}:n.source==="block"?yield{type:"content_block_location",file_id:n.url??"",start_block_index:n.startIndex??0,end_block_index:n.endIndex??0,document_title:n.title??null,document_index:0,cited_text:n.citedText??""}:n.source==="url"?yield{type:"web_search_result_location",url:n.url??"",title:n.title??null,encrypted_index:String(n.startIndex??0),cited_text:n.citedText??""}:n.source==="search"&&(yield{type:"search_result_location",title:n.title??null,start_block_index:n.startIndex??0,end_block_index:n.endIndex??0,search_result_index:0,source:n.source??"",cited_text:n.citedText??""}))}return Array.from(e())}function oe(t){return typeof t=="string"?t:Xs(t)}function Xs(t){const e=[];for(let n=0,{length:r}=t;n<r;n++)e.push(String.fromCharCode(t[n]));return btoa(e.join(""))}function ct(t){return(t??"").split(";")[0].toLowerCase()}function ke(t,e){if(t!=null&&typeof t=="object"&&e in t)return t[e]}function Z(t,e){const n=ke(e,"cache_control");n!==void 0&&(t.cache_control=n);const r=ke(e,"citations");r!==void 0&&(t.citations=r);const s=ke(e,"context");s!==void 0&&(t.context=s);const a=ke(e,"title");return a!==void 0&&(t.title=a),t}function ut(t,e){const n=ke(e,"cache_control");return n!==void 0&&(t.cache_control=n),t}function Xt(t){return new Set(["image/jpeg","image/png","image/gif","image/webp"]).has(t)}function zs(t){const e=[],n=t.response_metadata,r="model_provider"in n&&n?.model_provider==="anthropic";for(const s of t.contentBlocks)if(s.type==="text")s.annotations?e.push({type:"text",text:s.text,citations:Ks(s.annotations)}):e.push({type:"text",text:s.text});else if(s.type==="tool_call")e.push({type:"tool_use",id:s.id??"",name:s.name,input:s.args});else if(s.type==="tool_call_chunk"){const a=Hs(()=>{if(typeof s.args!="string")return s.args;try{return JSON.parse(s.args)}catch{return{}}});e.push({type:"tool_use",id:s.id??"",name:s.name??"",input:a})}else if(s.type==="reasoning"&&r)e.push({type:"thinking",thinking:s.reasoning,signature:String(s.signature)});else if(s.type==="server_tool_call"&&r)s.name==="web_search"?e.push({type:"server_tool_use",name:s.name,id:s.id??"",input:s.args}):s.name==="code_execution"&&e.push({type:"server_tool_use",name:s.name,id:s.id??"",input:s.args});else if(s.type==="server_tool_call_result"&&r)if(s.name==="web_search"&&Array.isArray(s.output.urls)){const a=s.output.urls.map(i=>({type:"web_search_result",title:"",encrypted_content:"",url:i}));e.push({type:"web_search_tool_result",tool_use_id:s.toolCallId??"",content:a})}else s.name==="code_execution"?e.push({type:"code_execution_tool_result",tool_use_id:s.toolCallId??"",content:s.output}):s.name==="mcp_tool_result"&&e.push({type:"mcp_tool_result",tool_use_id:s.toolCallId??"",content:s.output});else{if(s.type==="audio")throw new Error("Anthropic does not support audio content blocks.");if(s.type==="file"){const a=s.metadata;if(s.fileId){e.push(Z({type:"document",source:{type:"file",file_id:s.fileId}},a));continue}if(s.url){const i=ct(s.mimeType);if(i==="application/pdf"||i===""){e.push(Z({type:"document",source:{type:"url",url:s.url}},a));continue}}if(s.data){const i=ct(s.mimeType);if(i===""||i==="application/pdf")e.push(Z({type:"document",source:{type:"base64",data:oe(s.data),media_type:"application/pdf"}},a));else if(i==="text/plain")e.push(Z({type:"document",source:{type:"text",data:oe(s.data),media_type:"text/plain"}},a));else if(Xt(i))e.push(Z({type:"document",source:{type:"content",content:[{type:"image",source:{type:"base64",data:oe(s.data),media_type:i}}]}},a));else throw new Error(`Unsupported file mime type for Anthropic base64 source: ${i}`);continue}throw new Error("File content block must include a fileId, url, or data property.")}else if(s.type==="image"){const a=s.metadata;if(s.fileId){e.push(ut({type:"image",source:{type:"file",file_id:s.fileId}},a));continue}if(s.url){e.push(ut({type:"image",source:{type:"url",url:s.url}},a));continue}if(s.data){const i=ct(s.mimeType)||"image/png";Xt(i)&&e.push(ut({type:"image",source:{type:"base64",data:oe(s.data),media_type:i}},a));continue}throw new Error("Image content block must include a fileId, url, or data property.")}else s.type==="video"||(s.type==="text-plain"?s.data&&e.push(Z({type:"document",source:{type:"text",data:oe(s.data),media_type:"text/plain"}},s.metadata)):s.type==="non_standard"&&r&&e.push(s.value))}return e}function lt(t){const e=kn({dataUrl:t});if(e)return{type:"base64",media_type:e.mime_type,data:e.data};let n;try{n=new URL(t)}catch{throw new Error([`Malformed image URL: ${JSON.stringify(t)}. Content blocks of type 'image_url' must be a valid http, https, or base64-encoded data URL.`,"Example: data:image/png;base64,/9j/4AAQSk...","Example: https://example.com/image.jpg"].join(`
1
+ import{g as Ss,O as jt,h as ks,c as qt,f as Ts,J as Ms,S as vs,R as Dt}from"./index-DUSfaXA6.js";import{x as Os,b2 as y,b3 as Wt,b4 as Is,b5 as As,b6 as Ft,a0 as kn,U as ve,aA as Ht,Z as Rs,$ as Cs,W as N,a1 as Ps,b as ot,Q as ie,V as Es,a2 as Ns,b7 as Us,b8 as tt,b9 as b,ba as w,bb as E,bc as Bs,bd as At}from"./index-YcAOTRMN.js";import{t as Ie}from"./index-Cz7z8sOR.js";var Jt=class extends Ss{static lc_name(){return"AnthropicToolsOutputParser"}lc_namespace=["langchain","anthropic","output_parsers"];returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(t){super(t),this.keyName=t.keyName,this.returnSingle=t.returnSingle??this.returnSingle,this.zodSchema=t.zodSchema}async _validateResult(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(r){throw new jt(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(r.message)}`,t)}else e=t;if(this.zodSchema===void 0)return e;const n=await Os(this.zodSchema,e);if(n.success)return n.data;throw new jt(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(n.error.issues)}`,JSON.stringify(e,null,2))}async parseResult(t){const e=t.flatMap(s=>{const{message:a}=s;return Array.isArray(a.content)?Tn(a.content)[0]:[]});if(e[0]===void 0)throw new Error("No parseable tool calls provided to AnthropicToolsOutputParser.");const[n]=e;return await this._validateResult(n.args)}};function Tn(t){const e=[];for(const n of t)n.type==="tool_use"&&e.push({name:n.name,args:n.input,id:n.id,type:"tool_call"});return e}function $s(t){if(t)return t==="any"?{type:"any"}:t==="auto"?{type:"auto"}:t==="none"?{type:"none"}:typeof t=="string"?{type:"tool",name:t}:t}const Ls=y({cache_control:As().optional().nullable(),defer_loading:Is().optional(),input_examples:Wt(Ft()).optional(),allowed_callers:Wt(Ft()).optional()}),Kt={tool_search_tool_regex_20251119:"advanced-tool-use-2025-11-20",tool_search_tool_bm25_20251119:"advanced-tool-use-2025-11-20",memory_20250818:"context-management-2025-06-27",web_fetch_20250910:"web-fetch-2025-09-10",code_execution_20250825:"code-execution-2025-08-25",computer_20251124:"computer-use-2025-11-24",computer_20250124:"computer-use-2025-01-24",mcp_toolset:"mcp-client-2025-11-20"};function js(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="thinking"}function qs(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="redacted_thinking"}function Ds(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="search_result"}function Ws(t){return typeof t!="object"||t==null||!("type"in t)||t.type!=="image"||!("source"in t)||typeof t.source!="object"||t.source==null||!("type"in t.source)?!1:t.source.type==="base64"?!(!("media_type"in t.source)||typeof t.source.media_type!="string"||!("data"in t.source)||typeof t.source.data!="string"):t.source.type==="url"?!(!("url"in t.source)||typeof t.source.url!="string"):!1}const Fs={providerName:"anthropic",fromStandardTextBlock(t){return{type:"text",text:t.text,..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}}},fromStandardImageBlock(t){if(t.source_type==="url"){const e=kn({dataUrl:t.url,asTypedArray:!1});return e?{type:"image",source:{type:"base64",data:e.data,media_type:e.mime_type},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}}:{type:"image",source:{type:"url",url:t.url},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}}}else{if(t.source_type==="base64")return{type:"image",source:{type:"base64",data:t.data,media_type:t.mime_type??""},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{}};throw new Error(`Unsupported image source type: ${t.source_type}`)}},fromStandardFileBlock(t){const e=(t.mime_type??"").split(";")[0];if(t.source_type==="url"){if(e==="application/pdf"||e==="")return{type:"document",source:{type:"url",url:t.url},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};throw new Error(`Unsupported file mime type for file url source: ${t.mime_type}`)}else if(t.source_type==="text"){if(e==="text/plain"||e==="")return{type:"document",source:{type:"text",data:t.text,media_type:t.mime_type??""},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};throw new Error(`Unsupported file mime type for file text source: ${t.mime_type}`)}else if(t.source_type==="base64"){if(e==="application/pdf"||e==="")return{type:"document",source:{type:"base64",data:t.data,media_type:"application/pdf"},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};if(["image/jpeg","image/png","image/gif","image/webp"].includes(e))return{type:"document",source:{type:"content",content:[{type:"image",source:{type:"base64",data:t.data,media_type:e}}]},..."cache_control"in(t.metadata??{})?{cache_control:t.metadata.cache_control}:{},..."citations"in(t.metadata??{})?{citations:t.metadata.citations}:{},..."context"in(t.metadata??{})?{context:t.metadata.context}:{},..."title"in(t.metadata??{})?{title:t.metadata.title}:{}};throw new Error(`Unsupported file mime type for file base64 source: ${t.mime_type}`)}else throw new Error(`Unsupported file source type: ${t.source_type}`)}},Hs=t=>t();function Js(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="citation"}function Ks(t){function*e(){for(const n of t)Js(n)&&(n.source==="char"?yield{type:"char_location",file_id:n.url??"",start_char_index:n.startIndex??0,end_char_index:n.endIndex??0,document_title:n.title??null,document_index:0,cited_text:n.citedText??""}:n.source==="page"?yield{type:"page_location",file_id:n.url??"",start_page_number:n.startIndex??0,end_page_number:n.endIndex??0,document_title:n.title??null,document_index:0,cited_text:n.citedText??""}:n.source==="block"?yield{type:"content_block_location",file_id:n.url??"",start_block_index:n.startIndex??0,end_block_index:n.endIndex??0,document_title:n.title??null,document_index:0,cited_text:n.citedText??""}:n.source==="url"?yield{type:"web_search_result_location",url:n.url??"",title:n.title??null,encrypted_index:String(n.startIndex??0),cited_text:n.citedText??""}:n.source==="search"&&(yield{type:"search_result_location",title:n.title??null,start_block_index:n.startIndex??0,end_block_index:n.endIndex??0,search_result_index:0,source:n.source??"",cited_text:n.citedText??""}))}return Array.from(e())}function oe(t){return typeof t=="string"?t:Xs(t)}function Xs(t){const e=[];for(let n=0,{length:r}=t;n<r;n++)e.push(String.fromCharCode(t[n]));return btoa(e.join(""))}function ct(t){return(t??"").split(";")[0].toLowerCase()}function ke(t,e){if(t!=null&&typeof t=="object"&&e in t)return t[e]}function Z(t,e){const n=ke(e,"cache_control");n!==void 0&&(t.cache_control=n);const r=ke(e,"citations");r!==void 0&&(t.citations=r);const s=ke(e,"context");s!==void 0&&(t.context=s);const a=ke(e,"title");return a!==void 0&&(t.title=a),t}function ut(t,e){const n=ke(e,"cache_control");return n!==void 0&&(t.cache_control=n),t}function Xt(t){return new Set(["image/jpeg","image/png","image/gif","image/webp"]).has(t)}function zs(t){const e=[],n=t.response_metadata,r="model_provider"in n&&n?.model_provider==="anthropic";for(const s of t.contentBlocks)if(s.type==="text")s.annotations?e.push({type:"text",text:s.text,citations:Ks(s.annotations)}):e.push({type:"text",text:s.text});else if(s.type==="tool_call")e.push({type:"tool_use",id:s.id??"",name:s.name,input:s.args});else if(s.type==="tool_call_chunk"){const a=Hs(()=>{if(typeof s.args!="string")return s.args;try{return JSON.parse(s.args)}catch{return{}}});e.push({type:"tool_use",id:s.id??"",name:s.name??"",input:a})}else if(s.type==="reasoning"&&r)e.push({type:"thinking",thinking:s.reasoning,signature:String(s.signature)});else if(s.type==="server_tool_call"&&r)s.name==="web_search"?e.push({type:"server_tool_use",name:s.name,id:s.id??"",input:s.args}):s.name==="code_execution"&&e.push({type:"server_tool_use",name:s.name,id:s.id??"",input:s.args});else if(s.type==="server_tool_call_result"&&r)if(s.name==="web_search"&&Array.isArray(s.output.urls)){const a=s.output.urls.map(i=>({type:"web_search_result",title:"",encrypted_content:"",url:i}));e.push({type:"web_search_tool_result",tool_use_id:s.toolCallId??"",content:a})}else s.name==="code_execution"?e.push({type:"code_execution_tool_result",tool_use_id:s.toolCallId??"",content:s.output}):s.name==="mcp_tool_result"&&e.push({type:"mcp_tool_result",tool_use_id:s.toolCallId??"",content:s.output});else{if(s.type==="audio")throw new Error("Anthropic does not support audio content blocks.");if(s.type==="file"){const a=s.metadata;if(s.fileId){e.push(Z({type:"document",source:{type:"file",file_id:s.fileId}},a));continue}if(s.url){const i=ct(s.mimeType);if(i==="application/pdf"||i===""){e.push(Z({type:"document",source:{type:"url",url:s.url}},a));continue}}if(s.data){const i=ct(s.mimeType);if(i===""||i==="application/pdf")e.push(Z({type:"document",source:{type:"base64",data:oe(s.data),media_type:"application/pdf"}},a));else if(i==="text/plain")e.push(Z({type:"document",source:{type:"text",data:oe(s.data),media_type:"text/plain"}},a));else if(Xt(i))e.push(Z({type:"document",source:{type:"content",content:[{type:"image",source:{type:"base64",data:oe(s.data),media_type:i}}]}},a));else throw new Error(`Unsupported file mime type for Anthropic base64 source: ${i}`);continue}throw new Error("File content block must include a fileId, url, or data property.")}else if(s.type==="image"){const a=s.metadata;if(s.fileId){e.push(ut({type:"image",source:{type:"file",file_id:s.fileId}},a));continue}if(s.url){e.push(ut({type:"image",source:{type:"url",url:s.url}},a));continue}if(s.data){const i=ct(s.mimeType)||"image/png";Xt(i)&&e.push(ut({type:"image",source:{type:"base64",data:oe(s.data),media_type:i}},a));continue}throw new Error("Image content block must include a fileId, url, or data property.")}else s.type==="video"||(s.type==="text-plain"?s.data&&e.push(Z({type:"document",source:{type:"text",data:oe(s.data),media_type:"text/plain"}},s.metadata)):s.type==="non_standard"&&r&&e.push(s.value))}return e}function lt(t){const e=kn({dataUrl:t});if(e)return{type:"base64",media_type:e.mime_type,data:e.data};let n;try{n=new URL(t)}catch{throw new Error([`Malformed image URL: ${JSON.stringify(t)}. Content blocks of type 'image_url' must be a valid http, https, or base64-encoded data URL.`,"Example: data:image/png;base64,/9j/4AAQSk...","Example: https://example.com/image.jpg"].join(`
2
2
 
3
3
  `))}if(n.protocol==="http:"||n.protocol==="https:")return{type:"url",url:t};throw new Error([`Invalid image URL protocol: ${JSON.stringify(n.protocol)}. Anthropic only supports images as http, https, or base64-encoded data URLs on 'image_url' content blocks.`,"Example: data:image/png;base64,/9j/4AAQSk...","Example: https://example.com/image.jpg"].join(`
4
4
 
@@ -1,4 +1,4 @@
1
- import{o as E,s as x,i as P,v as $,p as S,A as b,a as C,e as N,m as O,_ as g,b as A,c as I,d as L,f as J,T as f,g as F,C as R,h as M,j as y,k as B,l as _,n as j,q as Z}from"./index-DKfT2EtL.js";import{B as W,i as q,a as H,b as K,c as V}from"./index-uEj4g89g.js";var z={};j(z,{BaseToolkit:()=>G,DynamicStructuredTool:()=>k,DynamicTool:()=>D,StructuredTool:()=>T,Tool:()=>w,ToolInputParsingException:()=>f,isLangChainTool:()=>V,isRunnableToolLike:()=>K,isStructuredTool:()=>H,isStructuredToolParams:()=>q,tool:()=>Q});var T=class extends W{extras;returnDirect=!1;verboseParsingErrors=!1;get lc_namespace(){return["langchain","tools"]}responseFormat="content";defaultConfig;constructor(t){super(t??{}),this.verboseParsingErrors=t?.verboseParsingErrors??this.verboseParsingErrors,this.responseFormat=t?.responseFormat??this.responseFormat,this.defaultConfig=t?.defaultConfig??this.defaultConfig,this.metadata=t?.metadata??this.metadata,this.extras=t?.extras??this.extras}async invoke(t,e){let a,s=N(O(this.defaultConfig,e));return g(t)?(a=t.args,s={...s,toolCall:t}):a=t,this.call(a,s)}async call(t,e,a){const s=g(t)?t.args:t;let u;if(A(this.schema))try{u=await I(this.schema,s)}catch(c){let o="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(o=`${o}
1
+ import{o as E,s as x,i as P,v as $,p as S,A as b,a as C,e as N,m as O,_ as g,b as A,c as I,d as L,f as J,T as f,g as F,C as R,h as M,j as y,k as B,l as _,n as j,q as Z}from"./index-YcAOTRMN.js";import{B as W,i as q,a as H,b as K,c as V}from"./index-DUSfaXA6.js";var z={};j(z,{BaseToolkit:()=>G,DynamicStructuredTool:()=>k,DynamicTool:()=>D,StructuredTool:()=>T,Tool:()=>w,ToolInputParsingException:()=>f,isLangChainTool:()=>V,isRunnableToolLike:()=>K,isStructuredTool:()=>H,isStructuredToolParams:()=>q,tool:()=>Q});var T=class extends W{extras;returnDirect=!1;verboseParsingErrors=!1;get lc_namespace(){return["langchain","tools"]}responseFormat="content";defaultConfig;constructor(t){super(t??{}),this.verboseParsingErrors=t?.verboseParsingErrors??this.verboseParsingErrors,this.responseFormat=t?.responseFormat??this.responseFormat,this.defaultConfig=t?.defaultConfig??this.defaultConfig,this.metadata=t?.metadata??this.metadata,this.extras=t?.extras??this.extras}async invoke(t,e){let a,s=N(O(this.defaultConfig,e));return g(t)?(a=t.args,s={...s,toolCall:t}):a=t,this.call(a,s)}async call(t,e,a){const s=g(t)?t.args:t;let u;if(A(this.schema))try{u=await I(this.schema,s)}catch(c){let o="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(o=`${o}
2
2
  Details: ${c.message}`),L(c)&&(o=`${o}
3
3
 
4
4
  ${J(c)}`),new f(o,JSON.stringify(t))}else{const c=F(s,this.schema);if(!c.valid){let o="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(o=`${o}
@@ -1,4 +1,4 @@
1
- import{cd as Ue,ce as je,cf as J,cg as ae,b as Ae,ch as H,bZ as le,n as U,ci as kt,cj as xt,ck as Mt,cl as Pt,cm as Rt,cn as Ft,co as Lt,cp as Dt,cq as Bt,cr as Ut,i as jt,cs as Vt,ct as zt,cu as Gt,d as Zt,cv as $t,cw as Ht,cx as Wt,cy as Jt,cz as Xt,x as Yt,cA as Kt,c as He,cB as qt,cC as We,cD as Qt,cE as ea,cF as ta,cG as Se,cH as aa,cI as sa,cJ as na,r as ra,w as Je,cK as re,e as oe,cL as Xe,cM as Ye,D as ce,C as _e,cN as Ve,B as ia,cO as ze,R as Ge,b_ as X,y as oa,cP as Ie,c1 as ca,c8 as Ke,cQ as ua,cR as la,cS as ha,c7 as pa,b$ as qe,cT as ie,p as G,cU as Qe,cV as ga,cW as et,cX as ma,a as fa,m as da,cY as ba,cZ as _a,c_ as ya,c$ as Ta,d0 as va,d1 as Ea,d2 as wa,d3 as Ca,c0 as Ze,d4 as Aa,G as Sa,d5 as Ia,o as tt,s as at,d6 as Oa,d7 as ve,z as Na}from"./index-DKfT2EtL.js";function st(e,a,n,r,i){if(a!==e){typeof a.toJSON=="function"&&(a=a.toJSON());for(var c=Ue(a),h=Ue(e),l=!1,b=h.length-1;b>=0;b--){var f=h[b],T=e[f];if(je(a,f)&&!(a[f]===void 0&&T!==void 0&&Array.isArray(a)===!1)){var y=a[f];typeof T=="object"&&T!=null&&typeof y=="object"&&y!=null&&Array.isArray(T)===Array.isArray(y)?st(T,y,n,r+"/"+J(f),i):T!==y&&(i&&n.push({op:"test",path:r+"/"+J(f),value:ae(T)}),n.push({op:"replace",path:r+"/"+J(f),value:ae(y)}))}else Array.isArray(e)===Array.isArray(a)?(i&&n.push({op:"test",path:r+"/"+J(f),value:ae(T)}),n.push({op:"remove",path:r+"/"+J(f)}),l=!0):(i&&n.push({op:"test",path:r,value:e}),n.push({op:"replace",path:r,value:a}))}if(!(!l&&c.length==h.length))for(var b=0;b<c.length;b++){var f=c[b];!je(e,f)&&a[f]!==void 0&&n.push({op:"add",path:r+"/"+J(f),value:ae(a[f])})}}}function Oe(e,a,n=!1){var r=[];return st(e,a,r,"",n),r}function nt(e){return e!==void 0&&Array.isArray(e.lc_namespace)}function rt(e){return e!==void 0&&H.isRunnable(e)&&"lc_name"in e.constructor&&typeof e.constructor.lc_name=="function"&&e.constructor.lc_name()==="RunnableToolLike"}function it(e){return!!e&&typeof e=="object"&&"name"in e&&"schema"in e&&(Ae(e.schema)||e.schema!=null&&typeof e.schema=="object"&&"type"in e.schema&&typeof e.schema.type=="string"&&["null","boolean","object","array","number","string"].includes(e.schema.type))}function ot(e){return it(e)||rt(e)||nt(e)}var ka={};U(ka,{convertToOpenAIFunction:()=>ct,convertToOpenAITool:()=>xa,isLangChainTool:()=>ot,isRunnableToolLike:()=>rt,isStructuredTool:()=>nt,isStructuredToolParams:()=>it});function ct(e,a){const n=typeof a=="number"?void 0:a;return{name:e.name,description:e.description,parameters:le(e.schema),...n?.strict!==void 0?{strict:n.strict}:{}}}function xa(e,a){const n=typeof a=="number"?void 0:a;let r;return ot(e)?r={type:"function",function:ct(e)}:r=e,n?.strict!==void 0&&(r.function.strict=n.strict),r}var Ma={};U(Ma,{extendInteropZodObject:()=>ta,getInteropZodDefaultGetter:()=>ea,getInteropZodObjectShape:()=>Qt,getSchemaDescription:()=>We,interopParse:()=>qt,interopParseAsync:()=>He,interopSafeParse:()=>Kt,interopSafeParseAsync:()=>Yt,interopZodObjectMakeFieldsOptional:()=>Xt,interopZodObjectPartial:()=>Jt,interopZodObjectPassthrough:()=>Wt,interopZodObjectStrict:()=>Ht,interopZodTransformInputSchema:()=>$t,isInteropZodError:()=>Zt,isInteropZodLiteral:()=>Gt,isInteropZodObject:()=>zt,isInteropZodSchema:()=>Ae,isShapelessZodSchema:()=>Vt,isSimpleStringZodSchema:()=>jt,isZodArrayV4:()=>Ut,isZodLiteralV3:()=>Bt,isZodLiteralV4:()=>Dt,isZodNullableV4:()=>Lt,isZodObjectV3:()=>Ft,isZodObjectV4:()=>Rt,isZodOptionalV4:()=>Pt,isZodSchema:()=>Mt,isZodSchemaV3:()=>xt,isZodSchemaV4:()=>kt});var Pa={};U(Pa,{BasePromptValue:()=>he,ChatPromptValue:()=>lt,ImagePromptValue:()=>Ra,StringPromptValue:()=>ut});var he=class extends sa{},ut=class extends he{static lc_name(){return"StringPromptValue"}lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;value;constructor(e){super({value:e}),this.value=e}toString(){return this.value}toChatMessages(){return[new Se(this.value)]}},lt=class extends he{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ChatPromptValue"}messages;constructor(e){Array.isArray(e)&&(e={messages:e}),super(e),this.messages=e.messages}toString(){return aa(this.messages)}toChatMessages(){return this.messages}},Ra=class extends he{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ImagePromptValue"}imageUrl;value;constructor(e){"imageUrl"in e||(e={imageUrl:e}),super(e),this.imageUrl=e.imageUrl}toString(){return this.imageUrl.url}toChatMessages(){return[new Se({content:[{type:"image_url",image_url:{detail:this.imageUrl.detail,url:this.imageUrl.url}}]})]}},_="0123456789abcdef".split(""),Fa=[-2147483648,8388608,32768,128],D=[24,16,8,0],se=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],P=[];function B(e,a){a?(P[0]=P[16]=P[1]=P[2]=P[3]=P[4]=P[5]=P[6]=P[7]=P[8]=P[9]=P[10]=P[11]=P[12]=P[13]=P[14]=P[15]=0,this.blocks=P):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=e}B.prototype.update=function(e){if(!this.finalized){var a,n=typeof e;if(n!=="string"){if(n==="object"){if(e===null)throw new Error(ERROR);if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(e)))throw new Error(ERROR)}else throw new Error(ERROR);a=!0}for(var r,i=0,c,h=e.length,l=this.blocks;i<h;){if(this.hashed&&(this.hashed=!1,l[0]=this.block,this.block=l[16]=l[1]=l[2]=l[3]=l[4]=l[5]=l[6]=l[7]=l[8]=l[9]=l[10]=l[11]=l[12]=l[13]=l[14]=l[15]=0),a)for(c=this.start;i<h&&c<64;++i)l[c>>>2]|=e[i]<<D[c++&3];else for(c=this.start;i<h&&c<64;++i)r=e.charCodeAt(i),r<128?l[c>>>2]|=r<<D[c++&3]:r<2048?(l[c>>>2]|=(192|r>>>6)<<D[c++&3],l[c>>>2]|=(128|r&63)<<D[c++&3]):r<55296||r>=57344?(l[c>>>2]|=(224|r>>>12)<<D[c++&3],l[c>>>2]|=(128|r>>>6&63)<<D[c++&3],l[c>>>2]|=(128|r&63)<<D[c++&3]):(r=65536+((r&1023)<<10|e.charCodeAt(++i)&1023),l[c>>>2]|=(240|r>>>18)<<D[c++&3],l[c>>>2]|=(128|r>>>12&63)<<D[c++&3],l[c>>>2]|=(128|r>>>6&63)<<D[c++&3],l[c>>>2]|=(128|r&63)<<D[c++&3]);this.lastByteIndex=c,this.bytes+=c-this.start,c>=64?(this.block=l[16],this.start=c-64,this.hash(),this.hashed=!0):this.start=c}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};B.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,a=this.lastByteIndex;e[16]=this.block,e[a>>>2]|=Fa[a&3],this.block=e[16],a>=56&&(this.hashed||this.hash(),e[0]=this.block,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),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}};B.prototype.hash=function(){var e=this.h0,a=this.h1,n=this.h2,r=this.h3,i=this.h4,c=this.h5,h=this.h6,l=this.h7,b=this.blocks,f,T,y,E,g,d,m,v,w,A,C;for(f=16;f<64;++f)g=b[f-15],T=(g>>>7|g<<25)^(g>>>18|g<<14)^g>>>3,g=b[f-2],y=(g>>>17|g<<15)^(g>>>19|g<<13)^g>>>10,b[f]=b[f-16]+T+b[f-7]+y<<0;for(C=a&n,f=0;f<64;f+=4)this.first?(this.is224?(v=300032,g=b[0]-1413257819,l=g-150054599<<0,r=g+24177077<<0):(v=704751109,g=b[0]-210244248,l=g-1521486534<<0,r=g+143694565<<0),this.first=!1):(T=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),y=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),v=e&a,E=v^e&n^C,m=i&c^~i&h,g=l+y+m+se[f]+b[f],d=T+E,l=r+g<<0,r=g+d<<0),T=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),y=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7),w=r&e,E=w^r&a^v,m=h&l^~h&i,g=c+y+m+se[f+1]+b[f+1],d=T+E,h=n+g<<0,n=g+d<<0,T=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),y=(h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7),A=n&r,E=A^n&e^w,m=c&h^~c&l,g=i+y+m+se[f+2]+b[f+2],d=T+E,c=a+g<<0,a=g+d<<0,T=(a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10),y=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),C=a&n,E=C^a&r^A,m=c&h^~c&l,g=i+y+m+se[f+3]+b[f+3],d=T+E,i=e+g<<0,e=g+d<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+e<<0,this.h1=this.h1+a<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+i<<0,this.h5=this.h5+c<<0,this.h6=this.h6+h<<0,this.h7=this.h7+l<<0};B.prototype.hex=function(){this.finalize();var e=this.h0,a=this.h1,n=this.h2,r=this.h3,i=this.h4,c=this.h5,h=this.h6,l=this.h7,b=_[e>>>28&15]+_[e>>>24&15]+_[e>>>20&15]+_[e>>>16&15]+_[e>>>12&15]+_[e>>>8&15]+_[e>>>4&15]+_[e&15]+_[a>>>28&15]+_[a>>>24&15]+_[a>>>20&15]+_[a>>>16&15]+_[a>>>12&15]+_[a>>>8&15]+_[a>>>4&15]+_[a&15]+_[n>>>28&15]+_[n>>>24&15]+_[n>>>20&15]+_[n>>>16&15]+_[n>>>12&15]+_[n>>>8&15]+_[n>>>4&15]+_[n&15]+_[r>>>28&15]+_[r>>>24&15]+_[r>>>20&15]+_[r>>>16&15]+_[r>>>12&15]+_[r>>>8&15]+_[r>>>4&15]+_[r&15]+_[i>>>28&15]+_[i>>>24&15]+_[i>>>20&15]+_[i>>>16&15]+_[i>>>12&15]+_[i>>>8&15]+_[i>>>4&15]+_[i&15]+_[c>>>28&15]+_[c>>>24&15]+_[c>>>20&15]+_[c>>>16&15]+_[c>>>12&15]+_[c>>>8&15]+_[c>>>4&15]+_[c&15]+_[h>>>28&15]+_[h>>>24&15]+_[h>>>20&15]+_[h>>>16&15]+_[h>>>12&15]+_[h>>>8&15]+_[h>>>4&15]+_[h&15];return this.is224||(b+=_[l>>>28&15]+_[l>>>24&15]+_[l>>>20&15]+_[l>>>16&15]+_[l>>>12&15]+_[l>>>8&15]+_[l>>>4&15]+_[l&15]),b};B.prototype.toString=B.prototype.hex;B.prototype.digest=function(){this.finalize();var e=this.h0,a=this.h1,n=this.h2,r=this.h3,i=this.h4,c=this.h5,h=this.h6,l=this.h7,b=[e>>>24&255,e>>>16&255,e>>>8&255,e&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,n>>>24&255,n>>>16&255,n>>>8&255,n&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255,i>>>24&255,i>>>16&255,i>>>8&255,i&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255];return this.is224||b.push(l>>>24&255,l>>>16&255,l>>>8&255,l&255),b};B.prototype.array=B.prototype.digest;B.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),a=new DataView(e);return a.setUint32(0,this.h0),a.setUint32(4,this.h1),a.setUint32(8,this.h2),a.setUint32(12,this.h3),a.setUint32(16,this.h4),a.setUint32(20,this.h5),a.setUint32(24,this.h6),this.is224||a.setUint32(28,this.h7),e};const ht=(...e)=>new B(!1,!0).update(e.join("")).hex();var La={};U(La,{sha256:()=>ht});var Da={};U(Da,{BaseCache:()=>gt,InMemoryCache:()=>mt,defaultHashKeyEncoder:()=>pt,deserializeStoredGeneration:()=>Ba,serializeGeneration:()=>Ua});const pt=(...e)=>ht(e.join("_"));function Ba(e){return e.message!==void 0?{text:e.text,message:na(e.message)}:{text:e.text}}function Ua(e){const a={text:e.text};return e.message!==void 0&&(a.message=e.message.toDict()),a}var gt=class{keyEncoder=pt;makeDefaultKeyEncoder(e){this.keyEncoder=e}};const ja=new Map;var mt=class ft extends gt{cache;constructor(a){super(),this.cache=a??new Map}lookup(a,n){return Promise.resolve(this.cache.get(this.keyEncoder(a,n))??null)}async update(a,n,r){this.cache.set(this.keyEncoder(a,n),r)}static global(){return new ft(ja)}},q={},$e;function Va(){if($e)return q;$e=1,q.byteLength=l,q.toByteArray=f,q.fromByteArray=E;for(var e=[],a=[],n=typeof Uint8Array<"u"?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,c=r.length;i<c;++i)e[i]=r[i],a[r.charCodeAt(i)]=i;a[45]=62,a[95]=63;function h(g){var d=g.length;if(d%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var m=g.indexOf("=");m===-1&&(m=d);var v=m===d?0:4-m%4;return[m,v]}function l(g){var d=h(g),m=d[0],v=d[1];return(m+v)*3/4-v}function b(g,d,m){return(d+m)*3/4-m}function f(g){var d,m=h(g),v=m[0],w=m[1],A=new n(b(g,v,w)),C=0,M=w>0?v-4:v,O;for(O=0;O<M;O+=4)d=a[g.charCodeAt(O)]<<18|a[g.charCodeAt(O+1)]<<12|a[g.charCodeAt(O+2)]<<6|a[g.charCodeAt(O+3)],A[C++]=d>>16&255,A[C++]=d>>8&255,A[C++]=d&255;return w===2&&(d=a[g.charCodeAt(O)]<<2|a[g.charCodeAt(O+1)]>>4,A[C++]=d&255),w===1&&(d=a[g.charCodeAt(O)]<<10|a[g.charCodeAt(O+1)]<<4|a[g.charCodeAt(O+2)]>>2,A[C++]=d>>8&255,A[C++]=d&255),A}function T(g){return e[g>>18&63]+e[g>>12&63]+e[g>>6&63]+e[g&63]}function y(g,d,m){for(var v,w=[],A=d;A<m;A+=3)v=(g[A]<<16&16711680)+(g[A+1]<<8&65280)+(g[A+2]&255),w.push(T(v));return w.join("")}function E(g){for(var d,m=g.length,v=m%3,w=[],A=16383,C=0,M=m-v;C<M;C+=A)w.push(y(g,C,C+A>M?M:C+A));return v===1?(d=g[m-1],w.push(e[d>>2]+e[d<<4&63]+"==")):v===2&&(d=(g[m-2]<<8)+g[m-1],w.push(e[d>>10]+e[d>>4&63]+e[d<<2&63]+"=")),w.join("")}return q}var za=Va();const Ga=ra(za);var Za=Object.defineProperty,$a=(e,a,n)=>a in e?Za(e,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[a]=n,Ha=(e,a,n)=>($a(e,a+"",n),n);function Wa(e,a){let n=Array.from({length:e.length},(r,i)=>({start:i,end:i+1}));for(;n.length>1;){let r=null;for(let i=0;i<n.length-1;i++){const c=e.slice(n[i].start,n[i+1].end),h=a.get(c.join(","));h!=null&&(r==null||h<r[0])&&(r=[h,i])}if(r!=null){const i=r[1];n[i]={start:n[i].start,end:n[i+1].end},n.splice(i+1,1)}else break}return n}function Ja(e,a){return e.length===1?[a.get(e.join(","))]:Wa(e,a).map(n=>a.get(e.slice(n.start,n.end).join(","))).filter(n=>n!=null)}function Xa(e){return e.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}var Ee=class{specialTokens;inverseSpecialTokens;patStr;textEncoder=new TextEncoder;textDecoder=new TextDecoder("utf-8");rankMap=new Map;textMap=new Map;constructor(e,a){this.patStr=e.pat_str;const n=e.bpe_ranks.split(`
1
+ import{a7 as Ue,a8 as je,a9 as J,aa as ae,b as Ae,ab as H,Q as le,n as U,ac as kt,ad as xt,ae as Mt,af as Pt,ag as Rt,ah as Ft,ai as Lt,aj as Dt,ak as Bt,al as Ut,i as jt,am as Vt,an as zt,ao as Gt,d as Zt,ap as $t,aq as Ht,ar as Wt,as as Jt,at as Xt,x as Yt,au as Kt,c as He,av as qt,aw as We,ax as Qt,ay as ea,az as ta,aA as Se,aB as aa,aC as sa,aD as na,r as ra,w as Je,aE as re,e as oe,aF as Xe,aG as Ye,D as ce,C as _e,aH as Ve,B as ia,aI as ze,R as Ge,S as X,y as oa,aJ as Ie,W as ca,a2 as Ke,aK as ua,aL as la,aM as ha,a1 as pa,U as qe,aN as ie,p as G,aO as Qe,aP as ga,aQ as et,aR as ma,a as fa,m as da,aS as ba,aT as _a,aU as ya,aV as Ta,aW as va,aX as Ea,aY as wa,aZ as Ca,V as Ze,a_ as Aa,G as Sa,a$ as Ia,o as tt,s as at,b0 as Oa,b1 as ve,z as Na}from"./index-YcAOTRMN.js";function st(e,a,n,r,i){if(a!==e){typeof a.toJSON=="function"&&(a=a.toJSON());for(var c=Ue(a),h=Ue(e),l=!1,b=h.length-1;b>=0;b--){var f=h[b],T=e[f];if(je(a,f)&&!(a[f]===void 0&&T!==void 0&&Array.isArray(a)===!1)){var y=a[f];typeof T=="object"&&T!=null&&typeof y=="object"&&y!=null&&Array.isArray(T)===Array.isArray(y)?st(T,y,n,r+"/"+J(f),i):T!==y&&(i&&n.push({op:"test",path:r+"/"+J(f),value:ae(T)}),n.push({op:"replace",path:r+"/"+J(f),value:ae(y)}))}else Array.isArray(e)===Array.isArray(a)?(i&&n.push({op:"test",path:r+"/"+J(f),value:ae(T)}),n.push({op:"remove",path:r+"/"+J(f)}),l=!0):(i&&n.push({op:"test",path:r,value:e}),n.push({op:"replace",path:r,value:a}))}if(!(!l&&c.length==h.length))for(var b=0;b<c.length;b++){var f=c[b];!je(e,f)&&a[f]!==void 0&&n.push({op:"add",path:r+"/"+J(f),value:ae(a[f])})}}}function Oe(e,a,n=!1){var r=[];return st(e,a,r,"",n),r}function nt(e){return e!==void 0&&Array.isArray(e.lc_namespace)}function rt(e){return e!==void 0&&H.isRunnable(e)&&"lc_name"in e.constructor&&typeof e.constructor.lc_name=="function"&&e.constructor.lc_name()==="RunnableToolLike"}function it(e){return!!e&&typeof e=="object"&&"name"in e&&"schema"in e&&(Ae(e.schema)||e.schema!=null&&typeof e.schema=="object"&&"type"in e.schema&&typeof e.schema.type=="string"&&["null","boolean","object","array","number","string"].includes(e.schema.type))}function ot(e){return it(e)||rt(e)||nt(e)}var ka={};U(ka,{convertToOpenAIFunction:()=>ct,convertToOpenAITool:()=>xa,isLangChainTool:()=>ot,isRunnableToolLike:()=>rt,isStructuredTool:()=>nt,isStructuredToolParams:()=>it});function ct(e,a){const n=typeof a=="number"?void 0:a;return{name:e.name,description:e.description,parameters:le(e.schema),...n?.strict!==void 0?{strict:n.strict}:{}}}function xa(e,a){const n=typeof a=="number"?void 0:a;let r;return ot(e)?r={type:"function",function:ct(e)}:r=e,n?.strict!==void 0&&(r.function.strict=n.strict),r}var Ma={};U(Ma,{extendInteropZodObject:()=>ta,getInteropZodDefaultGetter:()=>ea,getInteropZodObjectShape:()=>Qt,getSchemaDescription:()=>We,interopParse:()=>qt,interopParseAsync:()=>He,interopSafeParse:()=>Kt,interopSafeParseAsync:()=>Yt,interopZodObjectMakeFieldsOptional:()=>Xt,interopZodObjectPartial:()=>Jt,interopZodObjectPassthrough:()=>Wt,interopZodObjectStrict:()=>Ht,interopZodTransformInputSchema:()=>$t,isInteropZodError:()=>Zt,isInteropZodLiteral:()=>Gt,isInteropZodObject:()=>zt,isInteropZodSchema:()=>Ae,isShapelessZodSchema:()=>Vt,isSimpleStringZodSchema:()=>jt,isZodArrayV4:()=>Ut,isZodLiteralV3:()=>Bt,isZodLiteralV4:()=>Dt,isZodNullableV4:()=>Lt,isZodObjectV3:()=>Ft,isZodObjectV4:()=>Rt,isZodOptionalV4:()=>Pt,isZodSchema:()=>Mt,isZodSchemaV3:()=>xt,isZodSchemaV4:()=>kt});var Pa={};U(Pa,{BasePromptValue:()=>he,ChatPromptValue:()=>lt,ImagePromptValue:()=>Ra,StringPromptValue:()=>ut});var he=class extends sa{},ut=class extends he{static lc_name(){return"StringPromptValue"}lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;value;constructor(e){super({value:e}),this.value=e}toString(){return this.value}toChatMessages(){return[new Se(this.value)]}},lt=class extends he{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ChatPromptValue"}messages;constructor(e){Array.isArray(e)&&(e={messages:e}),super(e),this.messages=e.messages}toString(){return aa(this.messages)}toChatMessages(){return this.messages}},Ra=class extends he{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ImagePromptValue"}imageUrl;value;constructor(e){"imageUrl"in e||(e={imageUrl:e}),super(e),this.imageUrl=e.imageUrl}toString(){return this.imageUrl.url}toChatMessages(){return[new Se({content:[{type:"image_url",image_url:{detail:this.imageUrl.detail,url:this.imageUrl.url}}]})]}},_="0123456789abcdef".split(""),Fa=[-2147483648,8388608,32768,128],D=[24,16,8,0],se=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],P=[];function B(e,a){a?(P[0]=P[16]=P[1]=P[2]=P[3]=P[4]=P[5]=P[6]=P[7]=P[8]=P[9]=P[10]=P[11]=P[12]=P[13]=P[14]=P[15]=0,this.blocks=P):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=e}B.prototype.update=function(e){if(!this.finalized){var a,n=typeof e;if(n!=="string"){if(n==="object"){if(e===null)throw new Error(ERROR);if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(e)))throw new Error(ERROR)}else throw new Error(ERROR);a=!0}for(var r,i=0,c,h=e.length,l=this.blocks;i<h;){if(this.hashed&&(this.hashed=!1,l[0]=this.block,this.block=l[16]=l[1]=l[2]=l[3]=l[4]=l[5]=l[6]=l[7]=l[8]=l[9]=l[10]=l[11]=l[12]=l[13]=l[14]=l[15]=0),a)for(c=this.start;i<h&&c<64;++i)l[c>>>2]|=e[i]<<D[c++&3];else for(c=this.start;i<h&&c<64;++i)r=e.charCodeAt(i),r<128?l[c>>>2]|=r<<D[c++&3]:r<2048?(l[c>>>2]|=(192|r>>>6)<<D[c++&3],l[c>>>2]|=(128|r&63)<<D[c++&3]):r<55296||r>=57344?(l[c>>>2]|=(224|r>>>12)<<D[c++&3],l[c>>>2]|=(128|r>>>6&63)<<D[c++&3],l[c>>>2]|=(128|r&63)<<D[c++&3]):(r=65536+((r&1023)<<10|e.charCodeAt(++i)&1023),l[c>>>2]|=(240|r>>>18)<<D[c++&3],l[c>>>2]|=(128|r>>>12&63)<<D[c++&3],l[c>>>2]|=(128|r>>>6&63)<<D[c++&3],l[c>>>2]|=(128|r&63)<<D[c++&3]);this.lastByteIndex=c,this.bytes+=c-this.start,c>=64?(this.block=l[16],this.start=c-64,this.hash(),this.hashed=!0):this.start=c}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};B.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,a=this.lastByteIndex;e[16]=this.block,e[a>>>2]|=Fa[a&3],this.block=e[16],a>=56&&(this.hashed||this.hash(),e[0]=this.block,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),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}};B.prototype.hash=function(){var e=this.h0,a=this.h1,n=this.h2,r=this.h3,i=this.h4,c=this.h5,h=this.h6,l=this.h7,b=this.blocks,f,T,y,E,g,d,m,v,w,A,C;for(f=16;f<64;++f)g=b[f-15],T=(g>>>7|g<<25)^(g>>>18|g<<14)^g>>>3,g=b[f-2],y=(g>>>17|g<<15)^(g>>>19|g<<13)^g>>>10,b[f]=b[f-16]+T+b[f-7]+y<<0;for(C=a&n,f=0;f<64;f+=4)this.first?(this.is224?(v=300032,g=b[0]-1413257819,l=g-150054599<<0,r=g+24177077<<0):(v=704751109,g=b[0]-210244248,l=g-1521486534<<0,r=g+143694565<<0),this.first=!1):(T=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),y=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),v=e&a,E=v^e&n^C,m=i&c^~i&h,g=l+y+m+se[f]+b[f],d=T+E,l=r+g<<0,r=g+d<<0),T=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),y=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7),w=r&e,E=w^r&a^v,m=h&l^~h&i,g=c+y+m+se[f+1]+b[f+1],d=T+E,h=n+g<<0,n=g+d<<0,T=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),y=(h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7),A=n&r,E=A^n&e^w,m=c&h^~c&l,g=i+y+m+se[f+2]+b[f+2],d=T+E,c=a+g<<0,a=g+d<<0,T=(a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10),y=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),C=a&n,E=C^a&r^A,m=c&h^~c&l,g=i+y+m+se[f+3]+b[f+3],d=T+E,i=e+g<<0,e=g+d<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+e<<0,this.h1=this.h1+a<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+i<<0,this.h5=this.h5+c<<0,this.h6=this.h6+h<<0,this.h7=this.h7+l<<0};B.prototype.hex=function(){this.finalize();var e=this.h0,a=this.h1,n=this.h2,r=this.h3,i=this.h4,c=this.h5,h=this.h6,l=this.h7,b=_[e>>>28&15]+_[e>>>24&15]+_[e>>>20&15]+_[e>>>16&15]+_[e>>>12&15]+_[e>>>8&15]+_[e>>>4&15]+_[e&15]+_[a>>>28&15]+_[a>>>24&15]+_[a>>>20&15]+_[a>>>16&15]+_[a>>>12&15]+_[a>>>8&15]+_[a>>>4&15]+_[a&15]+_[n>>>28&15]+_[n>>>24&15]+_[n>>>20&15]+_[n>>>16&15]+_[n>>>12&15]+_[n>>>8&15]+_[n>>>4&15]+_[n&15]+_[r>>>28&15]+_[r>>>24&15]+_[r>>>20&15]+_[r>>>16&15]+_[r>>>12&15]+_[r>>>8&15]+_[r>>>4&15]+_[r&15]+_[i>>>28&15]+_[i>>>24&15]+_[i>>>20&15]+_[i>>>16&15]+_[i>>>12&15]+_[i>>>8&15]+_[i>>>4&15]+_[i&15]+_[c>>>28&15]+_[c>>>24&15]+_[c>>>20&15]+_[c>>>16&15]+_[c>>>12&15]+_[c>>>8&15]+_[c>>>4&15]+_[c&15]+_[h>>>28&15]+_[h>>>24&15]+_[h>>>20&15]+_[h>>>16&15]+_[h>>>12&15]+_[h>>>8&15]+_[h>>>4&15]+_[h&15];return this.is224||(b+=_[l>>>28&15]+_[l>>>24&15]+_[l>>>20&15]+_[l>>>16&15]+_[l>>>12&15]+_[l>>>8&15]+_[l>>>4&15]+_[l&15]),b};B.prototype.toString=B.prototype.hex;B.prototype.digest=function(){this.finalize();var e=this.h0,a=this.h1,n=this.h2,r=this.h3,i=this.h4,c=this.h5,h=this.h6,l=this.h7,b=[e>>>24&255,e>>>16&255,e>>>8&255,e&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,n>>>24&255,n>>>16&255,n>>>8&255,n&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255,i>>>24&255,i>>>16&255,i>>>8&255,i&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255];return this.is224||b.push(l>>>24&255,l>>>16&255,l>>>8&255,l&255),b};B.prototype.array=B.prototype.digest;B.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),a=new DataView(e);return a.setUint32(0,this.h0),a.setUint32(4,this.h1),a.setUint32(8,this.h2),a.setUint32(12,this.h3),a.setUint32(16,this.h4),a.setUint32(20,this.h5),a.setUint32(24,this.h6),this.is224||a.setUint32(28,this.h7),e};const ht=(...e)=>new B(!1,!0).update(e.join("")).hex();var La={};U(La,{sha256:()=>ht});var Da={};U(Da,{BaseCache:()=>gt,InMemoryCache:()=>mt,defaultHashKeyEncoder:()=>pt,deserializeStoredGeneration:()=>Ba,serializeGeneration:()=>Ua});const pt=(...e)=>ht(e.join("_"));function Ba(e){return e.message!==void 0?{text:e.text,message:na(e.message)}:{text:e.text}}function Ua(e){const a={text:e.text};return e.message!==void 0&&(a.message=e.message.toDict()),a}var gt=class{keyEncoder=pt;makeDefaultKeyEncoder(e){this.keyEncoder=e}};const ja=new Map;var mt=class ft extends gt{cache;constructor(a){super(),this.cache=a??new Map}lookup(a,n){return Promise.resolve(this.cache.get(this.keyEncoder(a,n))??null)}async update(a,n,r){this.cache.set(this.keyEncoder(a,n),r)}static global(){return new ft(ja)}},q={},$e;function Va(){if($e)return q;$e=1,q.byteLength=l,q.toByteArray=f,q.fromByteArray=E;for(var e=[],a=[],n=typeof Uint8Array<"u"?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,c=r.length;i<c;++i)e[i]=r[i],a[r.charCodeAt(i)]=i;a[45]=62,a[95]=63;function h(g){var d=g.length;if(d%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var m=g.indexOf("=");m===-1&&(m=d);var v=m===d?0:4-m%4;return[m,v]}function l(g){var d=h(g),m=d[0],v=d[1];return(m+v)*3/4-v}function b(g,d,m){return(d+m)*3/4-m}function f(g){var d,m=h(g),v=m[0],w=m[1],A=new n(b(g,v,w)),C=0,M=w>0?v-4:v,O;for(O=0;O<M;O+=4)d=a[g.charCodeAt(O)]<<18|a[g.charCodeAt(O+1)]<<12|a[g.charCodeAt(O+2)]<<6|a[g.charCodeAt(O+3)],A[C++]=d>>16&255,A[C++]=d>>8&255,A[C++]=d&255;return w===2&&(d=a[g.charCodeAt(O)]<<2|a[g.charCodeAt(O+1)]>>4,A[C++]=d&255),w===1&&(d=a[g.charCodeAt(O)]<<10|a[g.charCodeAt(O+1)]<<4|a[g.charCodeAt(O+2)]>>2,A[C++]=d>>8&255,A[C++]=d&255),A}function T(g){return e[g>>18&63]+e[g>>12&63]+e[g>>6&63]+e[g&63]}function y(g,d,m){for(var v,w=[],A=d;A<m;A+=3)v=(g[A]<<16&16711680)+(g[A+1]<<8&65280)+(g[A+2]&255),w.push(T(v));return w.join("")}function E(g){for(var d,m=g.length,v=m%3,w=[],A=16383,C=0,M=m-v;C<M;C+=A)w.push(y(g,C,C+A>M?M:C+A));return v===1?(d=g[m-1],w.push(e[d>>2]+e[d<<4&63]+"==")):v===2&&(d=(g[m-2]<<8)+g[m-1],w.push(e[d>>10]+e[d>>4&63]+e[d<<2&63]+"=")),w.join("")}return q}var za=Va();const Ga=ra(za);var Za=Object.defineProperty,$a=(e,a,n)=>a in e?Za(e,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[a]=n,Ha=(e,a,n)=>($a(e,a+"",n),n);function Wa(e,a){let n=Array.from({length:e.length},(r,i)=>({start:i,end:i+1}));for(;n.length>1;){let r=null;for(let i=0;i<n.length-1;i++){const c=e.slice(n[i].start,n[i+1].end),h=a.get(c.join(","));h!=null&&(r==null||h<r[0])&&(r=[h,i])}if(r!=null){const i=r[1];n[i]={start:n[i].start,end:n[i+1].end},n.splice(i+1,1)}else break}return n}function Ja(e,a){return e.length===1?[a.get(e.join(","))]:Wa(e,a).map(n=>a.get(e.slice(n.start,n.end).join(","))).filter(n=>n!=null)}function Xa(e){return e.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}var Ee=class{specialTokens;inverseSpecialTokens;patStr;textEncoder=new TextEncoder;textDecoder=new TextDecoder("utf-8");rankMap=new Map;textMap=new Map;constructor(e,a){this.patStr=e.pat_str;const n=e.bpe_ranks.split(`
2
2
  `).filter(Boolean).reduce((r,i)=>{const[c,h,...l]=i.split(" "),b=Number.parseInt(h,10);return l.forEach((f,T)=>r[f]=b+T),r},{});for(const[r,i]of Object.entries(n)){const c=Ga.toByteArray(r);this.rankMap.set(c.join(","),i),this.textMap.set(i,c)}this.specialTokens={...e.special_tokens,...a},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((r,[i,c])=>(r[c]=this.textEncoder.encode(i),r),{})}encode(e,a=[],n="all"){const r=new RegExp(this.patStr,"ug"),i=Ee.specialTokenRegex(Object.keys(this.specialTokens)),c=[],h=new Set(a==="all"?Object.keys(this.specialTokens):a),l=new Set(n==="all"?Object.keys(this.specialTokens).filter(f=>!h.has(f)):n);if(l.size>0){const f=Ee.specialTokenRegex([...l]),T=e.match(f);if(T!=null)throw new Error(`The text contains a special token that is not allowed: ${T[0]}`)}let b=0;for(;;){let f=null,T=b;for(;i.lastIndex=T,f=i.exec(e),!(f==null||h.has(f[0]));)T=f.index+1;const y=f?.index??e.length;for(const g of e.substring(b,y).matchAll(r)){const d=this.textEncoder.encode(g[0]),m=this.rankMap.get(d.join(","));if(m!=null){c.push(m);continue}c.push(...Ja(d,this.rankMap))}if(f==null)break;let E=this.specialTokens[f[0]];c.push(E),b=f.index+f[0].length}return c}decode(e){const a=[];let n=0;for(let c=0;c<e.length;++c){const h=e[c],l=this.textMap.get(h)??this.inverseSpecialTokens[h];l!=null&&(a.push(l),n+=l.length)}const r=new Uint8Array(n);let i=0;for(const c of a)r.set(c,i),i+=c.length;return this.textDecoder.decode(r)}},dt=Ee;Ha(dt,"specialTokenRegex",e=>new RegExp(e.map(a=>Xa(a)).join("|"),"g"));function Ya(e){switch(e){case"gpt2":return"gpt2";case"code-cushman-001":case"code-cushman-002":case"code-davinci-001":case"code-davinci-002":case"cushman-codex":case"davinci-codex":case"davinci-002":case"text-davinci-002":case"text-davinci-003":return"p50k_base";case"code-davinci-edit-001":case"text-davinci-edit-001":return"p50k_edit";case"ada":case"babbage":case"babbage-002":case"code-search-ada-code-001":case"code-search-babbage-code-001":case"curie":case"davinci":case"text-ada-001":case"text-babbage-001":case"text-curie-001":case"text-davinci-001":case"text-search-ada-doc-001":case"text-search-babbage-doc-001":case"text-search-curie-doc-001":case"text-search-davinci-doc-001":case"text-similarity-ada-001":case"text-similarity-babbage-001":case"text-similarity-curie-001":case"text-similarity-davinci-001":return"r50k_base";case"gpt-3.5-turbo-instruct-0914":case"gpt-3.5-turbo-instruct":case"gpt-3.5-turbo-16k-0613":case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo":case"gpt-4-32k-0613":case"gpt-4-32k-0314":case"gpt-4-32k":case"gpt-4-0613":case"gpt-4-0314":case"gpt-4":case"gpt-3.5-turbo-1106":case"gpt-35-turbo":case"gpt-4-1106-preview":case"gpt-4-vision-preview":case"gpt-3.5-turbo-0125":case"gpt-4-turbo":case"gpt-4-turbo-2024-04-09":case"gpt-4-turbo-preview":case"gpt-4-0125-preview":case"text-embedding-ada-002":case"text-embedding-3-small":case"text-embedding-3-large":return"cl100k_base";case"gpt-4o":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":case"gpt-4o-2024-11-20":case"gpt-4o-mini-2024-07-18":case"gpt-4o-mini":case"gpt-4o-search-preview":case"gpt-4o-search-preview-2025-03-11":case"gpt-4o-mini-search-preview":case"gpt-4o-mini-search-preview-2025-03-11":case"gpt-4o-audio-preview":case"gpt-4o-audio-preview-2024-12-17":case"gpt-4o-audio-preview-2024-10-01":case"gpt-4o-mini-audio-preview":case"gpt-4o-mini-audio-preview-2024-12-17":case"o1":case"o1-2024-12-17":case"o1-mini":case"o1-mini-2024-09-12":case"o1-preview":case"o1-preview-2024-09-12":case"o1-pro":case"o1-pro-2025-03-19":case"o3":case"o3-2025-04-16":case"o3-mini":case"o3-mini-2025-01-31":case"o4-mini":case"o4-mini-2025-04-16":case"chatgpt-4o-latest":case"gpt-4o-realtime":case"gpt-4o-realtime-preview-2024-10-01":case"gpt-4o-realtime-preview-2024-12-17":case"gpt-4o-mini-realtime-preview":case"gpt-4o-mini-realtime-preview-2024-12-17":case"gpt-4.1":case"gpt-4.1-2025-04-14":case"gpt-4.1-mini":case"gpt-4.1-mini-2025-04-14":case"gpt-4.1-nano":case"gpt-4.1-nano-2025-04-14":case"gpt-4.5-preview":case"gpt-4.5-preview-2025-02-27":case"gpt-5":case"gpt-5-2025-08-07":case"gpt-5-nano":case"gpt-5-nano-2025-08-07":case"gpt-5-mini":case"gpt-5-mini-2025-08-07":case"gpt-5-chat-latest":return"o200k_base";default:throw new Error("Unknown model")}}var Ka={};U(Ka,{encodingForModel:()=>Ne,getEncoding:()=>bt});const ne={},qa=new Je({});async function bt(e){return e in ne||(ne[e]=qa.fetch(`https://tiktoken.pages.dev/js/${e}.json`).then(a=>a.json()).then(a=>new dt(a)).catch(a=>{throw delete ne[e],a})),await ne[e]}async function Ne(e){return bt(Ya(e))}var Qa={};U(Qa,{BaseLangChain:()=>yt,BaseLanguageModel:()=>Tt,calculateMaxTokens:()=>as,getEmbeddingContextSize:()=>es,getModelContextSize:()=>_t,getModelNameForTiktoken:()=>pe,isOpenAITool:()=>ts});const pe=e=>e.startsWith("gpt-5")?"gpt-5":e.startsWith("gpt-3.5-turbo-16k")?"gpt-3.5-turbo-16k":e.startsWith("gpt-3.5-turbo-")?"gpt-3.5-turbo":e.startsWith("gpt-4-32k")?"gpt-4-32k":e.startsWith("gpt-4-")?"gpt-4":e.startsWith("gpt-4o")?"gpt-4o":e,es=e=>{switch(e){case"text-embedding-ada-002":return 8191;default:return 2046}},_t=e=>{switch(pe(e)){case"gpt-5":case"gpt-5-turbo":case"gpt-5-turbo-preview":return 4e5;case"gpt-4o":case"gpt-4o-mini":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":return 128e3;case"gpt-4-turbo":case"gpt-4-turbo-preview":case"gpt-4-turbo-2024-04-09":case"gpt-4-0125-preview":case"gpt-4-1106-preview":return 128e3;case"gpt-4-32k":case"gpt-4-32k-0314":case"gpt-4-32k-0613":return 32768;case"gpt-4":case"gpt-4-0314":case"gpt-4-0613":return 8192;case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-16k-0613":return 16384;case"gpt-3.5-turbo":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-1106":case"gpt-3.5-turbo-0125":return 4096;case"text-davinci-003":case"text-davinci-002":return 4097;case"text-davinci-001":return 2049;case"text-curie-001":case"text-babbage-001":case"text-ada-001":return 2048;case"code-davinci-002":case"code-davinci-001":return 8e3;case"code-cushman-001":return 2048;case"claude-3-5-sonnet-20241022":case"claude-3-5-sonnet-20240620":case"claude-3-opus-20240229":case"claude-3-sonnet-20240229":case"claude-3-haiku-20240307":case"claude-2.1":return 2e5;case"claude-2.0":case"claude-instant-1.2":return 1e5;case"gemini-1.5-pro":case"gemini-1.5-pro-latest":case"gemini-1.5-flash":case"gemini-1.5-flash-latest":return 1e6;case"gemini-pro":case"gemini-pro-vision":return 32768;default:return 4097}};function ts(e){return typeof e!="object"||!e?!1:!!("type"in e&&e.type==="function"&&"function"in e&&typeof e.function=="object"&&e.function&&"name"in e.function&&"parameters"in e.function)}const as=async({prompt:e,modelName:a})=>{let n;try{n=(await Ne(pe(a))).encode(e).length}catch{console.warn("Failed to calculate number of tokens, falling back to approximate count"),n=Math.ceil(e.length/4)}return _t(a)-n},ss=()=>!1;var yt=class extends H{verbose;callbacks;tags;metadata;get lc_attributes(){return{callbacks:void 0,verbose:void 0}}constructor(e){super(e),this.verbose=e.verbose??ss(),this.callbacks=e.callbacks,this.tags=e.tags??[],this.metadata=e.metadata??{}}},Tt=class extends yt{get callKeys(){return["stop","timeout","signal","tags","metadata","callbacks"]}caller;cache;constructor({callbacks:e,callbackManager:a,...n}){const{cache:r,...i}=n;super({callbacks:e??a,...i}),typeof r=="object"?this.cache=r:r?this.cache=mt.global():this.cache=void 0,this.caller=new Je(n??{})}_encoding;async getNumTokens(e){let a;typeof e=="string"?a=e:a=e.map(r=>typeof r=="string"?r:r.type==="text"&&"text"in r?r.text:"").join("");let n=Math.ceil(a.length/4);if(!this._encoding)try{this._encoding=await Ne("modelName"in this?pe(this.modelName):"gpt2")}catch(r){console.warn("Failed to calculate number of tokens, falling back to approximate count",r)}if(this._encoding)try{n=this._encoding.encode(a).length}catch(r){console.warn("Failed to calculate number of tokens, falling back to approximate count",r)}return n}static _convertInputToPromptValue(e){return typeof e=="string"?new ut(e):Array.isArray(e)?new lt(e.map(re)):e}_identifyingParams(){return{}}_getSerializedCacheKeyParametersForCall({config:e,...a}){const n={...this._identifyingParams(),...a,_type:this._llmType(),_model:this._modelType()};return Object.entries(n).filter(([c,h])=>h!==void 0).map(([c,h])=>`${c}:${JSON.stringify(h)}`).sort().join(",")}serialize(){return{...this._identifyingParams(),_type:this._llmType(),_model:this._modelType()}}static async deserialize(e){throw new Error("Use .toJSON() instead")}get profile(){return{}}},ue=class extends H{static lc_name(){return"RunnablePassthrough"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;func;constructor(e){super(e),e&&(this.func=e.func)}async invoke(e,a){const n=oe(a);return this.func&&await this.func(e,n),this._callWithConfig(r=>Promise.resolve(r),e,n)}async*transform(e,a){const n=oe(a);let r,i=!0;for await(const c of this._transformStreamWithConfig(e,h=>h,n))if(yield c,i)if(r===void 0)r=c;else try{r=ce(r,c)}catch{r=void 0,i=!1}this.func&&r!==void 0&&await this.func(r,n)}static assign(e){return new Xe(new Ye({steps:e}))}};const ns=e=>e();function ye(e){const a=e.constructor;return new a({...e,content:e.contentBlocks,response_metadata:{...e.response_metadata,output_version:"v1"}})}var rs={};U(rs,{BaseChatModel:()=>vt,SimpleChatModel:()=>is});function Te(e){const a=[];for(const n of e){let r=n;if(Array.isArray(n.content))for(let i=0;i<n.content.length;i++){const c=n.content[i];(ua(c)||la(c))&&r===n&&(r=new n.constructor({...r,content:[...n.content.slice(0,i),ha(c),...n.content.slice(i+1)]}))}a.push(r)}return a}var vt=class Z extends Tt{lc_namespace=["langchain","chat_models",this._llmType()];disableStreaming=!1;outputVersion;get callKeys(){return[...super.callKeys,"outputVersion"]}constructor(a){super(a),this.outputVersion=ns(()=>{const n=a.outputVersion??pa("LC_OUTPUT_VERSION");return n&&["v0","v1"].includes(n)?n:"v0"})}_separateRunnableConfigFromCallOptionsCompat(a){const[n,r]=super._separateRunnableConfigFromCallOptions(a);return r.signal=n.signal,[n,r]}async invoke(a,n){const r=Z._convertInputToPromptValue(a);return(await this.generatePrompt([r],n,n?.callbacks)).generations[0][0].message}async*_streamResponseChunks(a,n,r){throw new Error("Not implemented.")}async*_streamIterator(a,n){if(this._streamResponseChunks===Z.prototype._streamResponseChunks||this.disableStreaming)yield this.invoke(a,n);else{const i=Z._convertInputToPromptValue(a).toChatMessages(),[c,h]=this._separateRunnableConfigFromCallOptionsCompat(n),l={...c.metadata,...this.getLsParams(h)},b=await _e.configure(c.callbacks,this.callbacks,c.tags,this.tags,l,this.metadata,{verbose:this.verbose}),f={options:h,invocation_params:this?.invocationParams(h),batch_size:1},T=h.outputVersion??this.outputVersion,y=await b?.handleChatModelStart(this.toJSON(),[Te(i)],c.runId,void 0,f,void 0,void 0,c.runName);let E,g;try{for await(const d of this._streamResponseChunks(i,h,y?.[0])){if(h.signal?.throwIfAborted(),d.message.id==null){const m=y?.at(0)?.runId;m!=null&&d.message._updateId(`run-${m}`)}d.message.response_metadata={...d.generationInfo,...d.message.response_metadata},T==="v1"?yield ye(d.message):yield d.message,E?E=E.concat(d):E=d,Ve(d.message)&&d.message.usage_metadata!==void 0&&(g={tokenUsage:{promptTokens:d.message.usage_metadata.input_tokens,completionTokens:d.message.usage_metadata.output_tokens,totalTokens:d.message.usage_metadata.total_tokens}})}h.signal?.throwIfAborted()}catch(d){throw await Promise.all((y??[]).map(m=>m?.handleLLMError(d))),d}await Promise.all((y??[]).map(d=>d?.handleLLMEnd({generations:[[E]],llmOutput:g})))}}getLsParams(a){const n=this.getName().startsWith("Chat")?this.getName().replace("Chat",""):this.getName();return{ls_model_type:"chat",ls_stop:a.stop,ls_provider:n}}async _generateUncached(a,n,r,i){const c=a.map(E=>E.map(re));let h;if(i!==void 0&&i.length===c.length)h=i;else{const E={...r.metadata,...this.getLsParams(n)},g=await _e.configure(r.callbacks,this.callbacks,r.tags,this.tags,E,this.metadata,{verbose:this.verbose}),d={options:n,invocation_params:this?.invocationParams(n),batch_size:1};h=await g?.handleChatModelStart(this.toJSON(),c.map(Te),r.runId,void 0,d,void 0,void 0,r.runName)}const l=n.outputVersion??this.outputVersion,b=[],f=[];if(!!h?.[0].handlers.find(ia)&&!this.disableStreaming&&c.length===1&&this._streamResponseChunks!==Z.prototype._streamResponseChunks)try{const E=await this._streamResponseChunks(c[0],n,h?.[0]);let g,d;for await(const m of E){if(n.signal?.aborted){const v=g?.message;throw new ze("Model invocation was aborted.",v)}if(m.message.id==null){const v=h?.at(0)?.runId;v!=null&&m.message._updateId(`run-${v}`)}g===void 0?g=m:g=ce(g,m),Ve(m.message)&&m.message.usage_metadata!==void 0&&(d={tokenUsage:{promptTokens:m.message.usage_metadata.input_tokens,completionTokens:m.message.usage_metadata.output_tokens,totalTokens:m.message.usage_metadata.total_tokens}})}if(n.signal?.aborted){const m=g?.message;throw new ze("Model invocation was aborted.",m)}if(g===void 0)throw new Error("Received empty response from chat model call.");b.push([g]),await h?.[0].handleLLMEnd({generations:b,llmOutput:d})}catch(E){throw await h?.[0].handleLLMError(E),E}else{const E=await Promise.allSettled(c.map(async(g,d)=>{const m=await this._generate(g,{...n,promptIndex:d},h?.[d]);if(l==="v1")for(const v of m.generations)v.message=ye(v.message);return m}));await Promise.all(E.map(async(g,d)=>{if(g.status==="fulfilled"){const m=g.value;for(const v of m.generations){if(v.message.id==null){const w=h?.at(0)?.runId;w!=null&&v.message._updateId(`run-${w}`)}v.message.response_metadata={...v.generationInfo,...v.message.response_metadata}}return m.generations.length===1&&(m.generations[0].message.response_metadata={...m.llmOutput,...m.generations[0].message.response_metadata}),b[d]=m.generations,f[d]=m.llmOutput,h?.[d]?.handleLLMEnd({generations:[m.generations],llmOutput:m.llmOutput})}else return await h?.[d]?.handleLLMError(g.reason),Promise.reject(g.reason)}))}const y={generations:b,llmOutput:f.length?this._combineLLMOutput?.(...f):void 0};return Object.defineProperty(y,Ge,{value:h?{runIds:h?.map(E=>E.runId)}:void 0,configurable:!0}),y}async _generateCached({messages:a,cache:n,llmStringKey:r,parsedOptions:i,handledOptions:c}){const h=a.map(w=>w.map(re)),l={...c.metadata,...this.getLsParams(i)},b=await _e.configure(c.callbacks,this.callbacks,c.tags,this.tags,l,this.metadata,{verbose:this.verbose}),f={options:i,invocation_params:this?.invocationParams(i),batch_size:1},T=await b?.handleChatModelStart(this.toJSON(),h.map(Te),c.runId,void 0,f,void 0,void 0,c.runName),y=[],g=(await Promise.allSettled(h.map(async(w,A)=>{const C=Z._convertInputToPromptValue(w).toString(),M=await n.lookup(C,r);return M==null&&y.push(A),M}))).map((w,A)=>({result:w,runManager:T?.[A]})).filter(({result:w})=>w.status==="fulfilled"&&w.value!=null||w.status==="rejected"),d=i.outputVersion??this.outputVersion,m=[];await Promise.all(g.map(async({result:w,runManager:A},C)=>{if(w.status==="fulfilled"){const M=w.value;return m[C]=M.map(O=>("message"in O&&X(O.message)&&oa(O.message)&&(O.message.usage_metadata={input_tokens:0,output_tokens:0,total_tokens:0},d==="v1"&&(O.message=ye(O.message))),O.generationInfo={...O.generationInfo,tokenUsage:{}},O)),M.length&&await A?.handleLLMNewToken(M[0].text),A?.handleLLMEnd({generations:[M]},void 0,void 0,void 0,{cached:!0})}else return await A?.handleLLMError(w.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(w.reason)}));const v={generations:m,missingPromptIndices:y,startedRunManagers:T};return Object.defineProperty(v,Ge,{value:T?{runIds:T?.map(w=>w.runId)}:void 0,configurable:!0}),v}async generate(a,n,r){let i;Array.isArray(n)?i={stop:n}:i=n;const c=a.map(d=>d.map(re)),[h,l]=this._separateRunnableConfigFromCallOptionsCompat(i);if(h.callbacks=h.callbacks??r,!this.cache)return this._generateUncached(c,l,h);const{cache:b}=this,f=this._getSerializedCacheKeyParametersForCall(l),{generations:T,missingPromptIndices:y,startedRunManagers:E}=await this._generateCached({messages:c,cache:b,llmStringKey:f,parsedOptions:l,handledOptions:h});let g={};if(y.length>0){const d=await this._generateUncached(y.map(m=>c[m]),l,h,E!==void 0?y.map(m=>E?.[m]):void 0);await Promise.all(d.generations.map(async(m,v)=>{const w=y[v];T[w]=m;const A=Z._convertInputToPromptValue(c[w]).toString();return b.update(A,f,m)})),g=d.llmOutput??{}}return{generations:T,llmOutput:g}}invocationParams(a){return{}}_modelType(){return"base_chat_model"}async generatePrompt(a,n,r){const i=a.map(c=>c.toChatMessages());return this.generate(i,n,r)}withStructuredOutput(a,n){if(typeof this.bindTools!="function")throw new Error('Chat model must implement ".bindTools()" to use withStructuredOutput.');if(n?.strict)throw new Error('"strict" mode is not supported for this model by default.');const r=a,i=n?.name,c=We(r)??"A function available to call.",h=n?.method,l=n?.includeRaw;if(h==="jsonMode")throw new Error('Base withStructuredOutput implementation only supports "functionCalling" as a method.');let b=i??"extract",f;Ae(r)?f=[{type:"function",function:{name:b,description:c,parameters:le(r)}}]:("name"in r&&(b=r.name),f=[{type:"function",function:{name:b,description:c,parameters:r}}]);const T=this.bindTools(f),y=Ie.from(m=>{if(!ca.isInstance(m))throw new Error("Input is not an AIMessageChunk.");if(!m.tool_calls||m.tool_calls.length===0)throw new Error("No tool calls found in the response.");const v=m.tool_calls.find(w=>w.name===b);if(!v)throw new Error(`No tool call found with name ${b}.`);return v.args});if(!l)return T.pipe(y).withConfig({runName:"StructuredOutput"});const E=ue.assign({parsed:(m,v)=>y.invoke(m.raw,v)}),g=ue.assign({parsed:()=>null}),d=E.withFallbacks({fallbacks:[g]});return Ke.from([{raw:T},d]).withConfig({runName:"StructuredOutputRunnable"})}},is=class extends vt{async _generate(e,a,n){const r=await this._call(e,a,n),i=new qe(r);if(typeof i.content!="string")throw new Error("Cannot generate with a simple chat model when output is not a string.");return{generations:[{text:i.content,message:i}]}}},os=class extends H{static lc_name(){return"RouterRunnable"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;runnables;constructor(e){super(e),this.runnables=e.runnables}async invoke(e,a){const{key:n,input:r}=e,i=this.runnables[n];if(i===void 0)throw new Error(`No runnable associated with key "${n}".`);return i.invoke(r,oe(a))}async batch(e,a,n){const r=e.map(y=>y.key),i=e.map(y=>y.input);if(r.find(y=>this.runnables[y]===void 0)!==void 0)throw new Error("One or more keys do not have a corresponding runnable.");const h=r.map(y=>this.runnables[y]),l=this._getOptionsList(a??{},e.length),b=l[0]?.maxConcurrency??n?.maxConcurrency,f=b&&b>0?b:e.length,T=[];for(let y=0;y<i.length;y+=f){const E=i.slice(y,y+f).map((d,m)=>h[m].invoke(d,l[m])),g=await Promise.all(E);T.push(g)}return T.flat()}async stream(e,a){const{key:n,input:r}=e,i=this.runnables[n];if(i===void 0)throw new Error(`No runnable associated with key "${n}".`);return i.stream(r,a)}},cs=class extends H{static lc_name(){return"RunnableBranch"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;default;branches;constructor(e){super(e),this.branches=e.branches,this.default=e.default}static from(e){if(e.length<1)throw new Error("RunnableBranch requires at least one branch");const n=e.slice(0,-1).map(([i,c])=>[ie(i),ie(c)]),r=ie(e[e.length-1]);return new this({branches:n,default:r})}async _invoke(e,a,n){let r;for(let i=0;i<this.branches.length;i+=1){const[c,h]=this.branches[i];if(await c.invoke(e,G(a,{callbacks:n?.getChild(`condition:${i+1}`)}))){r=await h.invoke(e,G(a,{callbacks:n?.getChild(`branch:${i+1}`)}));break}}return r||(r=await this.default.invoke(e,G(a,{callbacks:n?.getChild("branch:default")}))),r}async invoke(e,a={}){return this._callWithConfig(this._invoke,e,a)}async*_streamIterator(e,a){const r=await(await Qe(a))?.handleChainStart(this.toJSON(),ga(e,"input"),a?.runId,void 0,void 0,void 0,a?.runName);let i,c=!0,h;try{for(let l=0;l<this.branches.length;l+=1){const[b,f]=this.branches[l];if(await b.invoke(e,G(a,{callbacks:r?.getChild(`condition:${l+1}`)}))){h=await f.stream(e,G(a,{callbacks:r?.getChild(`branch:${l+1}`)}));for await(const y of h)if(yield y,c)if(i===void 0)i=y;else try{i=ce(i,y)}catch{i=void 0,c=!1}break}}if(h===void 0){h=await this.default.stream(e,G(a,{callbacks:r?.getChild("branch:default")}));for await(const l of h)if(yield l,c)if(i===void 0)i=l;else try{i=ce(i,l)}catch{i=void 0,c=!1}}}catch(l){throw await r?.handleChainError(l),l}await r?.handleChainEnd(i??{})}},us=class extends et{runnable;inputMessagesKey;outputMessagesKey;historyMessagesKey;getMessageHistory;constructor(e){let a=Ie.from((c,h)=>this._enterHistory(c,h??{})).withConfig({runName:"loadHistory"});const n=e.historyMessagesKey??e.inputMessagesKey;n&&(a=ue.assign({[n]:a}).withConfig({runName:"insertHistory"}));const r=a.pipe(e.runnable.withListeners({onEnd:(c,h)=>this._exitHistory(c,h??{})})).withConfig({runName:"RunnableWithMessageHistory"}),i=e.config??{};super({...e,config:i,bound:r}),this.runnable=e.runnable,this.getMessageHistory=e.getMessageHistory,this.inputMessagesKey=e.inputMessagesKey,this.outputMessagesKey=e.outputMessagesKey,this.historyMessagesKey=e.historyMessagesKey}_getInputMessages(e){let a;if(typeof e=="object"&&!Array.isArray(e)&&!X(e)){let n;this.inputMessagesKey?n=this.inputMessagesKey:Object.keys(e).length===1?n=Object.keys(e)[0]:n="input",Array.isArray(e[n])&&Array.isArray(e[n][0])?a=e[n][0]:a=e[n]}else a=e;if(typeof a=="string")return[new Se(a)];if(Array.isArray(a))return a;if(X(a))return[a];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages.
3
3
  Got ${JSON.stringify(a,null,2)}`)}_getOutputMessages(e){let a;if(!Array.isArray(e)&&!X(e)&&typeof e!="string"){let n;this.outputMessagesKey!==void 0?n=this.outputMessagesKey:Object.keys(e).length===1?n=Object.keys(e)[0]:n="output",e.generations!==void 0?a=e.generations[0][0].message:a=e[n]}else a=e;if(typeof a=="string")return[new qe(a)];if(Array.isArray(a))return a;if(X(a))return[a];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages. Received: ${JSON.stringify(a,null,2)}`)}async _enterHistory(e,a){const r=await(a?.configurable?.messageHistory).getMessages();return this.historyMessagesKey===void 0?r.concat(this._getInputMessages(e)):r}async _exitHistory(e,a){const n=a.configurable?.messageHistory;let r;Array.isArray(e.inputs)&&Array.isArray(e.inputs[0])?r=e.inputs[0]:r=e.inputs;let i=this._getInputMessages(r);if(this.historyMessagesKey===void 0){const l=await n.getMessages();i=i.slice(l.length)}const c=e.outputs;if(!c)throw new Error(`Output values from 'Run' undefined. Run: ${JSON.stringify(e,null,2)}`);const h=this._getOutputMessages(c);await n.addMessages([...i,...h])}async _mergeConfig(...e){const a=await super._mergeConfig(...e);if(!a.configurable||!a.configurable.sessionId){const r={[this.inputMessagesKey??"input"]:"foo"},i={configurable:{sessionId:"123"}};throw new Error(`sessionId is required. Pass it in as part of the config argument to .invoke() or .stream()
4
4
  eg. chain.invoke(${JSON.stringify(r)}, ${JSON.stringify(i)})`)}const{sessionId:n}=a.configurable;return a.configurable.messageHistory=await this.getMessageHistory(n),a}},ls={};U(ls,{RouterRunnable:()=>os,Runnable:()=>H,RunnableAssign:()=>Xe,RunnableBinding:()=>et,RunnableBranch:()=>cs,RunnableEach:()=>Ea,RunnableLambda:()=>Ie,RunnableMap:()=>Ye,RunnableParallel:()=>va,RunnablePassthrough:()=>ue,RunnablePick:()=>Ta,RunnableRetry:()=>ya,RunnableSequence:()=>Ke,RunnableToolLike:()=>_a,RunnableWithFallbacks:()=>ba,RunnableWithMessageHistory:()=>us,_coerceToRunnable:()=>ie,ensureConfig:()=>oe,getCallbackManagerForConfig:()=>Qe,mergeConfigs:()=>da,patchConfig:()=>G,pickRunnableConfigKeys:()=>fa,raceWithSignal:()=>ma});var Et=class extends H{parseResultWithPrompt(e,a,n){return this.parseResult(e,n)}_baseMessageToString(e){return typeof e.content=="string"?e.content:this._baseMessageContentToString(e.content)}_baseMessageContentToString(e){return JSON.stringify(e)}async invoke(e,a){return typeof e=="string"?this._callWithConfig(async(n,r)=>this.parseResult([{text:n}],r?.callbacks),e,{...a,runType:"parser"}):this._callWithConfig(async(n,r)=>this.parseResult([{message:n,text:this._baseMessageToString(n)}],r?.callbacks),e,{...a,runType:"parser"})}},ge=class extends Et{parseResult(e,a){return this.parse(e[0].text,a)}async parseWithPrompt(e,a,n){return this.parse(e,n)}_type(){throw new Error("_type not implemented")}},$=class extends Error{llmOutput;observation;sendToLLM;constructor(e,a,n,r=!1){if(super(e),this.llmOutput=a,this.observation=n,this.sendToLLM=r,r&&(n===void 0||a===void 0))throw new Error("Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true");wa(this,"OUTPUT_PARSING_FAILURE")}},Q=class extends ge{async*_transform(e){for await(const a of e)typeof a=="string"?yield this.parseResult([{text:a}]):yield this.parseResult([{message:a,text:this._baseMessageToString(a)}])}async*transform(e,a){yield*this._transformStreamWithConfig(e,this._transform.bind(this),{...a,runType:"parser"})}},ke=class extends Q{diff=!1;constructor(e){super(e),this.diff=e?.diff??this.diff}async*_transform(e){let a,n;for await(const r of e){if(typeof r!="string"&&typeof r.content!="string")throw new Error("Cannot handle non-string output.");let i;if(Ca(r)){if(typeof r.content!="string")throw new Error("Cannot handle non-string message output.");i=new Ze({message:r,text:r.content})}else if(X(r)){if(typeof r.content!="string")throw new Error("Cannot handle non-string message output.");i=new Ze({message:Aa(r),text:r.content})}else i=new Sa({text:r});n===void 0?n=i:n=n.concat(i);const c=await this.parsePartialResult([n]);c!=null&&!Ia(c,a)&&(this.diff?yield this._diff(a,c):yield c,a=c)}}getFormatInstructions(){return""}},hs=class extends Q{static lc_name(){return"BytesOutputParser"}lc_namespace=["langchain_core","output_parsers","bytes"];lc_serializable=!0;textEncoder=new TextEncoder;parse(e){return Promise.resolve(this.textEncoder.encode(e))}getFormatInstructions(){return""}},ee=class extends Q{re;async*_transform(e){let a="";for await(const n of e)if(typeof n=="string"?a+=n:a+=n.content,this.re){const r=[...a.matchAll(this.re)];if(r.length>1){let i=0;for(const c of r.slice(0,-1))yield[c[1]],i+=(c.index??0)+c[0].length;a=a.slice(i)}}else{const r=await this.parse(a);if(r.length>1){for(const i of r.slice(0,-1))yield[i];a=r[r.length-1]}}for(const n of await this.parse(a))yield[n]}},ps=class extends ee{static lc_name(){return"CommaSeparatedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;async parse(e){try{return e.trim().split(",").map(a=>a.trim())}catch{throw new $(`Could not parse output: ${e}`,e)}}getFormatInstructions(){return"Your response should be a list of comma separated values, eg: `foo, bar, baz`"}},gs=class extends ee{lc_namespace=["langchain_core","output_parsers","list"];length;separator;constructor({length:e,separator:a}){super(...arguments),this.length=e,this.separator=a||","}async parse(e){try{const a=e.trim().split(this.separator).map(n=>n.trim());if(this.length!==void 0&&a.length!==this.length)throw new $(`Incorrect number of items. Expected ${this.length}, got ${a.length}.`);return a}catch(a){throw Object.getPrototypeOf(a)===$.prototype?a:new $(`Could not parse output: ${e}`)}}getFormatInstructions(){return`Your response should be a list of ${this.length===void 0?"":`${this.length} `}items separated by "${this.separator}" (eg: \`foo${this.separator} bar${this.separator} baz\`)`}},ms=class extends ee{static lc_name(){return"NumberedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;getFormatInstructions(){return`Your response should be a numbered list with each item on a new line. For example: