@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
@@ -19,6 +19,7 @@ var __decorateClass = (decorators, target, key, kind) => {
19
19
  import {
20
20
  AuthCredentialTypes
21
21
  } from "../../../../auth/auth_credential.js";
22
+ import { AuthSchemeType } from "../../../../auth/auth_schemes.js";
22
23
  import { experimental } from "../../../../utils/experimental.js";
23
24
  function checkSchemeCredentialType(authScheme, authCredential) {
24
25
  if (!authCredential) {
@@ -26,7 +27,7 @@ function checkSchemeCredentialType(authScheme, authCredential) {
26
27
  "auth_credential is empty. Please create AuthCredential using OAuth2Auth."
27
28
  );
28
29
  }
29
- if (authScheme.type !== "openIdConnect" && authScheme.type !== "oauth2") {
30
+ if (authScheme.type !== AuthSchemeType.OPEN_ID_CONNECT && authScheme.type !== AuthSchemeType.OAUTH2) {
30
31
  throw new Error(
31
32
  `Invalid security scheme, expect AuthSchemeType.openIdConnect or AuthSchemeType.oauth2 auth scheme, but got ${authScheme.type}`
32
33
  );
@@ -54,12 +55,12 @@ function generateAuthToken(authCredential) {
54
55
  }
55
56
  __name(generateAuthToken, "generateAuthToken");
56
57
  function exchangeCredential(authScheme, authCredential) {
57
- var _a, _b;
58
+ var _a;
58
59
  checkSchemeCredentialType(authScheme, authCredential);
59
60
  if (authCredential.http) {
60
61
  return authCredential;
61
62
  }
62
- if (((_a = authCredential.oauth2) == null ? void 0 : _a.accessToken) || ((_b = authCredential.oauth2) == null ? void 0 : _b.refreshToken)) {
63
+ if ((_a = authCredential.oauth2) == null ? void 0 : _a.accessToken) {
63
64
  return generateAuthToken(authCredential);
64
65
  }
65
66
  return null;
@@ -17,6 +17,7 @@ var __decorateClass = (decorators, target, key, kind) => {
17
17
  * SPDX-License-Identifier: Apache-2.0
18
18
  */
19
19
  import { GoogleAuth, JWT } from "google-auth-library";
20
+ import { createSign } from "node:crypto";
20
21
  import {
21
22
  AuthCredentialTypes
22
23
  } from "../../../../auth/auth_credential.js";
@@ -24,6 +25,83 @@ import { experimental } from "../../../../utils/experimental.js";
24
25
  import { AuthCredentialMissingError } from "./base_auth_credential_exchanger.js";
25
26
  const DEFAULT_SCOPES = ["https://www.googleapis.com/auth/cloud-platform"];
26
27
  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.";
28
+ const GOOGLE_TOKEN_URI = "https://oauth2.googleapis.com/token";
29
+ const JWT_BEARER_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer";
30
+ const ASSERTION_LIFETIME_SECONDS = 3600;
31
+ const TOKEN_REQUEST_TIMEOUT_MS = 3e4;
32
+ function hasCustomTokenUri(creds) {
33
+ return !!creds.tokenUri && creds.tokenUri !== GOOGLE_TOKEN_URI;
34
+ }
35
+ __name(hasCustomTokenUri, "hasCustomTokenUri");
36
+ function base64UrlJson(value) {
37
+ return Buffer.from(JSON.stringify(value)).toString("base64url");
38
+ }
39
+ __name(base64UrlJson, "base64UrlJson");
40
+ function signJwtBearerAssertion(creds, scopes, issuedAt) {
41
+ const header = {
42
+ alg: "RS256",
43
+ typ: "JWT",
44
+ ...creds.privateKeyId ? { kid: creds.privateKeyId } : {}
45
+ };
46
+ const payload = {
47
+ iss: creds.clientEmail,
48
+ scope: scopes.join(" "),
49
+ aud: GOOGLE_TOKEN_URI,
50
+ iat: issuedAt,
51
+ exp: issuedAt + ASSERTION_LIFETIME_SECONDS
52
+ };
53
+ const signingInput = `${base64UrlJson(header)}.${base64UrlJson(payload)}`;
54
+ const signature = createSign("RSA-SHA256").update(signingInput).sign(creds.privateKey, "base64url");
55
+ return `${signingInput}.${signature}`;
56
+ }
57
+ __name(signJwtBearerAssertion, "signJwtBearerAssertion");
58
+ async function readTokenErrorDetail(response) {
59
+ try {
60
+ const body = await response.json();
61
+ if (typeof body !== "object" || body === null) {
62
+ return void 0;
63
+ }
64
+ const parts = [];
65
+ if ("error" in body && typeof body.error === "string" && body.error.length > 0) {
66
+ parts.push(body.error);
67
+ }
68
+ if ("error_description" in body && typeof body.error_description === "string" && body.error_description.length > 0) {
69
+ parts.push(body.error_description);
70
+ }
71
+ return parts.length > 0 ? parts.join(": ") : void 0;
72
+ } catch {
73
+ return void 0;
74
+ }
75
+ }
76
+ __name(readTokenErrorDetail, "readTokenErrorDetail");
77
+ async function requestJwtBearerToken(creds, scopes) {
78
+ const assertion = signJwtBearerAssertion(
79
+ creds,
80
+ scopes,
81
+ Math.floor(Date.now() / 1e3)
82
+ );
83
+ const response = await fetch(creds.tokenUri, {
84
+ method: "POST",
85
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
86
+ body: new URLSearchParams({
87
+ grant_type: JWT_BEARER_GRANT_TYPE,
88
+ assertion
89
+ }),
90
+ signal: AbortSignal.timeout(TOKEN_REQUEST_TIMEOUT_MS)
91
+ });
92
+ if (!response.ok) {
93
+ const detail = await readTokenErrorDetail(response);
94
+ throw new Error(
95
+ detail ? `Token endpoint responded with HTTP ${response.status}: ${detail}` : `Token endpoint responded with HTTP ${response.status}`
96
+ );
97
+ }
98
+ const body = await response.json();
99
+ if (typeof body === "object" && body !== null && "access_token" in body && typeof body.access_token === "string") {
100
+ return body.access_token;
101
+ }
102
+ return void 0;
103
+ }
104
+ __name(requestJwtBearerToken, "requestJwtBearerToken");
27
105
  let ServiceAccountCredentialExchanger = class {
28
106
  async exchange(params) {
29
107
  const { authCredential } = params;
@@ -64,21 +142,27 @@ let ServiceAccountCredentialExchanger = class {
64
142
  }
65
143
  }
66
144
  async exchangeForExplicitCredential(saConfig) {
145
+ var _a;
67
146
  const creds = saConfig.serviceAccountCredential;
68
147
  if (!creds) {
69
148
  throw new AuthCredentialMissingError(MISSING_SERVICE_ACCOUNT_CREDENTIALS);
70
149
  }
71
150
  try {
72
- const client = new JWT({
73
- email: creds.clientEmail,
74
- key: creds.privateKey,
75
- keyId: creds.privateKeyId,
76
- projectId: creds.projectId,
77
- universeDomain: creds.universeDomain,
78
- scopes: saConfig.scopes
79
- });
80
- const tokens = await client.authorize();
81
- const token = tokens.access_token;
151
+ let token;
152
+ if (hasCustomTokenUri(creds)) {
153
+ token = await requestJwtBearerToken(creds, (_a = saConfig.scopes) != null ? _a : []);
154
+ } else {
155
+ const client = new JWT({
156
+ email: creds.clientEmail,
157
+ key: creds.privateKey,
158
+ keyId: creds.privateKeyId,
159
+ projectId: creds.projectId,
160
+ universeDomain: creds.universeDomain,
161
+ scopes: saConfig.scopes
162
+ });
163
+ const tokens = await client.authorize();
164
+ token = tokens.access_token;
165
+ }
82
166
  if (!token) {
83
167
  throw new Error("Failed to get access token from explicit credentials");
84
168
  }
@@ -29,15 +29,27 @@ const VALID_SCHEMA_TYPES = /* @__PURE__ */ new Set([
29
29
  "string"
30
30
  ]);
31
31
  let OpenApiSpecParser = class {
32
+ /**
33
+ * @param options.preservePropertyNames Keeps the original parameter and
34
+ * function names instead of converting them to snake_case.
35
+ * @param options.unconstrainedObjectBodyAsParameter Emits a whole-body
36
+ * parameter named `body` when an object request body schema has no
37
+ * properties. Defaults to `false`.
38
+ * @deprecated Retained for backwards compatibility; empty object schemas
39
+ * produce no parameters by default. This option will be removed in a
40
+ * future release.
41
+ */
32
42
  constructor(options = {}) {
33
- var _a;
43
+ var _a, _b;
34
44
  this.preservePropertyNames = (_a = options.preservePropertyNames) != null ? _a : false;
45
+ this.unconstrainedObjectBodyAsParameter = (_b = options.unconstrainedObjectBodyAsParameter) != null ? _b : false;
35
46
  }
36
47
  parse(openapiSpec) {
37
48
  const resolvedSpec = resolveReferences(openapiSpec);
38
49
  const sanitizedSpec = sanitizeSchemaTypes(resolvedSpec);
39
50
  return collectOperations(sanitizedSpec, {
40
- preservePropertyNames: this.preservePropertyNames
51
+ preservePropertyNames: this.preservePropertyNames,
52
+ unconstrainedObjectBodyAsParameter: this.unconstrainedObjectBodyAsParameter
41
53
  });
42
54
  }
43
55
  };
@@ -172,17 +184,18 @@ function resolveServerUrl(server) {
172
184
  }
173
185
  __name(resolveServerUrl, "resolveServerUrl");
174
186
  function collectOperations(spec, options = {}) {
175
- var _a, _b, _c;
187
+ var _a, _b, _c, _d;
176
188
  const preservePropertyNames = (_a = options.preservePropertyNames) != null ? _a : false;
189
+ const unconstrainedObjectBodyAsParameter = (_b = options.unconstrainedObjectBodyAsParameter) != null ? _b : false;
177
190
  const operations = [];
178
- const server = (_b = spec.servers) == null ? void 0 : _b[0];
191
+ const server = (_c = spec.servers) == null ? void 0 : _c[0];
179
192
  const baseUrl = server ? resolveServerUrl(server) : "";
180
193
  const globalSecurity = spec.security || [];
181
194
  let globalSchemeName;
182
195
  if (globalSecurity.length > 0) {
183
196
  globalSchemeName = Object.keys(globalSecurity[0])[0];
184
197
  }
185
- const authSchemes = ((_c = spec.components) == null ? void 0 : _c.securitySchemes) || {};
198
+ const authSchemes = ((_d = spec.components) == null ? void 0 : _d.securitySchemes) || {};
186
199
  for (const [path, pathItem] of Object.entries(spec.paths || {})) {
187
200
  if (!pathItem) continue;
188
201
  const methods = [
@@ -205,7 +218,8 @@ function collectOperations(spec, options = {}) {
205
218
  operation.operationId = toSnakeCaseName(`${path}_${method}`);
206
219
  }
207
220
  const parser = new OperationParser(operation, {
208
- preservePropertyNames
221
+ preservePropertyNames,
222
+ unconstrainedObjectBodyAsParameter
209
223
  });
210
224
  let authSchemeName;
211
225
  if (operation.security && operation.security.length > 0) {
@@ -34,13 +34,20 @@ let OperationParser = class {
34
34
  * function names instead of converting them to snake_case.
35
35
  * @param options.shouldParse Whether to parse the operation during
36
36
  * construction. Defaults to `true`.
37
+ * @param options.unconstrainedObjectBodyAsParameter Emits a whole-body
38
+ * parameter named `body` when an object request body schema has no
39
+ * properties. Defaults to `false`.
40
+ * @deprecated Retained for backwards compatibility; empty object schemas
41
+ * produce no parameters by default. This option will be removed in a
42
+ * future release.
37
43
  */
38
44
  constructor(operation, options = {}) {
39
45
  this.params = [];
40
- var _a, _b;
46
+ var _a, _b, _c;
41
47
  this.operation = typeof operation === "string" ? JSON.parse(operation) : operation;
42
48
  this.preservePropertyNames = (_a = options.preservePropertyNames) != null ? _a : false;
43
- if ((_b = options.shouldParse) != null ? _b : true) {
49
+ this.unconstrainedObjectBodyAsParameter = (_b = options.unconstrainedObjectBodyAsParameter) != null ? _b : false;
50
+ if ((_c = options.shouldParse) != null ? _c : true) {
44
51
  this.processOperationParameters();
45
52
  this.processRequestBody();
46
53
  this.returnValue = this.processReturnValue();
@@ -60,6 +67,7 @@ let OperationParser = class {
60
67
  return renameReservedKeywords(toSnakeCaseName(originalName));
61
68
  }
62
69
  processOperationParameters() {
70
+ var _a;
63
71
  const parameters = this.operation.parameters || [];
64
72
  for (const param of parameters) {
65
73
  if ("name" in param) {
@@ -70,9 +78,12 @@ let OperationParser = class {
70
78
  this.params.push({
71
79
  originalName,
72
80
  paramLocation: location,
73
- paramSchema: schema,
81
+ paramSchema: {
82
+ ...schema,
83
+ description: schema.description || description || void 0
84
+ },
74
85
  description,
75
- required: param.required || false,
86
+ required: (_a = param.required) != null ? _a : false,
76
87
  name: this.getParamName(originalName)
77
88
  });
78
89
  }
@@ -108,7 +119,7 @@ let OperationParser = class {
108
119
  });
109
120
  }
110
121
  }
111
- } else {
122
+ } else if (this.unconstrainedObjectBodyAsParameter) {
112
123
  this.params.push({
113
124
  originalName: "",
114
125
  paramLocation: "body",
@@ -129,7 +140,7 @@ let OperationParser = class {
129
140
  });
130
141
  } else {
131
142
  this.params.push({
132
- originalName: "body",
143
+ originalName: "",
133
144
  paramLocation: "body",
134
145
  paramSchema: schema,
135
146
  description,
@@ -18,6 +18,7 @@ var __decorateClass = (decorators, target, key, kind) => {
18
18
  */
19
19
  import { cloneDeep } from "lodash-es";
20
20
  import {
21
+ AuthCredentialTypes,
21
22
  isAuthCredential
22
23
  } from "../../../auth/auth_credential.js";
23
24
  import { experimental } from "../../../utils/experimental.js";
@@ -26,6 +27,16 @@ import { logger } from "../../../utils/logger.js";
26
27
  import { AutoAuthCredentialExchanger } from "../auth/credential_exchangers/auto_auth_credential_exchanger.js";
27
28
  import { AuthCredentialMissingError } from "../auth/credential_exchangers/base_auth_credential_exchanger.js";
28
29
  const DEFAULT_CREDENTIAL_KEY = "default_openapi_key";
30
+ const INTERACTIVE_CREDENTIAL_TYPES = /* @__PURE__ */ new Set([
31
+ AuthCredentialTypes.OAUTH2,
32
+ AuthCredentialTypes.OPEN_ID_CONNECT
33
+ ]);
34
+ function isMissingInteractiveToken(result) {
35
+ var _a, _b;
36
+ const { credential, wasExchanged } = result;
37
+ 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);
38
+ }
39
+ __name(isMissingInteractiveToken, "isMissingInteractiveToken");
29
40
  const _ToolContextCredentialStore = class _ToolContextCredentialStore {
30
41
  constructor(context) {
31
42
  this.context = context;
@@ -141,7 +152,8 @@ let ToolAuthHandler = class {
141
152
  };
142
153
  }
143
154
  /**
144
- * Exchanges `credential`, or returns `undefined` when the exchange failed.
155
+ * Exchanges `credential`, or returns `undefined` when the exchange failed or
156
+ * produced an interactive credential that still holds no token.
145
157
  *
146
158
  * An exchange failure is transient far more often than it is fatal, so it
147
159
  * becomes a `pending` result the client can resume from rather than an
@@ -151,10 +163,11 @@ let ToolAuthHandler = class {
151
163
  var _a;
152
164
  const exchanger = (_a = this.credentialExchanger) != null ? _a : new AutoAuthCredentialExchanger();
153
165
  try {
154
- return await exchanger.exchange({
166
+ const result = await exchanger.exchange({
155
167
  authScheme: this.authScheme,
156
168
  authCredential: credential
157
169
  });
170
+ return isMissingInteractiveToken(result) ? void 0 : result;
158
171
  } catch (e) {
159
172
  logger.error(
160
173
  `Failed to exchange credential: ${e instanceof Error ? e.message : e}`
@@ -16,7 +16,7 @@ var __decorateClass = (decorators, target, key, kind) => {
16
16
  * Copyright 2026 Google LLC
17
17
  * SPDX-License-Identifier: Apache-2.0
18
18
  */
19
- import yaml from "js-yaml";
19
+ import * as yaml from "js-yaml";
20
20
  import { experimental } from "../../utils/experimental.js";
21
21
  import { logger } from "../../utils/logger.js";
22
22
  import { BaseToolset } from "../base_toolset.js";
@@ -40,7 +40,8 @@ let OpenAPIToolset = class extends BaseToolset {
40
40
  throw new Error("Either specDict or specStr must be provided.");
41
41
  }
42
42
  const parser = new OpenApiSpecParser({
43
- preservePropertyNames: options.preservePropertyNames
43
+ preservePropertyNames: options.preservePropertyNames,
44
+ unconstrainedObjectBodyAsParameter: options.unconstrainedObjectBodyAsParameter
44
45
  });
45
46
  const parsedOperations = parser.parse(spec);
46
47
  for (const op of parsedOperations) {
@@ -61,7 +62,8 @@ let OpenAPIToolset = class extends BaseToolset {
61
62
  {
62
63
  preservePropertyNames: options.preservePropertyNames,
63
64
  headerProvider: options.headerProvider,
64
- credentialKey: options.credentialKey
65
+ credentialKey: options.credentialKey,
66
+ unconstrainedObjectBodyAsParameter: options.unconstrainedObjectBodyAsParameter
65
67
  }
66
68
  );
67
69
  this.tools.push(tool);
@@ -76,15 +78,7 @@ let OpenAPIToolset = class extends BaseToolset {
76
78
  }
77
79
  }
78
80
  async getTools(context) {
79
- return this.tools.filter((tool) => {
80
- if (Array.isArray(this.toolFilter) && this.toolFilter.length > 0) {
81
- return this.toolFilter.includes(tool.name);
82
- }
83
- if (context) {
84
- return this.isToolSelected(tool, context);
85
- }
86
- return true;
87
- });
81
+ return this.tools.filter((tool) => this.isToolSelected(tool, context));
88
82
  }
89
83
  getTool(toolName) {
90
84
  return this.tools.find((tool) => tool.name === toolName);
@@ -176,6 +176,22 @@ function encodePathParamValue(name, value) {
176
176
  return encodeURIComponent(value);
177
177
  }
178
178
  __name(encodePathParamValue, "encodePathParamValue");
179
+ function serializeQueryValue(value) {
180
+ return typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
181
+ }
182
+ __name(serializeQueryValue, "serializeQueryValue");
183
+ function appendQueryParam(queryParams, name, value) {
184
+ if (!Array.isArray(value)) {
185
+ queryParams.append(name, serializeQueryValue(value));
186
+ return;
187
+ }
188
+ for (const item of value) {
189
+ if (item !== void 0 && item !== null) {
190
+ queryParams.append(name, serializeQueryValue(item));
191
+ }
192
+ }
193
+ }
194
+ __name(appendQueryParam, "appendQueryParam");
179
195
  function prepareRequestParams(endpoint, parameters, args) {
180
196
  const headers = {};
181
197
  const queryParams = new URLSearchParams();
@@ -196,7 +212,7 @@ function prepareRequestParams(endpoint, parameters, args) {
196
212
  );
197
213
  } else if (location === "query") {
198
214
  if (argValue !== void 0 && argValue !== null && argValue !== "") {
199
- queryParams.append(originalName, String(argValue));
215
+ appendQueryParam(queryParams, originalName, argValue);
200
216
  }
201
217
  } else if (location === "header") {
202
218
  headers[originalName] = String(argValue);
@@ -7,9 +7,22 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7
7
  * Copyright 2026 Google LLC
8
8
  * SPDX-License-Identifier: Apache-2.0
9
9
  */
10
+ var _a, _b;
10
11
  import { Type } from "@google/genai";
11
12
  import { BaseTool } from "../base_tool.js";
12
- const _BaseRetrievalTool = class _BaseRetrievalTool extends BaseTool {
13
+ const BASE_RETRIEVAL_TOOL_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for(
14
+ "google.adk.baseRetrievalTool"
15
+ );
16
+ function isBaseRetrievalTool(obj) {
17
+ return typeof obj === "object" && obj !== null && BASE_RETRIEVAL_TOOL_SIGNATURE_SYMBOL in obj && obj[BASE_RETRIEVAL_TOOL_SIGNATURE_SYMBOL] === true;
18
+ }
19
+ __name(isBaseRetrievalTool, "isBaseRetrievalTool");
20
+ const _BaseRetrievalTool = class _BaseRetrievalTool extends (_b = BaseTool, _a = BASE_RETRIEVAL_TOOL_SIGNATURE_SYMBOL, _b) {
21
+ constructor() {
22
+ super(...arguments);
23
+ /** Unique symbol to identify `BaseRetrievalTool` class. */
24
+ this[_a] = true;
25
+ }
13
26
  _getDeclaration() {
14
27
  return {
15
28
  name: this.name,
@@ -29,5 +42,6 @@ const _BaseRetrievalTool = class _BaseRetrievalTool extends BaseTool {
29
42
  __name(_BaseRetrievalTool, "BaseRetrievalTool");
30
43
  let BaseRetrievalTool = _BaseRetrievalTool;
31
44
  export {
32
- BaseRetrievalTool
45
+ BaseRetrievalTool,
46
+ isBaseRetrievalTool
33
47
  };
@@ -0,0 +1,148 @@
1
+ import {createRequire as topLevelCreateRequire} from 'module';
2
+ const require = topLevelCreateRequire(import.meta.url);
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ /**
6
+ * @license
7
+ * Copyright 2026 Google LLC
8
+ * SPDX-License-Identifier: Apache-2.0
9
+ */
10
+ var _a, _b;
11
+ import { isBaseTool } from "./base_tool.js";
12
+ import { BaseToolset } from "./base_toolset.js";
13
+ import {
14
+ FunctionTool
15
+ } from "./function_tool.js";
16
+ const TOOLBOX_TOOLSET_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for(
17
+ "google.adk.toolboxToolset"
18
+ );
19
+ function isToolboxToolset(obj) {
20
+ return typeof obj === "object" && obj !== null && TOOLBOX_TOOLSET_SIGNATURE_SYMBOL in obj && obj[TOOLBOX_TOOLSET_SIGNATURE_SYMBOL] === true;
21
+ }
22
+ __name(isToolboxToolset, "isToolboxToolset");
23
+ function createUnconfiguredToolboxToolsetClient(serverUrl) {
24
+ const throwMissingClient = /* @__PURE__ */ __name(() => {
25
+ throw new Error(
26
+ `ToolboxToolset requires a ToolboxToolsetClientLike instance (for endpoint "${serverUrl}"). Pass {serverUrl, client} to the ToolboxToolset constructor.`
27
+ );
28
+ }, "throwMissingClient");
29
+ return {
30
+ loadTool: throwMissingClient,
31
+ loadToolset: throwMissingClient,
32
+ close: /* @__PURE__ */ __name(() => {
33
+ }, "close")
34
+ };
35
+ }
36
+ __name(createUnconfiguredToolboxToolsetClient, "createUnconfiguredToolboxToolsetClient");
37
+ function isToolOptionsObject(value) {
38
+ return typeof value === "object" && value !== null && "execute" in value && typeof value.execute === "function";
39
+ }
40
+ __name(isToolOptionsObject, "isToolOptionsObject");
41
+ function wrapLoadedTool(rawTool, prefix) {
42
+ var _a2;
43
+ if (isBaseTool(rawTool)) {
44
+ if (!prefix) {
45
+ return rawTool;
46
+ }
47
+ return Object.assign(
48
+ Object.create(Object.getPrototypeOf(rawTool)),
49
+ rawTool,
50
+ { name: `${prefix}_${rawTool.name}` }
51
+ );
52
+ }
53
+ if (typeof rawTool === "function") {
54
+ const fn = rawTool;
55
+ const baseName = fn.name || "toolbox_tool";
56
+ const name = prefix ? `${prefix}_${baseName}` : baseName;
57
+ const description = (_a2 = fn.description) != null ? _a2 : "";
58
+ return new FunctionTool({
59
+ name,
60
+ description,
61
+ execute: fn
62
+ });
63
+ }
64
+ if (isToolOptionsObject(rawTool)) {
65
+ const baseTool = new FunctionTool(rawTool);
66
+ if (!prefix) {
67
+ return baseTool;
68
+ }
69
+ return new FunctionTool({
70
+ ...rawTool,
71
+ name: `${prefix}_${baseTool.name}`
72
+ });
73
+ }
74
+ throw new TypeError(
75
+ "Unsupported Toolbox tool shape: expected a BaseTool, ToolOptions object, or function."
76
+ );
77
+ }
78
+ __name(wrapLoadedTool, "wrapLoadedTool");
79
+ const _ToolboxToolset = class _ToolboxToolset extends (_b = BaseToolset, _a = TOOLBOX_TOOLSET_SIGNATURE_SYMBOL, _b) {
80
+ constructor(serverUrlOrOptions, extraOptions) {
81
+ var _a2, _b2, _c, _d;
82
+ const options = typeof serverUrlOrOptions === "string" ? { serverUrl: serverUrlOrOptions, ...extraOptions } : serverUrlOrOptions;
83
+ if ((!options.toolNames || options.toolNames.length === 0) && !options.toolsetName) {
84
+ throw new Error("toolNames and toolsetName cannot both be undefined.");
85
+ }
86
+ super((_a2 = options.toolFilter) != null ? _a2 : [], options.prefix);
87
+ /** A unique symbol to identify ADK ToolboxToolset class. */
88
+ this[_a] = true;
89
+ this.serverUrl = options.serverUrl;
90
+ this.toolsetName = options.toolsetName;
91
+ this.toolNames = options.toolNames;
92
+ this.authTokenGetters = (_b2 = options.authTokenGetters) != null ? _b2 : {};
93
+ this.boundParams = (_c = options.boundParams) != null ? _c : {};
94
+ this.toolboxClient = (_d = options.client) != null ? _d : createUnconfiguredToolboxToolsetClient(this.serverUrl);
95
+ }
96
+ /**
97
+ * Loads the configured toolset and/or individual tools from the Toolbox
98
+ * client and returns the selected {@link BaseTool} instances.
99
+ */
100
+ async getTools(context) {
101
+ var _a2, _b2, _c, _d, _e, _f;
102
+ const loadOptions = {
103
+ authTokenGetters: this.authTokenGetters,
104
+ boundParams: this.boundParams
105
+ };
106
+ const tools = [];
107
+ if (this.toolsetName) {
108
+ const loader = (_c = (_a2 = this.toolboxClient.loadToolset) == null ? void 0 : _a2.bind(this.toolboxClient)) != null ? _c : (_b2 = this.toolboxClient.load_toolset) == null ? void 0 : _b2.bind(this.toolboxClient);
109
+ if (!loader) {
110
+ throw new Error(
111
+ "ToolboxClient does not implement loadToolset or load_toolset."
112
+ );
113
+ }
114
+ const loadedToolset = await loader(this.toolsetName, loadOptions);
115
+ for (const rawTool of loadedToolset) {
116
+ tools.push(wrapLoadedTool(rawTool, this.prefix));
117
+ }
118
+ }
119
+ if (this.toolNames && this.toolNames.length > 0) {
120
+ const loader = (_f = (_d = this.toolboxClient.loadTool) == null ? void 0 : _d.bind(this.toolboxClient)) != null ? _f : (_e = this.toolboxClient.load_tool) == null ? void 0 : _e.bind(this.toolboxClient);
121
+ if (!loader) {
122
+ throw new Error(
123
+ "ToolboxClient does not implement loadTool or load_tool."
124
+ );
125
+ }
126
+ const loadedSingleTools = await Promise.all(
127
+ this.toolNames.map((toolName) => loader(toolName, loadOptions))
128
+ );
129
+ for (const rawTool of loadedSingleTools) {
130
+ tools.push(wrapLoadedTool(rawTool, this.prefix));
131
+ }
132
+ }
133
+ return tools.filter((tool) => this.isToolSelected(tool, context));
134
+ }
135
+ /**
136
+ * Closes the underlying Toolbox client.
137
+ */
138
+ async close() {
139
+ var _a2, _b2;
140
+ await ((_b2 = (_a2 = this.toolboxClient).close) == null ? void 0 : _b2.call(_a2));
141
+ }
142
+ };
143
+ __name(_ToolboxToolset, "ToolboxToolset");
144
+ let ToolboxToolset = _ToolboxToolset;
145
+ export {
146
+ ToolboxToolset,
147
+ isToolboxToolset
148
+ };
@@ -41,20 +41,7 @@ const _WebMCPToolset = class _WebMCPToolset extends BaseToolset {
41
41
  document: this.doc
42
42
  })
43
43
  );
44
- const filter = this.toolFilter;
45
- if (!filter || Array.isArray(filter) && filter.length === 0) {
46
- return tools;
47
- }
48
- if (Array.isArray(filter)) {
49
- return tools.filter((tool) => filter.includes(tool.name));
50
- }
51
- if (context) {
52
- return tools.filter((tool) => filter(tool, context));
53
- }
54
- logger.warn(
55
- "WebMCPToolset: a ToolPredicate toolFilter was provided but getTools() was called without a ReadonlyContext. The filter will not be applied."
56
- );
57
- return tools;
44
+ return tools.filter((tool) => this.isToolSelected(tool, context));
58
45
  }
59
46
  /**
60
47
  * Subscribes to the WebMCP `toolchange` event, which fires when the page
@@ -99,7 +99,8 @@ function headerEntries(headers) {
99
99
  __name(headerEntries, "headerEntries");
100
100
  function mergeTrackingHeaders(headers) {
101
101
  var _a, _b;
102
- const merged = {};
102
+ const otherHeaders = new Headers();
103
+ const originalNames = /* @__PURE__ */ new Map();
103
104
  const callerValues = /* @__PURE__ */ new Map();
104
105
  for (const [name, value] of headerEntries(headers)) {
105
106
  const lowerName = name.toLowerCase();
@@ -109,9 +110,25 @@ function mergeTrackingHeaders(headers) {
109
110
  value
110
111
  ]);
111
112
  } else {
112
- merged[name] = value;
113
+ if (!originalNames.has(lowerName)) {
114
+ originalNames.set(lowerName, name);
115
+ }
116
+ otherHeaders.append(name, value);
113
117
  }
114
118
  }
119
+ const normalizedEntries = [];
120
+ otherHeaders.forEach((value, name) => {
121
+ normalizedEntries.push([name, value]);
122
+ });
123
+ const merged = Object.fromEntries(
124
+ normalizedEntries.map(([name, value]) => {
125
+ var _a2;
126
+ return [
127
+ (_a2 = originalNames.get(name)) != null ? _a2 : name,
128
+ value
129
+ ];
130
+ })
131
+ );
115
132
  for (const [name, trackingValue] of Object.entries(getTrackingHeaders())) {
116
133
  const tokens = trackingValue.split(" ");
117
134
  for (const value of (_b = callerValues.get(name)) != null ? _b : []) {