@mcp-use/inspector 0.24.2 → 0.24.3

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 (210) hide show
  1. package/dist/cdn/inspector.js +1649 -1649
  2. package/dist/client/components/ui/SandboxedIframe.d.ts.map +1 -1
  3. package/dist/client/index.js +34 -32
  4. package/dist/web/assets/{1c-BvhFLIxH.js → 1c-DWQP1mub.js} +1 -1
  5. package/dist/web/assets/{abnf-CX8OJqYN.js → abnf-B4m9DfW6.js} +1 -1
  6. package/dist/web/assets/{accesslog-DcgKZXrS.js → accesslog-hR0kFBAG.js} +1 -1
  7. package/dist/web/assets/{actionscript-CItnilsG.js → actionscript-Cp7uPlm2.js} +1 -1
  8. package/dist/web/assets/{ada-jhrFP_kG.js → ada-CR0g3XbW.js} +1 -1
  9. package/dist/web/assets/{angelscript-VAnEYDkE.js → angelscript-D_C_ttkM.js} +1 -1
  10. package/dist/web/assets/{apache-Bvpn5SVi.js → apache-BKAIxKqg.js} +1 -1
  11. package/dist/web/assets/{applescript-CJW-xKGY.js → applescript-BD1URYdA.js} +1 -1
  12. package/dist/web/assets/{arcade-DOpc8o0T.js → arcade-6QKc3A3K.js} +1 -1
  13. package/dist/web/assets/{arduino-gi6qvS9d.js → arduino-C5un47Hz.js} +1 -1
  14. package/dist/web/assets/{armasm-q6MkkUkb.js → armasm-BvMb3akz.js} +1 -1
  15. package/dist/web/assets/{asciidoc-dqeP70O7.js → asciidoc-BDpPy-YS.js} +1 -1
  16. package/dist/web/assets/{aspectj-pTI1lMoV.js → aspectj-C7CzdgE6.js} +1 -1
  17. package/dist/web/assets/{autohotkey-56nVTWRr.js → autohotkey-D7vg-g40.js} +1 -1
  18. package/dist/web/assets/{autoit-CeD--Ts3.js → autoit-CKAMTJPh.js} +1 -1
  19. package/dist/web/assets/{avrasm-AXSUKL73.js → avrasm-BRpxMiYU.js} +1 -1
  20. package/dist/web/assets/{awk-rtNNAadV.js → awk-040OBrGk.js} +1 -1
  21. package/dist/web/assets/{axapta-5CT0vHQJ.js → axapta-De6eA0hN.js} +1 -1
  22. package/dist/web/assets/{bash-BQ-JKmsJ.js → bash-BCfguAb3.js} +1 -1
  23. package/dist/web/assets/{basic-BeuEF9yi.js → basic-mvsNiNyT.js} +1 -1
  24. package/dist/web/assets/{bnf-CBLE-WBe.js → bnf-BOa_p0TC.js} +1 -1
  25. package/dist/web/assets/{brainfuck-D2gmEg74.js → brainfuck-DOWex2Q6.js} +1 -1
  26. package/dist/web/assets/{c-B8cZ_Jcv.js → c-BlnRkrx9.js} +1 -1
  27. package/dist/web/assets/{c-like-BUQset2J.js → c-like-Bb-uR29b.js} +1 -1
  28. package/dist/web/assets/{cal-BfmxNhZ4.js → cal-utigBNMh.js} +1 -1
  29. package/dist/web/assets/{capnproto-ci7Oy_3w.js → capnproto-Dlo2AOh-.js} +1 -1
  30. package/dist/web/assets/{ceylon-CR7mkBjT.js → ceylon-6bOUIIzW.js} +1 -1
  31. package/dist/web/assets/{clean-DDX6TchJ.js → clean-B_BLnZ47.js} +1 -1
  32. package/dist/web/assets/{client-S57RS52Z-D8i-S3XX.js → client-AB7PHV6E-8__RED_q.js} +4 -4
  33. package/dist/web/assets/{clojure-BI_RGTAe.js → clojure-CpRuXaIY.js} +1 -1
  34. package/dist/web/assets/{clojure-repl-DSE_x4C2.js → clojure-repl-DfhlcYzS.js} +1 -1
  35. package/dist/web/assets/{cmake-DO4jOBdV.js → cmake-Di3Tdm-b.js} +1 -1
  36. package/dist/web/assets/{coffeescript-Dd0Lp6GU.js → coffeescript-1A5CLhg9.js} +1 -1
  37. package/dist/web/assets/{coq-BVtIgdCz.js → coq-COY-wJJb.js} +1 -1
  38. package/dist/web/assets/{core-DLviWPP3.js → core-spBc5hpn.js} +1 -1
  39. package/dist/web/assets/{cos-BSiT-IT0.js → cos-DGYwvIaD.js} +1 -1
  40. package/dist/web/assets/{cpp-DQ17j1lu.js → cpp-CJzjHzKr.js} +1 -1
  41. package/dist/web/assets/{crmsh-BG-_i7Az.js → crmsh-D2Ny6Rg1.js} +1 -1
  42. package/dist/web/assets/{crystal-CwybcU_c.js → crystal-KwE8xYAd.js} +1 -1
  43. package/dist/web/assets/{csharp-C5EW5MWq.js → csharp-8dHfl8hC.js} +1 -1
  44. package/dist/web/assets/{csp-B4avFpGl.js → csp-CorDAKtZ.js} +1 -1
  45. package/dist/web/assets/{css-XwnDlpLG.js → css-kY1UfsP6.js} +1 -1
  46. package/dist/web/assets/{d-BVPgG_Aw.js → d-DLzik6S1.js} +1 -1
  47. package/dist/web/assets/{dart-CuzkdMfW.js → dart-DsClekPq.js} +1 -1
  48. package/dist/web/assets/{delphi-CUWyVIpe.js → delphi-cbm44tTh.js} +1 -1
  49. package/dist/web/assets/{diff-D3sSlrXe.js → diff-DXsxp2ij.js} +1 -1
  50. package/dist/web/assets/{display-A5IEINAP-GZCoUyvv.js → display-A5IEINAP-BUlGvd6Q.js} +2 -2
  51. package/dist/web/assets/{django-D17_zMlX.js → django-CyiFgRFK.js} +1 -1
  52. package/dist/web/assets/{dns-C1XxIveT.js → dns-DqVVp3Mw.js} +1 -1
  53. package/dist/web/assets/{dockerfile-CaGNlKQa.js → dockerfile-C3_NP38E.js} +1 -1
  54. package/dist/web/assets/{dos-CGH0X7Qf.js → dos-DNA6kcVG.js} +1 -1
  55. package/dist/web/assets/{dsconfig-DTVqhcqx.js → dsconfig-Cm5gOfMQ.js} +1 -1
  56. package/dist/web/assets/{dts-BQco_sjz.js → dts-Dxzj1Gl8.js} +1 -1
  57. package/dist/web/assets/{dust-BqGWXklz.js → dust-Db4IOXjd.js} +1 -1
  58. package/dist/web/assets/{ebnf-BqCwsW4k.js → ebnf-BbHZFiLn.js} +1 -1
  59. package/dist/web/assets/{elixir-WtC_BfcU.js → elixir-DqC_iHl6.js} +1 -1
  60. package/dist/web/assets/{elm-D7xIR2_2.js → elm-BqmcB6ra.js} +1 -1
  61. package/dist/web/assets/{embeddings-DD3kbxNt.js → embeddings-VSFMeWkW.js} +1 -1
  62. package/dist/web/assets/{erb-DjXRvkR1.js → erb-BQlRwOBV.js} +1 -1
  63. package/dist/web/assets/{erlang-3Dswo9Kb.js → erlang-BE_UGfR8.js} +1 -1
  64. package/dist/web/assets/{erlang-repl-DSxDJl2O.js → erlang-repl-Cz4fhEkS.js} +1 -1
  65. package/dist/web/assets/{excel-BomM7FtM.js → excel-BE4UVJCI.js} +1 -1
  66. package/dist/web/assets/{fix-Dk-kBHCz.js → fix-BFJZi0ZF.js} +1 -1
  67. package/dist/web/assets/{flix-AdO4r9fm.js → flix-CyeQFyrI.js} +1 -1
  68. package/dist/web/assets/{fortran-BiFgPRXr.js → fortran-BCOvhjJM.js} +1 -1
  69. package/dist/web/assets/{fsharp-CrGX07bo.js → fsharp-DR6jYTGn.js} +1 -1
  70. package/dist/web/assets/{gams-t-W8hkrr.js → gams-CGAR2g-Z.js} +1 -1
  71. package/dist/web/assets/{gauss-aVHF9YQ0.js → gauss-k3dDkPe5.js} +1 -1
  72. package/dist/web/assets/{gcode-Dirh21Jx.js → gcode-B6-frFb0.js} +1 -1
  73. package/dist/web/assets/{gherkin-Doinw4Bw.js → gherkin-BUuDsS9n.js} +1 -1
  74. package/dist/web/assets/{glsl-BVAd7fQZ.js → glsl-BYhoCZKT.js} +1 -1
  75. package/dist/web/assets/{gml-D3k6P4wF.js → gml-DYkKS3qA.js} +1 -1
  76. package/dist/web/assets/{go-RoXLUpPR.js → go-74QphXEb.js} +1 -1
  77. package/dist/web/assets/{golo-BC3q2vpX.js → golo-DBWqrZGX.js} +1 -1
  78. package/dist/web/assets/{gradle-DVbLpAp9.js → gradle-C7daK8_y.js} +1 -1
  79. package/dist/web/assets/{groovy-BlpSZ8yL.js → groovy-Bi5ue30i.js} +1 -1
  80. package/dist/web/assets/{haml-CzCcmI1O.js → haml-BXi-JezI.js} +1 -1
  81. package/dist/web/assets/{handlebars-Bw-pBlQu.js → handlebars-LAlnt_hk.js} +1 -1
  82. package/dist/web/assets/{haskell-DhIYpyey.js → haskell-D4WJNqrQ.js} +1 -1
  83. package/dist/web/assets/{haxe-CYh7KB7k.js → haxe-mWf61HUO.js} +1 -1
  84. package/dist/web/assets/{hsp-r1aLXMhs.js → hsp-Dojie6Gw.js} +1 -1
  85. package/dist/web/assets/{htmlbars-HUpfURpP.js → htmlbars-jJ14_7NK.js} +1 -1
  86. package/dist/web/assets/{http-BGFs537-.js → http-Cc4lCqW4.js} +1 -1
  87. package/dist/web/assets/{hy-Dhjbxgrk.js → hy-8KcZEbbZ.js} +1 -1
  88. package/dist/web/assets/{index-DhbVcA9F.js → index-BGGQsG8S.js} +1 -1
  89. package/dist/web/assets/{index-BaQ4JmMg.js → index-CCwFSwLA.js} +1 -1
  90. package/dist/web/assets/{index-i9rlZ7RP.js → index-CYJeDEI4.js} +1 -1
  91. package/dist/web/assets/{index-BniVLnRq.js → index-DJq3Cwo_.js} +1 -1
  92. package/dist/web/assets/{index-DdfO8wbV.js → index-OJkqFRtn.js} +1 -1
  93. package/dist/web/assets/{index-BQDf_2QT.js → index-PReApu5D.js} +9 -9
  94. package/dist/web/assets/{index-D6ksAhcX.js → index-zSJ0teU7.js} +1 -1
  95. package/dist/web/assets/{inform7-B5avNAGg.js → inform7-BVVLwY0Y.js} +1 -1
  96. package/dist/web/assets/{ini-5Yf7OApE.js → ini-DxVdMXTA.js} +1 -1
  97. package/dist/web/assets/{irpf90-9P8GaAT8.js → irpf90-CK5Ve43F.js} +1 -1
  98. package/dist/web/assets/{isbl-DBvY8d_e.js → isbl-CWdaifmf.js} +1 -1
  99. package/dist/web/assets/{java-BYAicyox.js → java-Deynp6dV.js} +1 -1
  100. package/dist/web/assets/{javascript-BsZ6ruUt.js → javascript-D-1JqFUr.js} +1 -1
  101. package/dist/web/assets/{jboss-cli-BEvNpqj4.js → jboss-cli-B9zhbwC0.js} +1 -1
  102. package/dist/web/assets/{json-YkjXrxXX.js → json-YMxXFyeh.js} +1 -1
  103. package/dist/web/assets/{julia-CIaQJLVA.js → julia-DWnUVcmD.js} +1 -1
  104. package/dist/web/assets/{julia-repl-neu8z3rS.js → julia-repl-DSX4rcLC.js} +1 -1
  105. package/dist/web/assets/{kotlin-B_3Gv_Wa.js → kotlin-BLBQXIGX.js} +1 -1
  106. package/dist/web/assets/{langfuse-U2OEF7K7-BS7yds-5.js → langfuse-U2OEF7K7-dQHZ0LiE.js} +3 -3
  107. package/dist/web/assets/{lasso-BcxCyLbb.js → lasso-CtlT6rls.js} +1 -1
  108. package/dist/web/assets/{latex-DBLSyLoB.js → latex-Cg4YnNMk.js} +1 -1
  109. package/dist/web/assets/{ldif-zLAu6Yaq.js → ldif-CzNJ0sb4.js} +1 -1
  110. package/dist/web/assets/{leaf-C8g3QwRa.js → leaf-_Bypq4lt.js} +1 -1
  111. package/dist/web/assets/{less-BiZdkKrA.js → less-BRX4OsEl.js} +1 -1
  112. package/dist/web/assets/{lisp-SZa_n4Ha.js → lisp-C_Q8MZOv.js} +1 -1
  113. package/dist/web/assets/{livecodeserver-DbqsVDXq.js → livecodeserver-B7R1o_x9.js} +1 -1
  114. package/dist/web/assets/{livescript-CKn9aHzH.js → livescript-By3nKPsA.js} +1 -1
  115. package/dist/web/assets/{llms-iELWWhGP.js → llms-Dji6qLbK.js} +1 -1
  116. package/dist/web/assets/{llvm-B2i8wLJj.js → llvm-D-UB_VdD.js} +1 -1
  117. package/dist/web/assets/{lsl-Cm2mEXVA.js → lsl-BhRYOBfc.js} +1 -1
  118. package/dist/web/assets/{lua-BEDlAaf-.js → lua-C4n77O33.js} +1 -1
  119. package/dist/web/assets/{makefile-CjFs_qe4.js → makefile-BNclwAhc.js} +1 -1
  120. package/dist/web/assets/{markdown-isjfrR4I.js → markdown-B_lHon9I.js} +1 -1
  121. package/dist/web/assets/{mathematica-_UeFOFBA.js → mathematica-BVYsM_A5.js} +1 -1
  122. package/dist/web/assets/{matlab-Bn6pdsuY.js → matlab-cYcEv3Wk.js} +1 -1
  123. package/dist/web/assets/{maxima-CzA538N9.js → maxima-DzwwwHqp.js} +1 -1
  124. package/dist/web/assets/{mel-BkIKTvwA.js → mel-D3qm56Y8.js} +1 -1
  125. package/dist/web/assets/{mercury-BW46IsU1.js → mercury-CFun94mM.js} +1 -1
  126. package/dist/web/assets/{mipsasm-xk8xikSW.js → mipsasm-3suvCdfN.js} +1 -1
  127. package/dist/web/assets/{mizar-CydR6mll.js → mizar-Bmm4Raqy.js} +1 -1
  128. package/dist/web/assets/{mojolicious-DPEf75yc.js → mojolicious-DRfaKPr8.js} +1 -1
  129. package/dist/web/assets/{monkey-C3GGTuc2.js → monkey-CdKa5phJ.js} +1 -1
  130. package/dist/web/assets/{moonscript-BWCm7GA4.js → moonscript-DjTY6jVw.js} +1 -1
  131. package/dist/web/assets/{n1ql-KUcEBJ5e.js → n1ql-D7N67xB1.js} +1 -1
  132. package/dist/web/assets/{nginx-B5n_99-T.js → nginx-0H1btrKU.js} +1 -1
  133. package/dist/web/assets/{nim-Cj2kL1F7.js → nim-D8xmWLX8.js} +1 -1
  134. package/dist/web/assets/{nix-DU3svOEi.js → nix-DhxXkFWS.js} +1 -1
  135. package/dist/web/assets/{node-repl-CVjFZCg8.js → node-repl-4fQyEV1h.js} +1 -1
  136. package/dist/web/assets/{nsis-ec6JIFaq.js → nsis-Bym7lcyY.js} +1 -1
  137. package/dist/web/assets/{objectivec-35jFh8_n.js → objectivec-Bae6P5vI.js} +1 -1
  138. package/dist/web/assets/{ocaml-DSvpPQQA.js → ocaml-BXQl_rW-.js} +1 -1
  139. package/dist/web/assets/{openscad-BtR0N549.js → openscad-Crs0A6z8.js} +1 -1
  140. package/dist/web/assets/{oxygene-DHhgzdSe.js → oxygene-GrMP1tSV.js} +1 -1
  141. package/dist/web/assets/{parser3-DBNAvQ81.js → parser3-DAaJCr4F.js} +1 -1
  142. package/dist/web/assets/{perl-aQ2z2IY0.js → perl-Bdu82Ke9.js} +1 -1
  143. package/dist/web/assets/{pf-NcRyIsiR.js → pf-BWAdT5hr.js} +1 -1
  144. package/dist/web/assets/{pgsql-C6IelojA.js → pgsql-BiAI36Tl.js} +1 -1
  145. package/dist/web/assets/{php-DXFb1z3E.js → php-DJJs2Qa7.js} +1 -1
  146. package/dist/web/assets/{php-template-noIzpFwi.js → php-template-5NUSFJjr.js} +1 -1
  147. package/dist/web/assets/{plaintext-CuMZI4wJ.js → plaintext-Cdy1uQ2h.js} +1 -1
  148. package/dist/web/assets/{pony-DKNUP03S.js → pony-BCtjd2SF.js} +1 -1
  149. package/dist/web/assets/{powershell-DK5QFD1P.js → powershell-D1lq3PTM.js} +1 -1
  150. package/dist/web/assets/{processing-Bd0YwPX-.js → processing-DaYRWplr.js} +1 -1
  151. package/dist/web/assets/{profile-BUJvtaZj.js → profile-DvQtt2O9.js} +1 -1
  152. package/dist/web/assets/{prolog-C8MmbuJy.js → prolog-DEkCKvGB.js} +1 -1
  153. package/dist/web/assets/{properties-BQiZSAsl.js → properties-B3LbXDXT.js} +1 -1
  154. package/dist/web/assets/{protobuf-BIM_UAt8.js → protobuf-C5rCr5vP.js} +1 -1
  155. package/dist/web/assets/{puppet-BuXb1lDA.js → puppet-CvxuSTBF.js} +1 -1
  156. package/dist/web/assets/{purebasic-BI2OGD7g.js → purebasic-DRKNl9vw.js} +1 -1
  157. package/dist/web/assets/{python-MrZFTqbt.js → python-BGj4l9-1.js} +1 -1
  158. package/dist/web/assets/{python-repl-BgSuB0OR.js → python-repl-a_mGDUz9.js} +1 -1
  159. package/dist/web/assets/{q-CHprrWyV.js → q-DYR5XrsH.js} +1 -1
  160. package/dist/web/assets/{qml-BnHfbLpq.js → qml-BYrig_lw.js} +1 -1
  161. package/dist/web/assets/{r-BaO6b_Bk.js → r-Cvry9LOJ.js} +1 -1
  162. package/dist/web/assets/{reasonml-DSmR8Ung.js → reasonml-DbRKnt_5.js} +1 -1
  163. package/dist/web/assets/{rib-Dm3ubKSd.js → rib-CEt4BFqx.js} +1 -1
  164. package/dist/web/assets/{roboconf-BLDc3VXQ.js → roboconf-H_d48ndW.js} +1 -1
  165. package/dist/web/assets/{routeros-BE3GmAwJ.js → routeros-Bc6nYTKY.js} +1 -1
  166. package/dist/web/assets/{rsl-BJNhDId6.js → rsl-COgBxi_Y.js} +1 -1
  167. package/dist/web/assets/{ruby-CQ10tkxO.js → ruby-B7Vd9nzp.js} +1 -1
  168. package/dist/web/assets/{ruleslanguage-DFnSuCn9.js → ruleslanguage-B_5WDFET.js} +1 -1
  169. package/dist/web/assets/{rust-wEY88oU7.js → rust-D4tCHsbQ.js} +1 -1
  170. package/dist/web/assets/{sas-gbrzG7lJ.js → sas-CY57IJZC.js} +1 -1
  171. package/dist/web/assets/{scala-CumsYZ1V.js → scala-C9Pbgj8I.js} +1 -1
  172. package/dist/web/assets/{scheme-DO8wf0St.js → scheme-BFBa25WW.js} +1 -1
  173. package/dist/web/assets/{scilab-BeQqjCZH.js → scilab-DK-pGu_5.js} +1 -1
  174. package/dist/web/assets/{scss-Bndud_G4.js → scss-BIOnER2K.js} +1 -1
  175. package/dist/web/assets/{shell-Ui33dEFX.js → shell-DQE7INyJ.js} +1 -1
  176. package/dist/web/assets/{smali-MAEUsdX_.js → smali-DpSW5EXH.js} +1 -1
  177. package/dist/web/assets/{smalltalk-hIj_nQ9T.js → smalltalk-CrDxUPM9.js} +1 -1
  178. package/dist/web/assets/{sml-CDrYQEBb.js → sml-B2aS7St-.js} +1 -1
  179. package/dist/web/assets/{sqf-BfLxcAGD.js → sqf-B78BRwov.js} +1 -1
  180. package/dist/web/assets/{sql-DANvBdmv.js → sql-Eqyy9FEh.js} +1 -1
  181. package/dist/web/assets/{sql_more-C0QRwHnL.js → sql_more-dSCbUr-A.js} +1 -1
  182. package/dist/web/assets/{stan-Cj8NJPGd.js → stan-PfHp2ZCj.js} +1 -1
  183. package/dist/web/assets/{stata-DHZ8Glmp.js → stata-CvOAKACJ.js} +1 -1
  184. package/dist/web/assets/{stdio-XAHYUHLM-Ci3DPFXU.js → stdio-J7J2D5YS-BCl13o02.js} +1 -1
  185. package/dist/web/assets/{step21-DYbMWMLq.js → step21-BF8so2_c.js} +1 -1
  186. package/dist/web/assets/{stylus-HTTDZjuT.js → stylus-CILAC3i4.js} +1 -1
  187. package/dist/web/assets/{subunit-VIqybOs4.js → subunit-BHyXupFz.js} +1 -1
  188. package/dist/web/assets/{swift-BR9ynvuv.js → swift-CDCOX3ON.js} +1 -1
  189. package/dist/web/assets/{taggerscript-BBIZMwyL.js → taggerscript-BldoyP1w.js} +1 -1
  190. package/dist/web/assets/{tap-DgYlHFwQ.js → tap-CF6UNBEG.js} +1 -1
  191. package/dist/web/assets/{tcl-BOVb5he3.js → tcl-nSy7CV5q.js} +1 -1
  192. package/dist/web/assets/{thrift-DnYrJP2I.js → thrift-D6SUf4ef.js} +1 -1
  193. package/dist/web/assets/{tp-CKMrYpFB.js → tp-B38xDURl.js} +1 -1
  194. package/dist/web/assets/{twig-C8yRQ_si.js → twig-O_UP3VrO.js} +1 -1
  195. package/dist/web/assets/{typescript-Bp8GRFbQ.js → typescript-BuJSAUtK.js} +1 -1
  196. package/dist/web/assets/{vala-Bv7tX-YP.js → vala-D9z2K-QI.js} +1 -1
  197. package/dist/web/assets/{vbnet-B-xyxnsY.js → vbnet-zONfI18P.js} +1 -1
  198. package/dist/web/assets/{vbscript-DCSS0QgU.js → vbscript-D6POmMCx.js} +1 -1
  199. package/dist/web/assets/{vbscript-html-DkK5mhXa.js → vbscript-html-Bxmac_EM.js} +1 -1
  200. package/dist/web/assets/{verilog-CaWRJI65.js → verilog-C6exP91c.js} +1 -1
  201. package/dist/web/assets/{vhdl-UJHisrmd.js → vhdl-CrisA7BU.js} +1 -1
  202. package/dist/web/assets/{vim-CTdBAd8A.js → vim-BpYmjRBH.js} +1 -1
  203. package/dist/web/assets/{x86asm-DipJ34Qb.js → x86asm-DS7pwGxH.js} +1 -1
  204. package/dist/web/assets/{xl-DfcCv_5D.js → xl-DgBcEonr.js} +1 -1
  205. package/dist/web/assets/{xml-Ds8sXZ7Q.js → xml-CDTtZ_A7.js} +1 -1
  206. package/dist/web/assets/{xquery-BofP9fWJ.js → xquery-0jSyorGq.js} +1 -1
  207. package/dist/web/assets/{yaml-CsOQPuOU.js → yaml-wH3dgKUW.js} +1 -1
  208. package/dist/web/assets/{zephir-CU7UAhpm.js → zephir-BiKgn5d9.js} +1 -1
  209. package/dist/web/index.html +2 -2
  210. package/package.json +2 -2
@@ -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-DhbVcA9F.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-BQDf_2QT.js";import{E as Nt,c as Mt}from"./embeddings-DD3kbxNt.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-BGGQsG8S.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-PReApu5D.js";import{E as Nt,c as Mt}from"./embeddings-VSFMeWkW.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{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-DhbVcA9F.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-BQDf_2QT.js";import{t as Ie}from"./index-BaQ4JmMg.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-BGGQsG8S.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-PReApu5D.js";import{t as Ie}from"./index-CCwFSwLA.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