@google/adk 2.2.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (298) hide show
  1. package/dist/cjs/a2a/a2a_remote_agent.js +4 -1
  2. package/dist/cjs/a2a/agent_card.js +102 -26
  3. package/dist/cjs/a2a/agent_to_a2a.js +1 -1
  4. package/dist/cjs/agents/agent_engine_client.js +172 -0
  5. package/dist/cjs/agents/base_agent.js +20 -4
  6. package/dist/cjs/agents/functions.js +227 -25
  7. package/dist/cjs/agents/instructions.js +6 -2
  8. package/dist/cjs/agents/invocation_context.js +26 -4
  9. package/dist/cjs/agents/langgraph_agent.js +152 -0
  10. package/dist/cjs/agents/llm_agent.js +194 -107
  11. package/dist/cjs/agents/processors/basic_llm_request_processor.js +1 -1
  12. package/dist/cjs/agents/processors/code_execution_request_processor.js +18 -6
  13. package/dist/cjs/agents/processors/content_processor_utils.js +38 -10
  14. package/dist/cjs/agents/processors/content_request_processor.js +34 -2
  15. package/dist/cjs/agents/processors/instructions_llm_request_processor.js +1 -1
  16. package/dist/cjs/agents/processors/nl_planning_processor.js +12 -3
  17. package/dist/cjs/artifacts/in_memory_artifact_service.js +14 -0
  18. package/dist/cjs/auth/auth_handler.js +37 -5
  19. package/dist/cjs/auth/auth_schemes.js +9 -0
  20. package/dist/cjs/cli/cli_eval.js +532 -0
  21. package/dist/cjs/cli/utils/envs.js +116 -0
  22. package/dist/cjs/cli/utils/evals.js +137 -0
  23. package/dist/cjs/cli/utils/logs.js +150 -0
  24. package/dist/cjs/code_executors/agent_engine_sandbox_code_executor.js +7 -2
  25. package/dist/cjs/code_executors/code_execution_utils.js +48 -16
  26. package/dist/cjs/code_executors/code_executor_context.js +6 -2
  27. package/dist/cjs/code_executors/container_code_executor.js +27 -16
  28. package/dist/cjs/code_executors/unsafe_local_code_executor.js +6 -1
  29. package/dist/cjs/common.js +61 -0
  30. package/dist/cjs/context/summarizers/llm_summarizer.js +12 -10
  31. package/dist/cjs/context/token_based_context_compactor.js +2 -1
  32. package/dist/cjs/errors/input_validation_error.js +3 -2
  33. package/dist/cjs/events/event.js +4 -2
  34. package/dist/cjs/examples/example_util.js +23 -2
  35. package/dist/cjs/flows/llm_flows/audio_transcriber.js +170 -0
  36. package/dist/cjs/index.js +104 -1
  37. package/dist/cjs/integrations/agent_registry/helpers.js +1 -1
  38. package/dist/cjs/models/gemini_llm_connection.js +16 -8
  39. package/dist/cjs/models/google_llm.js +13 -16
  40. package/dist/cjs/models/llm_response.js +9 -1
  41. package/dist/cjs/models/registry.js +1 -1
  42. package/dist/cjs/models/routed_llm.js +9 -8
  43. package/dist/cjs/planners/plan_re_act_planner.js +1 -1
  44. package/dist/cjs/plugins/base_plugin.js +13 -23
  45. package/dist/cjs/runner/in_memory_runner.js +6 -11
  46. package/dist/cjs/runner/runner.js +105 -33
  47. package/dist/cjs/sessions/base_session_service.js +14 -8
  48. package/dist/cjs/sessions/database_session_service.js +50 -28
  49. package/dist/cjs/sessions/db/operations.js +1 -1
  50. package/dist/cjs/sessions/in_memory_session_service.js +3 -1
  51. package/dist/cjs/sessions/stale_session_error.js +59 -0
  52. package/dist/cjs/sessions/state.js +8 -4
  53. package/dist/cjs/sessions/vertex_ai_session_service.js +34 -15
  54. package/dist/cjs/skills/loader.js +52 -18
  55. package/dist/cjs/telemetry/setup.js +0 -1
  56. package/dist/cjs/telemetry/tracing.js +147 -73
  57. package/dist/cjs/tools/agent_tool.js +44 -0
  58. package/dist/cjs/tools/apihub_tool/apihub_toolset.js +137 -0
  59. package/dist/cjs/tools/apihub_tool/clients/apihub_client.js +272 -0
  60. package/dist/cjs/tools/apihub_tool/clients/secret_client.js +148 -0
  61. package/dist/cjs/tools/apihub_tool/clients/service_account.js +48 -0
  62. package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +263 -0
  63. package/dist/cjs/tools/application_integration_tool/clients/cloud_request.js +133 -0
  64. package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +671 -0
  65. package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +223 -0
  66. package/dist/cjs/tools/application_integration_tool/integration_connector_tool.js +184 -0
  67. package/dist/cjs/tools/example_tool.js +10 -0
  68. package/dist/cjs/tools/function_tool.js +319 -0
  69. package/dist/cjs/tools/google_api_tool/google_api_tool.js +100 -0
  70. package/dist/cjs/tools/google_api_tool/google_api_toolset.js +173 -0
  71. package/dist/cjs/tools/google_api_tool/google_api_toolsets.js +124 -0
  72. package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +440 -0
  73. package/dist/cjs/tools/google_api_tool/index.js +61 -0
  74. package/dist/cjs/tools/load_artifacts_tool.js +12 -6
  75. package/dist/cjs/tools/load_memory_tool.js +12 -10
  76. package/dist/cjs/tools/mcp/index.js +12 -0
  77. package/dist/cjs/tools/mcp/mcp_session_manager.js +25 -0
  78. package/dist/cjs/tools/mcp/mcp_toolset.js +1 -14
  79. package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +1 -2
  80. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +46 -2
  81. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +4 -3
  82. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
  83. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
  84. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
  85. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +14 -2
  86. package/dist/cjs/tools/openapi_tool/openapi_toolset.js +7 -13
  87. package/dist/cjs/tools/openapi_tool/rest_api_tool.js +17 -1
  88. package/dist/cjs/tools/retrieval/base_retrieval_tool.js +18 -3
  89. package/dist/cjs/tools/toolbox_toolset.js +174 -0
  90. package/dist/cjs/tools/webmcp/webmcp_toolset.js +1 -14
  91. package/dist/cjs/utils/client_labels.js +19 -2
  92. package/dist/cjs/utils/env_aware_utils.js +6 -8
  93. package/dist/cjs/utils/error_utils.js +11 -11
  94. package/dist/cjs/utils/failover_utils.js +1 -1
  95. package/dist/cjs/utils/file_extension_utils.js +11 -0
  96. package/dist/cjs/utils/file_utils.js +2 -24
  97. package/dist/cjs/utils/gemini_schema_util.js +28 -7
  98. package/dist/cjs/utils/json_utils.js +49 -0
  99. package/dist/cjs/utils/live_connection_utils.js +4 -5
  100. package/dist/cjs/utils/logger_node.js +11 -1
  101. package/dist/cjs/utils/object_notation_utils.js +6 -3
  102. package/dist/cjs/utils/output_schema_utils.js +5 -2
  103. package/dist/cjs/utils/streaming_utils.js +12 -12
  104. package/dist/cjs/utils/task.js +1 -1
  105. package/dist/cjs/version.js +1 -1
  106. package/dist/esm/a2a/a2a_remote_agent.js +4 -1
  107. package/dist/esm/a2a/agent_card.js +103 -27
  108. package/dist/esm/a2a/agent_to_a2a.js +5 -2
  109. package/dist/esm/agents/agent_engine_client.js +144 -0
  110. package/dist/esm/agents/base_agent.js +20 -4
  111. package/dist/esm/agents/functions.js +226 -25
  112. package/dist/esm/agents/instructions.js +6 -2
  113. package/dist/esm/agents/invocation_context.js +24 -4
  114. package/dist/esm/agents/langgraph_agent.js +123 -0
  115. package/dist/esm/agents/llm_agent.js +204 -110
  116. package/dist/esm/agents/processors/basic_llm_request_processor.js +1 -1
  117. package/dist/esm/agents/processors/code_execution_request_processor.js +21 -8
  118. package/dist/esm/agents/processors/content_processor_utils.js +38 -10
  119. package/dist/esm/agents/processors/content_request_processor.js +34 -2
  120. package/dist/esm/agents/processors/instructions_llm_request_processor.js +1 -1
  121. package/dist/esm/agents/processors/nl_planning_processor.js +12 -3
  122. package/dist/esm/artifacts/in_memory_artifact_service.js +14 -0
  123. package/dist/esm/auth/auth_handler.js +37 -5
  124. package/dist/esm/auth/auth_schemes.js +8 -0
  125. package/dist/esm/cli/cli_eval.js +510 -0
  126. package/dist/esm/cli/utils/envs.js +78 -0
  127. package/dist/esm/cli/utils/evals.js +109 -0
  128. package/dist/esm/cli/utils/logs.js +111 -0
  129. package/dist/esm/code_executors/agent_engine_sandbox_code_executor.js +7 -2
  130. package/dist/esm/code_executors/code_execution_utils.js +46 -16
  131. package/dist/esm/code_executors/code_executor_context.js +5 -2
  132. package/dist/esm/code_executors/container_code_executor.js +27 -16
  133. package/dist/esm/code_executors/unsafe_local_code_executor.js +6 -1
  134. package/dist/esm/common.js +65 -4
  135. package/dist/esm/context/summarizers/llm_summarizer.js +12 -10
  136. package/dist/esm/context/token_based_context_compactor.js +2 -1
  137. package/dist/esm/errors/input_validation_error.js +3 -2
  138. package/dist/esm/events/event.js +4 -2
  139. package/dist/esm/examples/example_util.js +21 -1
  140. package/dist/esm/flows/llm_flows/audio_transcriber.js +142 -0
  141. package/dist/esm/index.js +114 -2
  142. package/dist/esm/integrations/agent_registry/helpers.js +1 -1
  143. package/dist/esm/models/gemini_llm_connection.js +16 -8
  144. package/dist/esm/models/google_llm.js +14 -17
  145. package/dist/esm/models/llm_response.js +9 -1
  146. package/dist/esm/models/registry.js +1 -1
  147. package/dist/esm/models/routed_llm.js +9 -8
  148. package/dist/esm/planners/plan_re_act_planner.js +1 -1
  149. package/dist/esm/plugins/base_plugin.js +13 -23
  150. package/dist/esm/runner/in_memory_runner.js +6 -11
  151. package/dist/esm/runner/runner.js +105 -33
  152. package/dist/esm/sessions/base_session_service.js +12 -7
  153. package/dist/esm/sessions/database_session_service.js +49 -28
  154. package/dist/esm/sessions/db/operations.js +1 -1
  155. package/dist/esm/sessions/in_memory_session_service.js +3 -1
  156. package/dist/esm/sessions/stale_session_error.js +31 -0
  157. package/dist/esm/sessions/state.js +8 -4
  158. package/dist/esm/sessions/vertex_ai_session_service.js +34 -15
  159. package/dist/esm/skills/loader.js +51 -17
  160. package/dist/esm/telemetry/setup.js +1 -2
  161. package/dist/esm/telemetry/tracing.js +151 -74
  162. package/dist/esm/tools/agent_tool.js +44 -0
  163. package/dist/esm/tools/apihub_tool/apihub_toolset.js +101 -0
  164. package/dist/esm/tools/apihub_tool/clients/apihub_client.js +244 -0
  165. package/dist/esm/tools/apihub_tool/clients/secret_client.js +132 -0
  166. package/dist/esm/tools/apihub_tool/clients/service_account.js +21 -0
  167. package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +245 -0
  168. package/dist/esm/tools/application_integration_tool/clients/cloud_request.js +103 -0
  169. package/dist/esm/tools/application_integration_tool/clients/connections_client.js +629 -0
  170. package/dist/esm/tools/application_integration_tool/clients/integration_client.js +219 -0
  171. package/dist/esm/tools/application_integration_tool/integration_connector_tool.js +158 -0
  172. package/dist/esm/tools/example_tool.js +13 -1
  173. package/dist/esm/tools/function_tool.js +316 -0
  174. package/dist/esm/tools/google_api_tool/google_api_tool.js +73 -0
  175. package/dist/esm/tools/google_api_tool/google_api_toolset.js +146 -0
  176. package/dist/esm/tools/google_api_tool/google_api_toolsets.js +94 -0
  177. package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +393 -0
  178. package/dist/esm/tools/google_api_tool/index.js +31 -0
  179. package/dist/esm/tools/load_artifacts_tool.js +10 -5
  180. package/dist/esm/tools/load_memory_tool.js +12 -10
  181. package/dist/esm/tools/mcp/index.js +6 -0
  182. package/dist/esm/tools/mcp/mcp_session_manager.js +25 -0
  183. package/dist/esm/tools/mcp/mcp_toolset.js +1 -14
  184. package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +1 -2
  185. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +50 -3
  186. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +4 -3
  187. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
  188. package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
  189. package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
  190. package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +15 -2
  191. package/dist/esm/tools/openapi_tool/openapi_toolset.js +6 -12
  192. package/dist/esm/tools/openapi_tool/rest_api_tool.js +17 -1
  193. package/dist/esm/tools/retrieval/base_retrieval_tool.js +16 -2
  194. package/dist/esm/tools/toolbox_toolset.js +148 -0
  195. package/dist/esm/tools/webmcp/webmcp_toolset.js +1 -14
  196. package/dist/esm/utils/client_labels.js +19 -2
  197. package/dist/esm/utils/env_aware_utils.js +6 -8
  198. package/dist/esm/utils/error_utils.js +9 -10
  199. package/dist/esm/utils/failover_utils.js +1 -1
  200. package/dist/esm/utils/file_extension_utils.js +11 -0
  201. package/dist/esm/utils/file_utils.js +2 -23
  202. package/dist/esm/utils/gemini_schema_util.js +27 -7
  203. package/dist/esm/utils/json_utils.js +21 -0
  204. package/dist/esm/utils/live_connection_utils.js +4 -5
  205. package/dist/esm/utils/logger_node.js +11 -1
  206. package/dist/esm/utils/object_notation_utils.js +4 -2
  207. package/dist/esm/utils/output_schema_utils.js +5 -2
  208. package/dist/esm/utils/streaming_utils.js +11 -11
  209. package/dist/esm/utils/task.js +1 -1
  210. package/dist/esm/version.js +1 -1
  211. package/dist/types/a2a/a2a_remote_agent.d.ts +9 -0
  212. package/dist/types/a2a/agent_card.d.ts +44 -1
  213. package/dist/types/a2a/agent_to_a2a.d.ts +9 -0
  214. package/dist/types/a2a/index.d.ts +1 -0
  215. package/dist/types/agents/agent_engine_client.d.ts +37 -0
  216. package/dist/types/agents/base_agent.d.ts +12 -0
  217. package/dist/types/agents/functions.d.ts +33 -1
  218. package/dist/types/agents/invocation_context.d.ts +20 -1
  219. package/dist/types/agents/langgraph_agent.d.ts +153 -0
  220. package/dist/types/agents/llm_agent.d.ts +5 -1
  221. package/dist/types/agents/processors/content_processor_utils.d.ts +4 -2
  222. package/dist/types/agents/processors/nl_planning_processor.d.ts +2 -1
  223. package/dist/types/auth/auth_handler.d.ts +28 -1
  224. package/dist/types/auth/auth_schemes.d.ts +13 -0
  225. package/dist/types/cli/cli_eval.d.ts +173 -0
  226. package/dist/types/cli/utils/envs.d.ts +23 -0
  227. package/dist/types/cli/utils/evals.d.ts +47 -0
  228. package/dist/types/cli/utils/logs.d.ts +38 -0
  229. package/dist/types/code_executors/code_execution_utils.d.ts +39 -0
  230. package/dist/types/code_executors/code_executor_context.d.ts +1 -0
  231. package/dist/types/code_executors/container_code_executor.d.ts +17 -5
  232. package/dist/types/common.d.ts +24 -5
  233. package/dist/types/errors/input_validation_error.d.ts +2 -1
  234. package/dist/types/events/event.d.ts +4 -0
  235. package/dist/types/examples/example_util.d.ts +17 -0
  236. package/dist/types/flows/llm_flows/audio_transcriber.d.ts +85 -0
  237. package/dist/types/index.d.ts +19 -2
  238. package/dist/types/models/gemini_llm_connection.d.ts +6 -7
  239. package/dist/types/models/routed_llm.d.ts +1 -1
  240. package/dist/types/plugins/base_plugin.d.ts +0 -10
  241. package/dist/types/runner/in_memory_runner.d.ts +2 -1
  242. package/dist/types/runner/runner.d.ts +34 -0
  243. package/dist/types/sessions/base_session_service.d.ts +5 -0
  244. package/dist/types/sessions/database_session_service.d.ts +17 -1
  245. package/dist/types/sessions/stale_session_error.d.ts +21 -0
  246. package/dist/types/sessions/state.d.ts +5 -1
  247. package/dist/types/sessions/vertex_ai_session_service.d.ts +8 -0
  248. package/dist/types/skills/loader.d.ts +3 -2
  249. package/dist/types/skills/skill.d.ts +1 -1
  250. package/dist/types/telemetry/tracing.d.ts +20 -4
  251. package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +115 -0
  252. package/dist/types/tools/apihub_tool/clients/apihub_client.d.ts +142 -0
  253. package/dist/types/tools/apihub_tool/clients/secret_client.d.ts +55 -0
  254. package/dist/types/tools/apihub_tool/clients/service_account.d.ts +11 -0
  255. package/dist/types/tools/application_integration_tool/application_integration_toolset.d.ts +109 -0
  256. package/dist/types/tools/application_integration_tool/clients/cloud_request.d.ts +53 -0
  257. package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +229 -0
  258. package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +72 -0
  259. package/dist/types/tools/application_integration_tool/integration_connector_tool.d.ts +70 -0
  260. package/dist/types/tools/base_toolset.d.ts +6 -5
  261. package/dist/types/tools/example_tool.d.ts +10 -0
  262. package/dist/types/tools/function_tool.d.ts +32 -0
  263. package/dist/types/tools/google_api_tool/google_api_tool.d.ts +37 -0
  264. package/dist/types/tools/google_api_tool/google_api_toolset.d.ts +55 -0
  265. package/dist/types/tools/google_api_tool/google_api_toolsets.d.ts +48 -0
  266. package/dist/types/tools/google_api_tool/googleapi_to_openapi_converter.d.ts +165 -0
  267. package/dist/types/tools/google_api_tool/index.d.ts +10 -0
  268. package/dist/types/tools/load_artifacts_tool.d.ts +14 -1
  269. package/dist/types/tools/load_memory_tool.d.ts +23 -1
  270. package/dist/types/tools/mcp/index.d.ts +3 -0
  271. package/dist/types/tools/mcp/mcp_session_manager.d.ts +34 -1
  272. package/dist/types/tools/mcp/mcp_toolset.d.ts +15 -0
  273. package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +19 -0
  274. package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +18 -1
  275. package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +12 -0
  276. package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +8 -0
  277. package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +2 -1
  278. package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +5 -0
  279. package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +10 -0
  280. package/dist/types/tools/retrieval/base_retrieval_tool.d.ts +15 -0
  281. package/dist/types/tools/toolbox_toolset.d.ts +159 -0
  282. package/dist/types/utils/client_labels.d.ts +2 -1
  283. package/dist/types/utils/env_aware_utils.d.ts +18 -2
  284. package/dist/types/utils/error_utils.d.ts +7 -0
  285. package/dist/types/utils/file_utils.d.ts +6 -1
  286. package/dist/types/utils/gemini_schema_util.d.ts +9 -2
  287. package/dist/types/utils/json_utils.d.ts +11 -0
  288. package/dist/types/utils/object_notation_utils.d.ts +7 -0
  289. package/dist/types/utils/output_schema_utils.d.ts +3 -2
  290. package/dist/types/utils/simple_zod_to_json.d.ts +1 -2
  291. package/dist/types/utils/streaming_utils.d.ts +11 -4
  292. package/dist/types/version.d.ts +1 -1
  293. package/dist/web/index_web.js +117 -110
  294. package/dist/web/index_web.js.map +4 -4
  295. package/package.json +38 -26
  296. package/dist/cjs/models/gemini_continuation.js +0 -232
  297. package/dist/esm/models/gemini_continuation.js +0 -205
  298. package/dist/types/models/gemini_continuation.d.ts +0 -59
@@ -38,11 +38,13 @@ var import_base_tool = require("./base_tool.js");
38
38
  * SPDX-License-Identifier: Apache-2.0
39
39
  */
40
40
  const _LoadMemoryTool = class _LoadMemoryTool extends import_base_tool.BaseTool {
41
- constructor() {
41
+ constructor(options = {}) {
42
+ var _a;
42
43
  super({
43
44
  name: "load_memory",
44
45
  description: "Loads the memory for the current user.\n\nNOTE: Currently this tool only uses text part from the memory."
45
46
  });
47
+ this.textOnlyContent = (_a = options.textOnlyContent) != null ? _a : false;
46
48
  }
47
49
  _getDeclaration() {
48
50
  return {
@@ -64,12 +66,12 @@ const _LoadMemoryTool = class _LoadMemoryTool extends import_base_tool.BaseTool
64
66
  args,
65
67
  toolContext
66
68
  }) {
67
- try {
68
- const query = args["query"];
69
- if (!toolContext.invocationContext.memoryService) {
70
- throw new Error("Memory service is not initialized.");
71
- }
72
- const searchMemoryResponse = await toolContext.searchMemory(query);
69
+ const query = args["query"];
70
+ if (!toolContext.invocationContext.memoryService) {
71
+ throw new Error("Memory service is not initialized.");
72
+ }
73
+ const searchMemoryResponse = await toolContext.searchMemory(query);
74
+ if (this.textOnlyContent) {
73
75
  return {
74
76
  memories: searchMemoryResponse.memories.map((m) => {
75
77
  var _a, _b;
@@ -84,10 +86,10 @@ const _LoadMemoryTool = class _LoadMemoryTool extends import_base_tool.BaseTool
84
86
  };
85
87
  })
86
88
  };
87
- } catch (e) {
88
- console.error("ERROR in LoadMemoryTool runAsync:", e);
89
- throw e;
90
89
  }
90
+ return {
91
+ memories: searchMemoryResponse.memories
92
+ };
91
93
  }
92
94
  async processLlmRequest(request) {
93
95
  await super.processLlmRequest(request);
@@ -9,6 +9,10 @@ var __defProp = Object.defineProperty;
9
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
10
  var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __export = (target, all) => {
13
+ for (var name in all)
14
+ __defProp(target, name, { get: all[name], enumerable: true });
15
+ };
12
16
  var __copyProps = (to, from, except, desc) => {
13
17
  if (from && typeof from === "object" || typeof from === "function") {
14
18
  for (let key of __getOwnPropNames(from))
@@ -20,7 +24,13 @@ var __copyProps = (to, from, except, desc) => {
20
24
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
25
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
26
  var mcp_exports = {};
27
+ __export(mcp_exports, {
28
+ genaiSchemaToJsonSchema: () => import_genai_schema_to_json.genaiSchemaToJsonSchema,
29
+ toGeminiSchema: () => import_gemini_schema_util.toGeminiSchema
30
+ });
23
31
  module.exports = __toCommonJS(mcp_exports);
32
+ var import_gemini_schema_util = require("../../utils/gemini_schema_util.js");
33
+ var import_genai_schema_to_json = require("../../utils/genai_schema_to_json.js");
24
34
  __reExport(mcp_exports, require("./load_mcp_resource_tool.js"), module.exports);
25
35
  __reExport(mcp_exports, require("./mcp_session_manager.js"), module.exports);
26
36
  __reExport(mcp_exports, require("./mcp_tool.js"), module.exports);
@@ -32,6 +42,8 @@ __reExport(mcp_exports, require("./mcp_toolset.js"), module.exports);
32
42
  */
33
43
  // Annotate the CommonJS export names for ESM import in node:
34
44
  0 && (module.exports = {
45
+ genaiSchemaToJsonSchema,
46
+ toGeminiSchema,
35
47
  ...require("./load_mcp_resource_tool.js"),
36
48
  ...require("./mcp_session_manager.js"),
37
49
  ...require("./mcp_tool.js"),
@@ -67,6 +67,18 @@ function buildTransportOptions(params) {
67
67
  };
68
68
  }
69
69
  __name(buildTransportOptions, "buildTransportOptions");
70
+ function buildSseTransportOptions(params) {
71
+ const { transportOptions, header, headers } = params;
72
+ const callerHeaders = (transportOptions == null ? void 0 : transportOptions.requestInit) === void 0 ? header != null ? header : headers : transportOptions.requestInit.headers;
73
+ return {
74
+ ...transportOptions,
75
+ requestInit: {
76
+ ...transportOptions == null ? void 0 : transportOptions.requestInit,
77
+ headers: (0, import_client_labels.mergeTrackingHeaders)(callerHeaders)
78
+ }
79
+ };
80
+ }
81
+ __name(buildSseTransportOptions, "buildSseTransportOptions");
70
82
  const _MCPSessionManager = class _MCPSessionManager {
71
83
  constructor(connectionParams) {
72
84
  this.activeSessions = /* @__PURE__ */ new Set();
@@ -105,6 +117,19 @@ const _MCPSessionManager = class _MCPSessionManager {
105
117
  await client.connect(transport);
106
118
  break;
107
119
  }
120
+ case "SseConnectionParams": {
121
+ const { SSEClientTransport } = await (0, import_optional_peer.loadOptionalPeer)(
122
+ MCP_SDK,
123
+ () => Promise.resolve().then(() => __toESM(require("@modelcontextprotocol/sdk/client/sse.js"), 1))
124
+ );
125
+ const transport = new SSEClientTransport(
126
+ new URL(this.connectionParams.url),
127
+ buildSseTransportOptions(this.connectionParams)
128
+ );
129
+ transport.onerror = logTransportError;
130
+ await client.connect(transport);
131
+ break;
132
+ }
108
133
  default: {
109
134
  const _exhaustiveCheck = this.connectionParams;
110
135
  break;
@@ -61,20 +61,7 @@ const _MCPToolset = class _MCPToolset extends import_base_toolset.BaseToolset {
61
61
  };
62
62
  return new import_mcp_tool.MCPTool(toolWithPrefix, this.mcpSessionManager, tool.name);
63
63
  });
64
- const filter = this.toolFilter;
65
- if (!filter || Array.isArray(filter) && filter.length === 0) {
66
- return tools;
67
- }
68
- if (Array.isArray(filter)) {
69
- return tools.filter((tool) => filter.includes(tool.name));
70
- }
71
- if (context) {
72
- return tools.filter((tool) => filter(tool, context));
73
- }
74
- import_logger.logger.warn(
75
- "MCPToolset: a ToolPredicate toolFilter was provided but getTools() was called without a ReadonlyContext. The filter will not be applied."
76
- );
77
- return tools;
64
+ return tools.filter((tool) => this.isToolSelected(tool, context));
78
65
  }
79
66
  /**
80
67
  * Lists the names of the resources advertised by the MCP server.
@@ -165,12 +165,11 @@ function bearerJwtScheme() {
165
165
  }
166
166
  __name(bearerJwtScheme, "bearerJwtScheme");
167
167
  function bearerTokenParam(authScheme, token) {
168
- var _a;
169
168
  const param = {
170
169
  originalName: "Authorization",
171
170
  paramLocation: "header",
172
171
  paramSchema: { type: "string" },
173
- description: (_a = authScheme.description) != null ? _a : "Bearer token",
172
+ description: authScheme.description || "Bearer token",
174
173
  name: `${INTERNAL_AUTH_PREFIX}Authorization`,
175
174
  required: true
176
175
  };
@@ -37,14 +37,48 @@ __export(auto_auth_credential_exchanger_exports, {
37
37
  });
38
38
  module.exports = __toCommonJS(auto_auth_credential_exchanger_exports);
39
39
  var import_auth_credential = require("../../../../auth/auth_credential.js");
40
+ var import_auth_schemes = require("../../../../auth/auth_schemes.js");
40
41
  var import_oauth2_credential_exchanger = require("../../../../auth/oauth2/oauth2_credential_exchanger.js");
41
42
  var import_experimental = require("../../../../utils/experimental.js");
43
+ var import_oauth2_exchanger = require("./oauth2_exchanger.js");
42
44
  var import_service_account_exchanger = require("./service_account_exchanger.js");
43
45
  /**
44
46
  * @license
45
47
  * Copyright 2026 Google LLC
46
48
  * SPDX-License-Identifier: Apache-2.0
47
49
  */
50
+ function isPendingAuthorizationCode(authScheme, authCredential) {
51
+ var _a, _b, _c;
52
+ return !!authScheme && (0, import_oauth2_credential_exchanger.determineGrantType)(authScheme) === import_auth_schemes.OAuthGrantType.AUTHORIZATION_CODE && !((_a = authCredential.oauth2) == null ? void 0 : _a.accessToken) && !((_b = authCredential.oauth2) == null ? void 0 : _b.authCode) && !((_c = authCredential.oauth2) == null ? void 0 : _c.authResponseUri);
53
+ }
54
+ __name(isPendingAuthorizationCode, "isPendingAuthorizationCode");
55
+ function createDefaultOAuth2Exchanger() {
56
+ const tokenFetcher = new import_oauth2_credential_exchanger.OAuth2CredentialExchanger();
57
+ return {
58
+ async exchange(params) {
59
+ const { authScheme, authCredential } = params;
60
+ if (authScheme && authCredential.http) {
61
+ return {
62
+ credential: authCredential,
63
+ wasExchanged: false
64
+ };
65
+ }
66
+ if (isPendingAuthorizationCode(authScheme, authCredential)) {
67
+ return {
68
+ credential: authCredential,
69
+ wasExchanged: false
70
+ };
71
+ }
72
+ const { credential, wasExchanged } = await tokenFetcher.exchange(params);
73
+ const bearer = (0, import_oauth2_exchanger.generateAuthToken)(credential);
74
+ return {
75
+ credential: bearer,
76
+ wasExchanged: wasExchanged || bearer !== credential
77
+ };
78
+ }
79
+ };
80
+ }
81
+ __name(createDefaultOAuth2Exchanger, "createDefaultOAuth2Exchanger");
48
82
  let AutoAuthCredentialExchanger = class {
49
83
  /**
50
84
  * @param customExchangers - Optional exchangers that add to or override the
@@ -52,14 +86,24 @@ let AutoAuthCredentialExchanger = class {
52
86
  * exchanger instance to use for that type.
53
87
  */
54
88
  constructor(customExchangers) {
89
+ /**
90
+ * The exchanger used for each auth credential type.
91
+ *
92
+ * By default `OAUTH2` and `OPEN_ID_CONNECT` run
93
+ * {@link OAuth2CredentialExchanger} and convert any access token with
94
+ * {@link generateAuthToken}, and `SERVICE_ACCOUNT` maps to a
95
+ * {@link ServiceAccountCredentialExchanger}, with any custom exchangers from
96
+ * the constructor merged over them. The map is live: an entry added or
97
+ * replaced after construction is used by the next {@link exchange} call.
98
+ */
55
99
  this.exchangers = /* @__PURE__ */ new Map();
56
100
  this.exchangers.set(
57
101
  import_auth_credential.AuthCredentialTypes.OAUTH2,
58
- new import_oauth2_credential_exchanger.OAuth2CredentialExchanger()
102
+ createDefaultOAuth2Exchanger()
59
103
  );
60
104
  this.exchangers.set(
61
105
  import_auth_credential.AuthCredentialTypes.OPEN_ID_CONNECT,
62
- new import_oauth2_credential_exchanger.OAuth2CredentialExchanger()
106
+ createDefaultOAuth2Exchanger()
63
107
  );
64
108
  this.exchangers.set(
65
109
  import_auth_credential.AuthCredentialTypes.SERVICE_ACCOUNT,
@@ -40,6 +40,7 @@ __export(oauth2_exchanger_exports, {
40
40
  });
41
41
  module.exports = __toCommonJS(oauth2_exchanger_exports);
42
42
  var import_auth_credential = require("../../../../auth/auth_credential.js");
43
+ var import_auth_schemes = require("../../../../auth/auth_schemes.js");
43
44
  var import_experimental = require("../../../../utils/experimental.js");
44
45
  /**
45
46
  * @license
@@ -52,7 +53,7 @@ function checkSchemeCredentialType(authScheme, authCredential) {
52
53
  "auth_credential is empty. Please create AuthCredential using OAuth2Auth."
53
54
  );
54
55
  }
55
- if (authScheme.type !== "openIdConnect" && authScheme.type !== "oauth2") {
56
+ if (authScheme.type !== import_auth_schemes.AuthSchemeType.OPEN_ID_CONNECT && authScheme.type !== import_auth_schemes.AuthSchemeType.OAUTH2) {
56
57
  throw new Error(
57
58
  `Invalid security scheme, expect AuthSchemeType.openIdConnect or AuthSchemeType.oauth2 auth scheme, but got ${authScheme.type}`
58
59
  );
@@ -80,12 +81,12 @@ function generateAuthToken(authCredential) {
80
81
  }
81
82
  __name(generateAuthToken, "generateAuthToken");
82
83
  function exchangeCredential(authScheme, authCredential) {
83
- var _a, _b;
84
+ var _a;
84
85
  checkSchemeCredentialType(authScheme, authCredential);
85
86
  if (authCredential.http) {
86
87
  return authCredential;
87
88
  }
88
- if (((_a = authCredential.oauth2) == null ? void 0 : _a.accessToken) || ((_b = authCredential.oauth2) == null ? void 0 : _b.refreshToken)) {
89
+ if ((_a = authCredential.oauth2) == null ? void 0 : _a.accessToken) {
89
90
  return generateAuthToken(authCredential);
90
91
  }
91
92
  return null;
@@ -37,6 +37,7 @@ __export(service_account_exchanger_exports, {
37
37
  });
38
38
  module.exports = __toCommonJS(service_account_exchanger_exports);
39
39
  var import_google_auth_library = require("google-auth-library");
40
+ var import_node_crypto = require("node:crypto");
40
41
  var import_auth_credential = require("../../../../auth/auth_credential.js");
41
42
  var import_experimental = require("../../../../utils/experimental.js");
42
43
  var import_base_auth_credential_exchanger = require("./base_auth_credential_exchanger.js");
@@ -47,6 +48,83 @@ var import_base_auth_credential_exchanger = require("./base_auth_credential_exch
47
48
  */
48
49
  const DEFAULT_SCOPES = ["https://www.googleapis.com/auth/cloud-platform"];
49
50
  const MISSING_SERVICE_ACCOUNT_CREDENTIALS = "Service account credentials are missing. Please provide them, or set `useDefaultCredential: true` to use application default credentials in a hosted service like Cloud Run.";
51
+ const GOOGLE_TOKEN_URI = "https://oauth2.googleapis.com/token";
52
+ const JWT_BEARER_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer";
53
+ const ASSERTION_LIFETIME_SECONDS = 3600;
54
+ const TOKEN_REQUEST_TIMEOUT_MS = 3e4;
55
+ function hasCustomTokenUri(creds) {
56
+ return !!creds.tokenUri && creds.tokenUri !== GOOGLE_TOKEN_URI;
57
+ }
58
+ __name(hasCustomTokenUri, "hasCustomTokenUri");
59
+ function base64UrlJson(value) {
60
+ return Buffer.from(JSON.stringify(value)).toString("base64url");
61
+ }
62
+ __name(base64UrlJson, "base64UrlJson");
63
+ function signJwtBearerAssertion(creds, scopes, issuedAt) {
64
+ const header = {
65
+ alg: "RS256",
66
+ typ: "JWT",
67
+ ...creds.privateKeyId ? { kid: creds.privateKeyId } : {}
68
+ };
69
+ const payload = {
70
+ iss: creds.clientEmail,
71
+ scope: scopes.join(" "),
72
+ aud: GOOGLE_TOKEN_URI,
73
+ iat: issuedAt,
74
+ exp: issuedAt + ASSERTION_LIFETIME_SECONDS
75
+ };
76
+ const signingInput = `${base64UrlJson(header)}.${base64UrlJson(payload)}`;
77
+ const signature = (0, import_node_crypto.createSign)("RSA-SHA256").update(signingInput).sign(creds.privateKey, "base64url");
78
+ return `${signingInput}.${signature}`;
79
+ }
80
+ __name(signJwtBearerAssertion, "signJwtBearerAssertion");
81
+ async function readTokenErrorDetail(response) {
82
+ try {
83
+ const body = await response.json();
84
+ if (typeof body !== "object" || body === null) {
85
+ return void 0;
86
+ }
87
+ const parts = [];
88
+ if ("error" in body && typeof body.error === "string" && body.error.length > 0) {
89
+ parts.push(body.error);
90
+ }
91
+ if ("error_description" in body && typeof body.error_description === "string" && body.error_description.length > 0) {
92
+ parts.push(body.error_description);
93
+ }
94
+ return parts.length > 0 ? parts.join(": ") : void 0;
95
+ } catch {
96
+ return void 0;
97
+ }
98
+ }
99
+ __name(readTokenErrorDetail, "readTokenErrorDetail");
100
+ async function requestJwtBearerToken(creds, scopes) {
101
+ const assertion = signJwtBearerAssertion(
102
+ creds,
103
+ scopes,
104
+ Math.floor(Date.now() / 1e3)
105
+ );
106
+ const response = await fetch(creds.tokenUri, {
107
+ method: "POST",
108
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
109
+ body: new URLSearchParams({
110
+ grant_type: JWT_BEARER_GRANT_TYPE,
111
+ assertion
112
+ }),
113
+ signal: AbortSignal.timeout(TOKEN_REQUEST_TIMEOUT_MS)
114
+ });
115
+ if (!response.ok) {
116
+ const detail = await readTokenErrorDetail(response);
117
+ throw new Error(
118
+ detail ? `Token endpoint responded with HTTP ${response.status}: ${detail}` : `Token endpoint responded with HTTP ${response.status}`
119
+ );
120
+ }
121
+ const body = await response.json();
122
+ if (typeof body === "object" && body !== null && "access_token" in body && typeof body.access_token === "string") {
123
+ return body.access_token;
124
+ }
125
+ return void 0;
126
+ }
127
+ __name(requestJwtBearerToken, "requestJwtBearerToken");
50
128
  let ServiceAccountCredentialExchanger = class {
51
129
  async exchange(params) {
52
130
  const { authCredential } = params;
@@ -87,21 +165,27 @@ let ServiceAccountCredentialExchanger = class {
87
165
  }
88
166
  }
89
167
  async exchangeForExplicitCredential(saConfig) {
168
+ var _a;
90
169
  const creds = saConfig.serviceAccountCredential;
91
170
  if (!creds) {
92
171
  throw new import_base_auth_credential_exchanger.AuthCredentialMissingError(MISSING_SERVICE_ACCOUNT_CREDENTIALS);
93
172
  }
94
173
  try {
95
- const client = new import_google_auth_library.JWT({
96
- email: creds.clientEmail,
97
- key: creds.privateKey,
98
- keyId: creds.privateKeyId,
99
- projectId: creds.projectId,
100
- universeDomain: creds.universeDomain,
101
- scopes: saConfig.scopes
102
- });
103
- const tokens = await client.authorize();
104
- const token = tokens.access_token;
174
+ let token;
175
+ if (hasCustomTokenUri(creds)) {
176
+ token = await requestJwtBearerToken(creds, (_a = saConfig.scopes) != null ? _a : []);
177
+ } else {
178
+ const client = new import_google_auth_library.JWT({
179
+ email: creds.clientEmail,
180
+ key: creds.privateKey,
181
+ keyId: creds.privateKeyId,
182
+ projectId: creds.projectId,
183
+ universeDomain: creds.universeDomain,
184
+ scopes: saConfig.scopes
185
+ });
186
+ const tokens = await client.authorize();
187
+ token = tokens.access_token;
188
+ }
105
189
  if (!token) {
106
190
  throw new Error("Failed to get access token from explicit credentials");
107
191
  }
@@ -54,15 +54,27 @@ const VALID_SCHEMA_TYPES = /* @__PURE__ */ new Set([
54
54
  "string"
55
55
  ]);
56
56
  let OpenApiSpecParser = class {
57
+ /**
58
+ * @param options.preservePropertyNames Keeps the original parameter and
59
+ * function names instead of converting them to snake_case.
60
+ * @param options.unconstrainedObjectBodyAsParameter Emits a whole-body
61
+ * parameter named `body` when an object request body schema has no
62
+ * properties. Defaults to `false`.
63
+ * @deprecated Retained for backwards compatibility; empty object schemas
64
+ * produce no parameters by default. This option will be removed in a
65
+ * future release.
66
+ */
57
67
  constructor(options = {}) {
58
- var _a;
68
+ var _a, _b;
59
69
  this.preservePropertyNames = (_a = options.preservePropertyNames) != null ? _a : false;
70
+ this.unconstrainedObjectBodyAsParameter = (_b = options.unconstrainedObjectBodyAsParameter) != null ? _b : false;
60
71
  }
61
72
  parse(openapiSpec) {
62
73
  const resolvedSpec = resolveReferences(openapiSpec);
63
74
  const sanitizedSpec = sanitizeSchemaTypes(resolvedSpec);
64
75
  return collectOperations(sanitizedSpec, {
65
- preservePropertyNames: this.preservePropertyNames
76
+ preservePropertyNames: this.preservePropertyNames,
77
+ unconstrainedObjectBodyAsParameter: this.unconstrainedObjectBodyAsParameter
66
78
  });
67
79
  }
68
80
  };
@@ -197,17 +209,18 @@ function resolveServerUrl(server) {
197
209
  }
198
210
  __name(resolveServerUrl, "resolveServerUrl");
199
211
  function collectOperations(spec, options = {}) {
200
- var _a, _b, _c;
212
+ var _a, _b, _c, _d;
201
213
  const preservePropertyNames = (_a = options.preservePropertyNames) != null ? _a : false;
214
+ const unconstrainedObjectBodyAsParameter = (_b = options.unconstrainedObjectBodyAsParameter) != null ? _b : false;
202
215
  const operations = [];
203
- const server = (_b = spec.servers) == null ? void 0 : _b[0];
216
+ const server = (_c = spec.servers) == null ? void 0 : _c[0];
204
217
  const baseUrl = server ? resolveServerUrl(server) : "";
205
218
  const globalSecurity = spec.security || [];
206
219
  let globalSchemeName;
207
220
  if (globalSecurity.length > 0) {
208
221
  globalSchemeName = Object.keys(globalSecurity[0])[0];
209
222
  }
210
- const authSchemes = ((_c = spec.components) == null ? void 0 : _c.securitySchemes) || {};
223
+ const authSchemes = ((_d = spec.components) == null ? void 0 : _d.securitySchemes) || {};
211
224
  for (const [path, pathItem] of Object.entries(spec.paths || {})) {
212
225
  if (!pathItem) continue;
213
226
  const methods = [
@@ -230,7 +243,8 @@ function collectOperations(spec, options = {}) {
230
243
  operation.operationId = (0, import_case_utils.toSnakeCaseName)(`${path}_${method}`);
231
244
  }
232
245
  const parser = new import_operation_parser.OperationParser(operation, {
233
- preservePropertyNames
246
+ preservePropertyNames,
247
+ unconstrainedObjectBodyAsParameter
234
248
  });
235
249
  let authSchemeName;
236
250
  if (operation.security && operation.security.length > 0) {
@@ -52,13 +52,20 @@ let OperationParser = class {
52
52
  * function names instead of converting them to snake_case.
53
53
  * @param options.shouldParse Whether to parse the operation during
54
54
  * construction. Defaults to `true`.
55
+ * @param options.unconstrainedObjectBodyAsParameter Emits a whole-body
56
+ * parameter named `body` when an object request body schema has no
57
+ * properties. Defaults to `false`.
58
+ * @deprecated Retained for backwards compatibility; empty object schemas
59
+ * produce no parameters by default. This option will be removed in a
60
+ * future release.
55
61
  */
56
62
  constructor(operation, options = {}) {
57
63
  this.params = [];
58
- var _a, _b;
64
+ var _a, _b, _c;
59
65
  this.operation = typeof operation === "string" ? JSON.parse(operation) : operation;
60
66
  this.preservePropertyNames = (_a = options.preservePropertyNames) != null ? _a : false;
61
- if ((_b = options.shouldParse) != null ? _b : true) {
67
+ this.unconstrainedObjectBodyAsParameter = (_b = options.unconstrainedObjectBodyAsParameter) != null ? _b : false;
68
+ if ((_c = options.shouldParse) != null ? _c : true) {
62
69
  this.processOperationParameters();
63
70
  this.processRequestBody();
64
71
  this.returnValue = this.processReturnValue();
@@ -78,6 +85,7 @@ let OperationParser = class {
78
85
  return (0, import_case_utils.renameReservedKeywords)((0, import_case_utils.toSnakeCaseName)(originalName));
79
86
  }
80
87
  processOperationParameters() {
88
+ var _a;
81
89
  const parameters = this.operation.parameters || [];
82
90
  for (const param of parameters) {
83
91
  if ("name" in param) {
@@ -88,9 +96,12 @@ let OperationParser = class {
88
96
  this.params.push({
89
97
  originalName,
90
98
  paramLocation: location,
91
- paramSchema: schema,
99
+ paramSchema: {
100
+ ...schema,
101
+ description: schema.description || description || void 0
102
+ },
92
103
  description,
93
- required: param.required || false,
104
+ required: (_a = param.required) != null ? _a : false,
94
105
  name: this.getParamName(originalName)
95
106
  });
96
107
  }
@@ -126,7 +137,7 @@ let OperationParser = class {
126
137
  });
127
138
  }
128
139
  }
129
- } else {
140
+ } else if (this.unconstrainedObjectBodyAsParameter) {
130
141
  this.params.push({
131
142
  originalName: "",
132
143
  paramLocation: "body",
@@ -147,7 +158,7 @@ let OperationParser = class {
147
158
  });
148
159
  } else {
149
160
  this.params.push({
150
- originalName: "body",
161
+ originalName: "",
151
162
  paramLocation: "body",
152
163
  paramSchema: schema,
153
164
  description,
@@ -50,6 +50,16 @@ var import_base_auth_credential_exchanger = require("../auth/credential_exchange
50
50
  * SPDX-License-Identifier: Apache-2.0
51
51
  */
52
52
  const DEFAULT_CREDENTIAL_KEY = "default_openapi_key";
53
+ const INTERACTIVE_CREDENTIAL_TYPES = /* @__PURE__ */ new Set([
54
+ import_auth_credential.AuthCredentialTypes.OAUTH2,
55
+ import_auth_credential.AuthCredentialTypes.OPEN_ID_CONNECT
56
+ ]);
57
+ function isMissingInteractiveToken(result) {
58
+ var _a, _b;
59
+ const { credential, wasExchanged } = result;
60
+ return !wasExchanged && INTERACTIVE_CREDENTIAL_TYPES.has(credential.authType) && !credential.http && !((_a = credential.oauth2) == null ? void 0 : _a.accessToken) && !((_b = credential.oauth2) == null ? void 0 : _b.refreshToken);
61
+ }
62
+ __name(isMissingInteractiveToken, "isMissingInteractiveToken");
53
63
  const _ToolContextCredentialStore = class _ToolContextCredentialStore {
54
64
  constructor(context) {
55
65
  this.context = context;
@@ -165,7 +175,8 @@ let ToolAuthHandler = class {
165
175
  };
166
176
  }
167
177
  /**
168
- * Exchanges `credential`, or returns `undefined` when the exchange failed.
178
+ * Exchanges `credential`, or returns `undefined` when the exchange failed or
179
+ * produced an interactive credential that still holds no token.
169
180
  *
170
181
  * An exchange failure is transient far more often than it is fatal, so it
171
182
  * becomes a `pending` result the client can resume from rather than an
@@ -175,10 +186,11 @@ let ToolAuthHandler = class {
175
186
  var _a;
176
187
  const exchanger = (_a = this.credentialExchanger) != null ? _a : new import_auto_auth_credential_exchanger.AutoAuthCredentialExchanger();
177
188
  try {
178
- return await exchanger.exchange({
189
+ const result = await exchanger.exchange({
179
190
  authScheme: this.authScheme,
180
191
  authCredential: credential
181
192
  });
193
+ return isMissingInteractiveToken(result) ? void 0 : result;
182
194
  } catch (e) {
183
195
  import_logger.logger.error(
184
196
  `Failed to exchange credential: ${e instanceof Error ? e.message : e}`
@@ -46,7 +46,7 @@ __export(openapi_toolset_exports, {
46
46
  OpenAPIToolset: () => OpenAPIToolset
47
47
  });
48
48
  module.exports = __toCommonJS(openapi_toolset_exports);
49
- var import_js_yaml = __toESM(require("js-yaml"), 1);
49
+ var yaml = __toESM(require("js-yaml"), 1);
50
50
  var import_experimental = require("../../utils/experimental.js");
51
51
  var import_logger = require("../../utils/logger.js");
52
52
  var import_base_toolset = require("../base_toolset.js");
@@ -64,7 +64,7 @@ let OpenAPIToolset = class extends import_base_toolset.BaseToolset {
64
64
  let spec = options.specDict;
65
65
  if (!spec && options.specStr) {
66
66
  if (options.specType === "yaml" || !options.specType && options.specStr.trim().startsWith("---")) {
67
- spec = import_js_yaml.default.load(options.specStr);
67
+ spec = yaml.load(options.specStr);
68
68
  } else if (options.specType === "json" || !options.specType) {
69
69
  spec = JSON.parse(options.specStr);
70
70
  } else {
@@ -75,7 +75,8 @@ let OpenAPIToolset = class extends import_base_toolset.BaseToolset {
75
75
  throw new Error("Either specDict or specStr must be provided.");
76
76
  }
77
77
  const parser = new import_openapi_spec_parser.OpenApiSpecParser({
78
- preservePropertyNames: options.preservePropertyNames
78
+ preservePropertyNames: options.preservePropertyNames,
79
+ unconstrainedObjectBodyAsParameter: options.unconstrainedObjectBodyAsParameter
79
80
  });
80
81
  const parsedOperations = parser.parse(spec);
81
82
  for (const op of parsedOperations) {
@@ -96,7 +97,8 @@ let OpenAPIToolset = class extends import_base_toolset.BaseToolset {
96
97
  {
97
98
  preservePropertyNames: options.preservePropertyNames,
98
99
  headerProvider: options.headerProvider,
99
- credentialKey: options.credentialKey
100
+ credentialKey: options.credentialKey,
101
+ unconstrainedObjectBodyAsParameter: options.unconstrainedObjectBodyAsParameter
100
102
  }
101
103
  );
102
104
  this.tools.push(tool);
@@ -111,15 +113,7 @@ let OpenAPIToolset = class extends import_base_toolset.BaseToolset {
111
113
  }
112
114
  }
113
115
  async getTools(context) {
114
- return this.tools.filter((tool) => {
115
- if (Array.isArray(this.toolFilter) && this.toolFilter.length > 0) {
116
- return this.toolFilter.includes(tool.name);
117
- }
118
- if (context) {
119
- return this.isToolSelected(tool, context);
120
- }
121
- return true;
122
- });
116
+ return this.tools.filter((tool) => this.isToolSelected(tool, context));
123
117
  }
124
118
  getTool(toolName) {
125
119
  return this.tools.find((tool) => tool.name === toolName);
@@ -203,6 +203,22 @@ function encodePathParamValue(name, value) {
203
203
  return encodeURIComponent(value);
204
204
  }
205
205
  __name(encodePathParamValue, "encodePathParamValue");
206
+ function serializeQueryValue(value) {
207
+ return typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
208
+ }
209
+ __name(serializeQueryValue, "serializeQueryValue");
210
+ function appendQueryParam(queryParams, name, value) {
211
+ if (!Array.isArray(value)) {
212
+ queryParams.append(name, serializeQueryValue(value));
213
+ return;
214
+ }
215
+ for (const item of value) {
216
+ if (item !== void 0 && item !== null) {
217
+ queryParams.append(name, serializeQueryValue(item));
218
+ }
219
+ }
220
+ }
221
+ __name(appendQueryParam, "appendQueryParam");
206
222
  function prepareRequestParams(endpoint, parameters, args) {
207
223
  const headers = {};
208
224
  const queryParams = new URLSearchParams();
@@ -223,7 +239,7 @@ function prepareRequestParams(endpoint, parameters, args) {
223
239
  );
224
240
  } else if (location === "query") {
225
241
  if (argValue !== void 0 && argValue !== null && argValue !== "") {
226
- queryParams.append(originalName, String(argValue));
242
+ appendQueryParam(queryParams, originalName, argValue);
227
243
  }
228
244
  } else if (location === "header") {
229
245
  headers[originalName] = String(argValue);