@google/adk 2.2.0 → 2.3.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 (241) 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/a2a/event_converter_utils.js +5 -1
  5. package/dist/cjs/a2a/metadata_converter_utils.js +2 -1
  6. package/dist/cjs/agents/functions.js +199 -25
  7. package/dist/cjs/agents/instructions.js +4 -1
  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 +175 -101
  11. package/dist/cjs/agents/processors/code_execution_request_processor.js +10 -6
  12. package/dist/cjs/agents/remote_agent.js +187 -0
  13. package/dist/cjs/artifacts/in_memory_artifact_service.js +14 -0
  14. package/dist/cjs/auth/auth_handler.js +37 -5
  15. package/dist/cjs/auth/auth_schemes.js +9 -0
  16. package/dist/cjs/cli/cli_eval.js +532 -0
  17. package/dist/cjs/cli/utils/envs.js +116 -0
  18. package/dist/cjs/cli/utils/evals.js +137 -0
  19. package/dist/cjs/cli/utils/logs.js +150 -0
  20. package/dist/cjs/code_executors/agent_engine_sandbox_code_executor.js +7 -2
  21. package/dist/cjs/code_executors/code_execution_utils.js +48 -16
  22. package/dist/cjs/code_executors/code_executor_context.js +6 -2
  23. package/dist/cjs/common.js +90 -0
  24. package/dist/cjs/context/summarizers/llm_summarizer.js +12 -10
  25. package/dist/cjs/context/token_based_context_compactor.js +2 -1
  26. package/dist/cjs/events/abort_events.js +135 -0
  27. package/dist/cjs/events/event.js +4 -2
  28. package/dist/cjs/events/internal_metadata.js +131 -0
  29. package/dist/cjs/examples/example_util.js +23 -2
  30. package/dist/cjs/flows/llm_flows/audio_transcriber.js +170 -0
  31. package/dist/cjs/index.js +97 -1
  32. package/dist/cjs/integrations/agent_registry/helpers.js +1 -1
  33. package/dist/cjs/models/gemini_llm_connection.js +16 -8
  34. package/dist/cjs/models/google_llm.js +13 -16
  35. package/dist/cjs/models/llm_response.js +9 -1
  36. package/dist/cjs/models/registry.js +1 -1
  37. package/dist/cjs/models/routed_llm.js +9 -8
  38. package/dist/cjs/planners/plan_re_act_planner.js +1 -1
  39. package/dist/cjs/plugins/debug_logging_plugin.js +653 -0
  40. package/dist/cjs/plugins/plugin_manager.js +1 -1
  41. package/dist/cjs/plugins/tool_call_integrity_plugin.js +364 -0
  42. package/dist/cjs/runner/in_memory_runner.js +6 -11
  43. package/dist/cjs/runner/runner.js +121 -35
  44. package/dist/cjs/sessions/db/operations.js +1 -1
  45. package/dist/cjs/sessions/in_memory_session_service.js +3 -1
  46. package/dist/cjs/sessions/state.js +8 -4
  47. package/dist/cjs/sessions/vertex_ai_session_service.js +34 -15
  48. package/dist/cjs/telemetry/tracing.js +97 -66
  49. package/dist/cjs/tools/agent_tool.js +44 -0
  50. package/dist/cjs/tools/apihub_tool/apihub_toolset.js +142 -0
  51. package/dist/cjs/tools/apihub_tool/clients/apihub_client.js +272 -0
  52. package/dist/cjs/tools/apihub_tool/clients/secret_client.js +148 -0
  53. package/dist/cjs/tools/apihub_tool/clients/service_account.js +48 -0
  54. package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +185 -0
  55. package/dist/cjs/tools/application_integration_tool/clients/cloud_request.js +133 -0
  56. package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +603 -0
  57. package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +219 -0
  58. package/dist/cjs/tools/crewai_tool.js +132 -0
  59. package/dist/cjs/tools/example_tool.js +10 -0
  60. package/dist/cjs/tools/function_tool.js +319 -0
  61. package/dist/cjs/tools/google_api_tool/google_api_tool.js +97 -0
  62. package/dist/cjs/tools/google_api_tool/google_api_tool_set.js +226 -0
  63. package/dist/cjs/tools/google_api_tool/google_api_tool_sets.js +58 -0
  64. package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +440 -0
  65. package/dist/cjs/tools/google_api_tool/index.js +64 -0
  66. package/dist/cjs/tools/langchain_tool.js +172 -0
  67. package/dist/cjs/tools/mcp/index.js +12 -0
  68. package/dist/cjs/tools/mcp/mcp_session_manager.js +25 -0
  69. package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +1 -2
  70. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +46 -2
  71. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -1
  72. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
  73. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +14 -2
  74. package/dist/cjs/tools/retrieval/base_retrieval_tool.js +18 -3
  75. package/dist/cjs/tools/toolbox_tool.js +108 -0
  76. package/dist/cjs/utils/env_aware_utils.js +6 -8
  77. package/dist/cjs/utils/error_utils.js +11 -11
  78. package/dist/cjs/utils/file_extension_utils.js +11 -0
  79. package/dist/cjs/utils/file_utils.js +2 -24
  80. package/dist/cjs/utils/gemini_schema_util.js +4 -1
  81. package/dist/cjs/utils/json_utils.js +49 -0
  82. package/dist/cjs/utils/live_connection_utils.js +4 -5
  83. package/dist/cjs/utils/logger_node.js +7 -1
  84. package/dist/cjs/utils/object_notation_utils.js +6 -3
  85. package/dist/cjs/utils/streaming_utils.js +12 -12
  86. package/dist/cjs/version.js +1 -1
  87. package/dist/esm/a2a/a2a_remote_agent.js +4 -1
  88. package/dist/esm/a2a/agent_card.js +103 -27
  89. package/dist/esm/a2a/agent_to_a2a.js +5 -2
  90. package/dist/esm/a2a/event_converter_utils.js +5 -1
  91. package/dist/esm/a2a/metadata_converter_utils.js +2 -1
  92. package/dist/esm/agents/functions.js +198 -25
  93. package/dist/esm/agents/instructions.js +4 -1
  94. package/dist/esm/agents/invocation_context.js +24 -4
  95. package/dist/esm/agents/langgraph_agent.js +123 -0
  96. package/dist/esm/agents/llm_agent.js +185 -104
  97. package/dist/esm/agents/processors/code_execution_request_processor.js +13 -8
  98. package/dist/esm/agents/remote_agent.js +164 -0
  99. package/dist/esm/artifacts/in_memory_artifact_service.js +14 -0
  100. package/dist/esm/auth/auth_handler.js +37 -5
  101. package/dist/esm/auth/auth_schemes.js +8 -0
  102. package/dist/esm/cli/cli_eval.js +510 -0
  103. package/dist/esm/cli/utils/envs.js +78 -0
  104. package/dist/esm/cli/utils/evals.js +109 -0
  105. package/dist/esm/cli/utils/logs.js +111 -0
  106. package/dist/esm/code_executors/agent_engine_sandbox_code_executor.js +7 -2
  107. package/dist/esm/code_executors/code_execution_utils.js +46 -16
  108. package/dist/esm/code_executors/code_executor_context.js +5 -2
  109. package/dist/esm/common.js +87 -3
  110. package/dist/esm/context/summarizers/llm_summarizer.js +12 -10
  111. package/dist/esm/context/token_based_context_compactor.js +2 -1
  112. package/dist/esm/events/abort_events.js +110 -0
  113. package/dist/esm/events/event.js +4 -2
  114. package/dist/esm/events/internal_metadata.js +97 -0
  115. package/dist/esm/examples/example_util.js +21 -1
  116. package/dist/esm/flows/llm_flows/audio_transcriber.js +142 -0
  117. package/dist/esm/index.js +99 -1
  118. package/dist/esm/integrations/agent_registry/helpers.js +1 -1
  119. package/dist/esm/models/gemini_llm_connection.js +16 -8
  120. package/dist/esm/models/google_llm.js +14 -17
  121. package/dist/esm/models/llm_response.js +9 -1
  122. package/dist/esm/models/registry.js +1 -1
  123. package/dist/esm/models/routed_llm.js +9 -8
  124. package/dist/esm/planners/plan_re_act_planner.js +1 -1
  125. package/dist/esm/plugins/debug_logging_plugin.js +615 -0
  126. package/dist/esm/plugins/plugin_manager.js +1 -1
  127. package/dist/esm/plugins/tool_call_integrity_plugin.js +339 -0
  128. package/dist/esm/runner/in_memory_runner.js +6 -11
  129. package/dist/esm/runner/runner.js +124 -35
  130. package/dist/esm/sessions/db/operations.js +1 -1
  131. package/dist/esm/sessions/in_memory_session_service.js +3 -1
  132. package/dist/esm/sessions/state.js +8 -4
  133. package/dist/esm/sessions/vertex_ai_session_service.js +34 -15
  134. package/dist/esm/telemetry/tracing.js +97 -66
  135. package/dist/esm/tools/agent_tool.js +44 -0
  136. package/dist/esm/tools/apihub_tool/apihub_toolset.js +106 -0
  137. package/dist/esm/tools/apihub_tool/clients/apihub_client.js +244 -0
  138. package/dist/esm/tools/apihub_tool/clients/secret_client.js +132 -0
  139. package/dist/esm/tools/apihub_tool/clients/service_account.js +21 -0
  140. package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +163 -0
  141. package/dist/esm/tools/application_integration_tool/clients/cloud_request.js +103 -0
  142. package/dist/esm/tools/application_integration_tool/clients/connections_client.js +561 -0
  143. package/dist/esm/tools/application_integration_tool/clients/integration_client.js +215 -0
  144. package/dist/esm/tools/crewai_tool.js +107 -0
  145. package/dist/esm/tools/example_tool.js +13 -1
  146. package/dist/esm/tools/function_tool.js +316 -0
  147. package/dist/esm/tools/google_api_tool/google_api_tool.js +70 -0
  148. package/dist/esm/tools/google_api_tool/google_api_tool_set.js +188 -0
  149. package/dist/esm/tools/google_api_tool/google_api_tool_sets.js +24 -0
  150. package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +393 -0
  151. package/dist/esm/tools/google_api_tool/index.js +33 -0
  152. package/dist/esm/tools/langchain_tool.js +148 -0
  153. package/dist/esm/tools/mcp/index.js +6 -0
  154. package/dist/esm/tools/mcp/mcp_session_manager.js +25 -0
  155. package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +1 -2
  156. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +50 -3
  157. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -1
  158. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
  159. package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +15 -2
  160. package/dist/esm/tools/retrieval/base_retrieval_tool.js +16 -2
  161. package/dist/esm/tools/toolbox_tool.js +80 -0
  162. package/dist/esm/utils/env_aware_utils.js +6 -8
  163. package/dist/esm/utils/error_utils.js +9 -10
  164. package/dist/esm/utils/file_extension_utils.js +11 -0
  165. package/dist/esm/utils/file_utils.js +2 -23
  166. package/dist/esm/utils/gemini_schema_util.js +4 -1
  167. package/dist/esm/utils/json_utils.js +21 -0
  168. package/dist/esm/utils/live_connection_utils.js +4 -5
  169. package/dist/esm/utils/logger_node.js +7 -1
  170. package/dist/esm/utils/object_notation_utils.js +4 -2
  171. package/dist/esm/utils/streaming_utils.js +11 -11
  172. package/dist/esm/version.js +1 -1
  173. package/dist/types/a2a/a2a_remote_agent.d.ts +9 -0
  174. package/dist/types/a2a/agent_card.d.ts +44 -1
  175. package/dist/types/a2a/agent_to_a2a.d.ts +9 -0
  176. package/dist/types/a2a/index.d.ts +1 -0
  177. package/dist/types/agents/functions.d.ts +33 -1
  178. package/dist/types/agents/invocation_context.d.ts +20 -1
  179. package/dist/types/agents/langgraph_agent.d.ts +153 -0
  180. package/dist/types/agents/remote_agent.d.ts +68 -0
  181. package/dist/types/auth/auth_handler.d.ts +28 -1
  182. package/dist/types/auth/auth_schemes.d.ts +13 -0
  183. package/dist/types/cli/cli_eval.d.ts +173 -0
  184. package/dist/types/cli/utils/envs.d.ts +23 -0
  185. package/dist/types/cli/utils/evals.d.ts +47 -0
  186. package/dist/types/cli/utils/logs.d.ts +38 -0
  187. package/dist/types/code_executors/code_execution_utils.d.ts +39 -0
  188. package/dist/types/code_executors/code_executor_context.d.ts +1 -0
  189. package/dist/types/common.d.ts +30 -4
  190. package/dist/types/events/abort_events.d.ts +43 -0
  191. package/dist/types/events/event.d.ts +4 -0
  192. package/dist/types/events/internal_metadata.d.ts +78 -0
  193. package/dist/types/examples/example_util.d.ts +17 -0
  194. package/dist/types/flows/llm_flows/audio_transcriber.d.ts +85 -0
  195. package/dist/types/index.d.ts +16 -1
  196. package/dist/types/models/gemini_llm_connection.d.ts +6 -7
  197. package/dist/types/models/routed_llm.d.ts +1 -1
  198. package/dist/types/plugins/debug_logging_plugin.d.ts +157 -0
  199. package/dist/types/plugins/tool_call_integrity_plugin.d.ts +116 -0
  200. package/dist/types/runner/in_memory_runner.d.ts +2 -1
  201. package/dist/types/runner/runner.d.ts +34 -0
  202. package/dist/types/sessions/state.d.ts +5 -1
  203. package/dist/types/sessions/vertex_ai_session_service.d.ts +8 -0
  204. package/dist/types/skills/skill.d.ts +1 -1
  205. package/dist/types/telemetry/tracing.d.ts +4 -2
  206. package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +122 -0
  207. package/dist/types/tools/apihub_tool/clients/apihub_client.d.ts +142 -0
  208. package/dist/types/tools/apihub_tool/clients/secret_client.d.ts +55 -0
  209. package/dist/types/tools/apihub_tool/clients/service_account.d.ts +11 -0
  210. package/dist/types/tools/application_integration_tool/application_integration_toolset.d.ts +86 -0
  211. package/dist/types/tools/application_integration_tool/clients/cloud_request.d.ts +53 -0
  212. package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +215 -0
  213. package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +72 -0
  214. package/dist/types/tools/crewai_tool.d.ts +85 -0
  215. package/dist/types/tools/example_tool.d.ts +10 -0
  216. package/dist/types/tools/function_tool.d.ts +32 -0
  217. package/dist/types/tools/google_api_tool/google_api_tool.d.ts +30 -0
  218. package/dist/types/tools/google_api_tool/google_api_tool_set.d.ts +78 -0
  219. package/dist/types/tools/google_api_tool/google_api_tool_sets.d.ts +33 -0
  220. package/dist/types/tools/google_api_tool/googleapi_to_openapi_converter.d.ts +164 -0
  221. package/dist/types/tools/google_api_tool/index.d.ts +11 -0
  222. package/dist/types/tools/langchain_tool.d.ts +103 -0
  223. package/dist/types/tools/mcp/index.d.ts +3 -0
  224. package/dist/types/tools/mcp/mcp_session_manager.d.ts +34 -1
  225. package/dist/types/tools/mcp/mcp_toolset.d.ts +15 -0
  226. package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +19 -0
  227. package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +18 -1
  228. package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +2 -1
  229. package/dist/types/tools/retrieval/base_retrieval_tool.d.ts +15 -0
  230. package/dist/types/tools/toolbox_tool.d.ts +73 -0
  231. package/dist/types/utils/env_aware_utils.d.ts +18 -2
  232. package/dist/types/utils/error_utils.d.ts +7 -0
  233. package/dist/types/utils/file_utils.d.ts +6 -1
  234. package/dist/types/utils/gemini_schema_util.d.ts +1 -2
  235. package/dist/types/utils/json_utils.d.ts +11 -0
  236. package/dist/types/utils/object_notation_utils.d.ts +7 -0
  237. package/dist/types/utils/streaming_utils.d.ts +11 -4
  238. package/dist/types/version.d.ts +1 -1
  239. package/dist/web/index_web.js +105 -106
  240. package/dist/web/index_web.js.map +4 -4
  241. package/package.json +8 -3
@@ -0,0 +1,393 @@
1
+ import {createRequire as topLevelCreateRequire} from 'module';
2
+ const require = topLevelCreateRequire(import.meta.url);
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __decorateClass = (decorators, target, key, kind) => {
7
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
8
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
9
+ if (decorator = decorators[i])
10
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
11
+ if (kind && result) __defProp(target, key, result);
12
+ return result;
13
+ };
14
+ /**
15
+ * @license
16
+ * Copyright 2026 Google LLC
17
+ * SPDX-License-Identifier: Apache-2.0
18
+ */
19
+ import * as fs from "node:fs";
20
+ import { experimental } from "../../utils/experimental.js";
21
+ import { logger } from "../../utils/logger.js";
22
+ const GOOGLE_DISCOVERY_BASE_URL = "https://www.googleapis.com/discovery/v1/apis";
23
+ const GOOGLE_OAUTH2_AUTH_URL = "https://accounts.google.com/o/oauth2/auth";
24
+ const GOOGLE_OAUTH2_TOKEN_URL = "https://oauth2.googleapis.com/token";
25
+ function normalizeGoogleSchemaRef(ref) {
26
+ if (ref.startsWith("#")) {
27
+ return `#/components/schemas/${ref.slice(1)}`;
28
+ }
29
+ return `#/components/schemas/${ref}`;
30
+ }
31
+ __name(normalizeGoogleSchemaRef, "normalizeGoogleSchemaRef");
32
+ function convertInfo(googleApiSpec, openapiSpec, apiName, apiVersion) {
33
+ var _a, _b, _c, _d;
34
+ openapiSpec.info = {
35
+ title: (_a = googleApiSpec.title) != null ? _a : `${apiName} API`,
36
+ description: (_b = googleApiSpec.description) != null ? _b : "",
37
+ version: (_c = googleApiSpec.version) != null ? _c : apiVersion,
38
+ contact: {},
39
+ termsOfService: (_d = googleApiSpec.documentationLink) != null ? _d : ""
40
+ };
41
+ const docsLink = googleApiSpec.documentationLink;
42
+ if (docsLink) {
43
+ openapiSpec.externalDocs = {
44
+ description: "API Documentation",
45
+ url: docsLink
46
+ };
47
+ }
48
+ }
49
+ __name(convertInfo, "convertInfo");
50
+ function convertServers(googleApiSpec, openapiSpec, apiName, apiVersion) {
51
+ var _a, _b;
52
+ let baseUrl = `${(_a = googleApiSpec.rootUrl) != null ? _a : ""}${(_b = googleApiSpec.servicePath) != null ? _b : ""}`;
53
+ if (baseUrl.endsWith("/")) {
54
+ baseUrl = baseUrl.slice(0, -1);
55
+ }
56
+ openapiSpec.servers = [
57
+ {
58
+ url: baseUrl,
59
+ description: `${apiName} ${apiVersion} API`
60
+ }
61
+ ];
62
+ }
63
+ __name(convertServers, "convertServers");
64
+ function convertSecuritySchemes(googleApiSpec, openapiSpec) {
65
+ var _a, _b, _c, _d, _e;
66
+ openapiSpec.components = (_a = openapiSpec.components) != null ? _a : {};
67
+ openapiSpec.components.securitySchemes = (_b = openapiSpec.components.securitySchemes) != null ? _b : {};
68
+ const oauth2 = (_c = googleApiSpec.auth) == null ? void 0 : _c.oauth2;
69
+ const hasOauth2 = oauth2 !== void 0 && Object.keys(oauth2).length > 0;
70
+ const formattedScopes = {};
71
+ if (hasOauth2) {
72
+ const scopes = (_d = oauth2.scopes) != null ? _d : {};
73
+ for (const [scope, scopeInfo] of Object.entries(scopes)) {
74
+ formattedScopes[scope] = (_e = scopeInfo.description) != null ? _e : "";
75
+ }
76
+ openapiSpec.components.securitySchemes["oauth2"] = {
77
+ type: "oauth2",
78
+ description: "OAuth 2.0 authentication",
79
+ flows: {
80
+ authorizationCode: {
81
+ authorizationUrl: GOOGLE_OAUTH2_AUTH_URL,
82
+ tokenUrl: GOOGLE_OAUTH2_TOKEN_URL,
83
+ scopes: formattedScopes
84
+ }
85
+ }
86
+ };
87
+ }
88
+ openapiSpec.components.securitySchemes["apiKey"] = {
89
+ type: "apiKey",
90
+ in: "query",
91
+ name: "key",
92
+ description: "API key for accessing this API"
93
+ };
94
+ openapiSpec.security = [
95
+ hasOauth2 ? { oauth2: Object.keys(formattedScopes) } : {},
96
+ { apiKey: [] }
97
+ ];
98
+ }
99
+ __name(convertSecuritySchemes, "convertSecuritySchemes");
100
+ function convertSchemaObject(schemaDef) {
101
+ var _a;
102
+ const result = {};
103
+ if (schemaDef.type !== void 0) {
104
+ const gtype = schemaDef.type;
105
+ if (gtype === "object") {
106
+ result["type"] = "object";
107
+ if (schemaDef.properties !== void 0) {
108
+ const properties = {};
109
+ for (const [propName, propDef] of Object.entries(
110
+ schemaDef.properties
111
+ )) {
112
+ properties[propName] = convertSchemaObject(propDef);
113
+ }
114
+ result["properties"] = properties;
115
+ }
116
+ const requiredFields = [];
117
+ for (const [propName, propDef] of Object.entries(
118
+ (_a = schemaDef.properties) != null ? _a : {}
119
+ )) {
120
+ if (propDef.required) {
121
+ requiredFields.push(propName);
122
+ }
123
+ }
124
+ if (requiredFields.length > 0) {
125
+ result["required"] = requiredFields;
126
+ }
127
+ } else if (gtype === "array") {
128
+ result["type"] = "array";
129
+ if (schemaDef.items !== void 0) {
130
+ result["items"] = convertSchemaObject(schemaDef.items);
131
+ }
132
+ } else if (gtype === "any") {
133
+ result["oneOf"] = [
134
+ { type: "object" },
135
+ { type: "array" },
136
+ { type: "string" },
137
+ { type: "number" },
138
+ { type: "boolean" },
139
+ { type: "null" }
140
+ ];
141
+ } else {
142
+ result["type"] = gtype;
143
+ }
144
+ }
145
+ if (schemaDef.$ref !== void 0) {
146
+ result["$ref"] = normalizeGoogleSchemaRef(schemaDef.$ref);
147
+ }
148
+ if (schemaDef.format !== void 0) {
149
+ result["format"] = schemaDef.format;
150
+ }
151
+ if (schemaDef.enum !== void 0) {
152
+ result["enum"] = schemaDef.enum;
153
+ }
154
+ if (schemaDef.description !== void 0) {
155
+ result["description"] = schemaDef.description;
156
+ }
157
+ if (schemaDef.pattern !== void 0) {
158
+ result["pattern"] = schemaDef.pattern;
159
+ }
160
+ if (schemaDef.default !== void 0) {
161
+ result["default"] = schemaDef.default;
162
+ }
163
+ return result;
164
+ }
165
+ __name(convertSchemaObject, "convertSchemaObject");
166
+ function convertSchemas(googleApiSpec, openapiSpec) {
167
+ var _a, _b, _c;
168
+ openapiSpec.components = (_a = openapiSpec.components) != null ? _a : {};
169
+ openapiSpec.components.schemas = (_b = openapiSpec.components.schemas) != null ? _b : {};
170
+ const schemas = (_c = googleApiSpec.schemas) != null ? _c : {};
171
+ for (const [schemaName, schemaDef] of Object.entries(schemas)) {
172
+ openapiSpec.components.schemas[schemaName] = convertSchemaObject(schemaDef);
173
+ }
174
+ }
175
+ __name(convertSchemas, "convertSchemas");
176
+ function extractPathParameters(path) {
177
+ const params = [];
178
+ for (const match of path.matchAll(/\{\+?([^{}]+)\}/g)) {
179
+ params.push(match[1]);
180
+ }
181
+ return params;
182
+ }
183
+ __name(extractPathParameters, "extractPathParameters");
184
+ function convertParameterSchema(paramData) {
185
+ var _a;
186
+ const schema = {
187
+ type: (_a = paramData.type) != null ? _a : "string"
188
+ };
189
+ if (paramData.enum !== void 0) {
190
+ schema["enum"] = paramData.enum;
191
+ }
192
+ if (paramData.format !== void 0) {
193
+ schema["format"] = paramData.format;
194
+ }
195
+ if (paramData.default !== void 0) {
196
+ schema["default"] = paramData.default;
197
+ }
198
+ if (paramData.pattern !== void 0) {
199
+ schema["pattern"] = paramData.pattern;
200
+ }
201
+ return schema;
202
+ }
203
+ __name(convertParameterSchema, "convertParameterSchema");
204
+ function convertOperation(methodData, pathParams) {
205
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
206
+ const parameters = [];
207
+ for (const paramName of pathParams) {
208
+ parameters.push({
209
+ name: paramName,
210
+ in: "path",
211
+ required: true,
212
+ schema: { type: "string" }
213
+ });
214
+ }
215
+ const pathParamSet = new Set(pathParams);
216
+ for (const [paramName, paramData] of Object.entries(
217
+ (_a = methodData.parameters) != null ? _a : {}
218
+ )) {
219
+ if (pathParamSet.has(paramName)) {
220
+ continue;
221
+ }
222
+ const location = (_b = paramData.location) != null ? _b : "query";
223
+ parameters.push({
224
+ name: paramName,
225
+ in: location,
226
+ description: (_c = paramData.description) != null ? _c : "",
227
+ required: location === "path" ? true : (_d = paramData.required) != null ? _d : false,
228
+ schema: convertParameterSchema(paramData)
229
+ });
230
+ }
231
+ const response200 = {
232
+ description: "Successful operation"
233
+ };
234
+ const responseRef = (_e = methodData.response) == null ? void 0 : _e.$ref;
235
+ if (responseRef) {
236
+ response200.content = {
237
+ "application/json": {
238
+ schema: { $ref: normalizeGoogleSchemaRef(responseRef) }
239
+ }
240
+ };
241
+ }
242
+ const operation = {
243
+ operationId: (_f = methodData.id) != null ? _f : "",
244
+ summary: (_g = methodData.description) != null ? _g : "",
245
+ description: (_h = methodData.description) != null ? _h : "",
246
+ parameters,
247
+ responses: {
248
+ "200": response200,
249
+ "400": { description: "Bad request" },
250
+ "401": { description: "Unauthorized" },
251
+ "403": { description: "Forbidden" },
252
+ "404": { description: "Not found" },
253
+ "500": { description: "Server error" }
254
+ }
255
+ };
256
+ const requestRef = (_i = methodData.request) == null ? void 0 : _i.$ref;
257
+ if (requestRef) {
258
+ operation.requestBody = {
259
+ description: "Request body",
260
+ content: {
261
+ "application/json": {
262
+ schema: { $ref: normalizeGoogleSchemaRef(requestRef) }
263
+ }
264
+ },
265
+ required: true
266
+ };
267
+ }
268
+ const scopes = (_j = methodData.scopes) != null ? _j : [];
269
+ if (scopes.length > 0) {
270
+ operation.security = [{ oauth2: scopes }];
271
+ }
272
+ return operation;
273
+ }
274
+ __name(convertOperation, "convertOperation");
275
+ function convertMethods(methods, _resourcePath, openapiSpec) {
276
+ var _a, _b;
277
+ for (const methodData of Object.values(methods)) {
278
+ const httpMethod = ((_a = methodData.httpMethod) != null ? _a : "GET").toLowerCase();
279
+ let restPath = ((_b = methodData.path) != null ? _b : "/").replace(
280
+ /\{\+([^{}]+)\}/g,
281
+ (_match, paramName) => `{${paramName}}`
282
+ );
283
+ if (!restPath.startsWith("/")) {
284
+ restPath = `/${restPath}`;
285
+ }
286
+ const pathParams = extractPathParameters(restPath);
287
+ if (!openapiSpec.paths[restPath]) {
288
+ openapiSpec.paths[restPath] = {};
289
+ }
290
+ const pathItem = openapiSpec.paths[restPath];
291
+ pathItem[httpMethod] = convertOperation(methodData, pathParams);
292
+ }
293
+ }
294
+ __name(convertMethods, "convertMethods");
295
+ function convertResources(resources, openapiSpec, parentPath = "") {
296
+ var _a;
297
+ for (const [resourceName, resourceData] of Object.entries(resources)) {
298
+ const resourcePath = `${parentPath}/${resourceName}`;
299
+ convertMethods((_a = resourceData.methods) != null ? _a : {}, resourcePath, openapiSpec);
300
+ if (resourceData.resources && Object.keys(resourceData.resources).length > 0) {
301
+ convertResources(resourceData.resources, openapiSpec, resourcePath);
302
+ }
303
+ }
304
+ }
305
+ __name(convertResources, "convertResources");
306
+ let GoogleApiToOpenApiConverter = class {
307
+ constructor(apiName, apiVersion) {
308
+ this.googleApiSpec = null;
309
+ this.apiName = apiName;
310
+ this.apiVersion = apiVersion;
311
+ this.openapiSpec = {
312
+ openapi: "3.0.0",
313
+ info: {},
314
+ servers: [],
315
+ paths: {},
316
+ components: { schemas: {}, securitySchemes: {} }
317
+ };
318
+ }
319
+ async fetchGoogleApiSpec() {
320
+ try {
321
+ logger.debug(
322
+ `Fetching Google API spec for ${this.apiName} ${this.apiVersion}`
323
+ );
324
+ const url = `${GOOGLE_DISCOVERY_BASE_URL}/${encodeURIComponent(this.apiName)}/${encodeURIComponent(this.apiVersion)}/rest`;
325
+ const response = await globalThis.fetch(url);
326
+ if (response.status >= 400) {
327
+ throw new Error(
328
+ `HTTP Error ${response.status}: Failed to fetch Google API spec for ${this.apiName} ${this.apiVersion}`
329
+ );
330
+ }
331
+ const spec = await response.json();
332
+ if (!spec || typeof spec !== "object" || Object.keys(spec).length === 0) {
333
+ throw new Error("Failed to retrieve API specification");
334
+ }
335
+ this.googleApiSpec = spec;
336
+ logger.debug(`Successfully fetched ${this.apiName} API specification`);
337
+ } catch (error) {
338
+ logger.error(
339
+ `Error fetching API spec: ${error instanceof Error ? error.message : String(error)}`
340
+ );
341
+ throw error;
342
+ }
343
+ }
344
+ async convert() {
345
+ var _a, _b, _c;
346
+ if (!this.googleApiSpec) {
347
+ await this.fetchGoogleApiSpec();
348
+ }
349
+ const spec = (_a = this.googleApiSpec) != null ? _a : {};
350
+ convertInfo(spec, this.openapiSpec, this.apiName, this.apiVersion);
351
+ convertServers(spec, this.openapiSpec, this.apiName, this.apiVersion);
352
+ convertSecuritySchemes(spec, this.openapiSpec);
353
+ convertSchemas(spec, this.openapiSpec);
354
+ convertResources((_b = spec.resources) != null ? _b : {}, this.openapiSpec);
355
+ convertMethods((_c = spec.methods) != null ? _c : {}, "/", this.openapiSpec);
356
+ return this.openapiSpec;
357
+ }
358
+ saveOpenapiSpec(outputPath) {
359
+ fs.writeFileSync(
360
+ outputPath,
361
+ JSON.stringify(this.openapiSpec, null, 2),
362
+ "utf-8"
363
+ );
364
+ logger.info(`OpenAPI specification saved to ${outputPath}`);
365
+ }
366
+ };
367
+ __name(GoogleApiToOpenApiConverter, "GoogleApiToOpenApiConverter");
368
+ __decorateClass([
369
+ experimental
370
+ ], GoogleApiToOpenApiConverter.prototype, "fetchGoogleApiSpec", 1);
371
+ __decorateClass([
372
+ experimental
373
+ ], GoogleApiToOpenApiConverter.prototype, "convert", 1);
374
+ __decorateClass([
375
+ experimental
376
+ ], GoogleApiToOpenApiConverter.prototype, "saveOpenapiSpec", 1);
377
+ GoogleApiToOpenApiConverter = __decorateClass([
378
+ experimental
379
+ ], GoogleApiToOpenApiConverter);
380
+ export {
381
+ GoogleApiToOpenApiConverter,
382
+ convertInfo,
383
+ convertMethods,
384
+ convertOperation,
385
+ convertParameterSchema,
386
+ convertResources,
387
+ convertSchemaObject,
388
+ convertSchemas,
389
+ convertSecuritySchemes,
390
+ convertServers,
391
+ extractPathParameters,
392
+ normalizeGoogleSchemaRef
393
+ };
@@ -0,0 +1,33 @@
1
+ import {createRequire as topLevelCreateRequire} from 'module';
2
+ const require = topLevelCreateRequire(import.meta.url);
3
+ /**
4
+ * @license
5
+ * Copyright 2026 Google LLC
6
+ * SPDX-License-Identifier: Apache-2.0
7
+ */
8
+ import { GoogleApiTool, isGoogleApiTool } from "./google_api_tool.js";
9
+ import { GoogleApiToolSet, isGoogleApiToolSet } from "./google_api_tool_set.js";
10
+ import {
11
+ bigqueryToolSet,
12
+ calendarToolSet,
13
+ docsToolSet,
14
+ gmailToolSet,
15
+ sheetsToolSet,
16
+ slidesToolSet,
17
+ youtubeToolSet
18
+ } from "./google_api_tool_sets.js";
19
+ import { GoogleApiToOpenApiConverter } from "./googleapi_to_openapi_converter.js";
20
+ export {
21
+ GoogleApiToOpenApiConverter,
22
+ GoogleApiTool,
23
+ GoogleApiToolSet,
24
+ bigqueryToolSet,
25
+ calendarToolSet,
26
+ docsToolSet,
27
+ gmailToolSet,
28
+ isGoogleApiTool,
29
+ isGoogleApiToolSet,
30
+ sheetsToolSet,
31
+ slidesToolSet,
32
+ youtubeToolSet
33
+ };
@@ -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 { toJsonSchema } from "../utils/schema.js";
12
+ import { isZodObject, isZodSchema } from "../utils/simple_zod_to_json.js";
13
+ import { GoogleLLMVariant } from "../utils/variant_utils.js";
14
+ import {
15
+ buildFunctionDeclarationForLangchain,
16
+ buildFunctionDeclarationUtil,
17
+ FunctionTool
18
+ } from "./function_tool.js";
19
+ const LANGCHAIN_TOOL_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for("google.adk.langchainTool");
20
+ function isLangchainTool(obj) {
21
+ return typeof obj === "object" && obj !== null && LANGCHAIN_TOOL_SIGNATURE_SYMBOL in obj && obj[LANGCHAIN_TOOL_SIGNATURE_SYMBOL] === true;
22
+ }
23
+ __name(isLangchainTool, "isLangchainTool");
24
+ function isLangchainToolConfig(value) {
25
+ return typeof value === "object" && value !== null && "tool" in value && typeof value.tool === "object" && value.tool !== null;
26
+ }
27
+ __name(isLangchainToolConfig, "isLangchainToolConfig");
28
+ function resolveRunnerFunction(tool) {
29
+ if (typeof tool._run === "function") {
30
+ return tool._run.bind(tool);
31
+ }
32
+ if (typeof tool._call === "function") {
33
+ return tool._call.bind(tool);
34
+ }
35
+ if (typeof tool.invoke === "function") {
36
+ return tool.invoke.bind(tool);
37
+ }
38
+ if (typeof tool.run === "function") {
39
+ return tool.run.bind(tool);
40
+ }
41
+ throw new TypeError(
42
+ "LangchainTool requires a tool object with a _run, _call, invoke, or run method."
43
+ );
44
+ }
45
+ __name(resolveRunnerFunction, "resolveRunnerFunction");
46
+ function isStructuredLangchainTool(tool) {
47
+ return typeof tool._run === "function" || typeof tool._call === "function" || typeof tool.invoke === "function" || tool.argsSchema !== void 0 || tool.schema !== void 0 || tool.args !== void 0;
48
+ }
49
+ __name(isStructuredLangchainTool, "isStructuredLangchainTool");
50
+ function extractLangchainPropertiesMap(tool) {
51
+ var _a2;
52
+ if (tool.args && typeof tool.args === "object") {
53
+ return structuredClone(tool.args);
54
+ }
55
+ const schemaSource = (_a2 = tool.argsSchema) != null ? _a2 : tool.schema;
56
+ if (!schemaSource) {
57
+ return {};
58
+ }
59
+ let rawSchema;
60
+ if (typeof schemaSource.modelJsonSchema === "function") {
61
+ rawSchema = schemaSource.modelJsonSchema();
62
+ } else if (typeof schemaSource.jsonSchema === "function") {
63
+ rawSchema = schemaSource.jsonSchema();
64
+ } else if (isZodSchema(schemaSource)) {
65
+ rawSchema = structuredClone(toJsonSchema(schemaSource));
66
+ } else {
67
+ rawSchema = structuredClone(schemaSource);
68
+ }
69
+ const properties = rawSchema["properties"] && typeof rawSchema["properties"] === "object" ? structuredClone(
70
+ rawSchema["properties"]
71
+ ) : structuredClone(rawSchema);
72
+ const requiredSet = Array.isArray(rawSchema["required"]) ? new Set(rawSchema["required"]) : void 0;
73
+ for (const [key, prop] of Object.entries(properties)) {
74
+ if (!prop || typeof prop !== "object") {
75
+ continue;
76
+ }
77
+ if (Array.isArray(prop["type"])) {
78
+ const types = prop["type"];
79
+ delete prop["type"];
80
+ prop["anyOf"] = types.map((t) => ({ type: t }));
81
+ } else if (requiredSet !== void 0 && !requiredSet.has(key) && !("default" in prop) && !("anyOf" in prop) && typeof prop["type"] === "string") {
82
+ const propType = prop["type"];
83
+ delete prop["type"];
84
+ prop["anyOf"] = [{ type: propType }, { type: "null" }];
85
+ }
86
+ }
87
+ return properties;
88
+ }
89
+ __name(extractLangchainPropertiesMap, "extractLangchainPropertiesMap");
90
+ const _LangchainTool = class _LangchainTool extends (_b = FunctionTool, _a = LANGCHAIN_TOOL_SIGNATURE_SYMBOL, _b) {
91
+ constructor(toolOrConfig, options) {
92
+ var _a2, _b2, _c, _d;
93
+ const config = isLangchainToolConfig(toolOrConfig) ? toolOrConfig : {
94
+ tool: toolOrConfig,
95
+ name: options == null ? void 0 : options.name,
96
+ description: options == null ? void 0 : options.description
97
+ };
98
+ const runnerFn = resolveRunnerFunction(config.tool);
99
+ const rawFn = (_c = (_b2 = (_a2 = config.tool._run) != null ? _a2 : config.tool._call) != null ? _b2 : config.tool.invoke) != null ? _c : config.tool.run;
100
+ const resolvedName = config.name || config.tool.name || (rawFn == null ? void 0 : rawFn.name) || "langchain_tool";
101
+ const resolvedDescription = config.description || config.tool.description || "";
102
+ const schemaCandidate = (_d = config.tool.argsSchema) != null ? _d : config.tool.schema;
103
+ super({
104
+ name: resolvedName,
105
+ description: resolvedDescription,
106
+ parameters: isZodObject(schemaCandidate) ? schemaCandidate : void 0,
107
+ execute: /* @__PURE__ */ __name(async (args, toolContext) => {
108
+ return await runnerFn(
109
+ args != null ? args : {},
110
+ toolContext
111
+ );
112
+ }, "execute")
113
+ });
114
+ /** A unique symbol to identify ADK LangchainTool class. */
115
+ this[_a] = true;
116
+ this.tool = config.tool;
117
+ }
118
+ /**
119
+ * Builds the `FunctionDeclaration` for the wrapped LangChain tool.
120
+ */
121
+ _getDeclaration() {
122
+ var _a2, _b2, _c;
123
+ if (isStructuredLangchainTool(this.tool)) {
124
+ const propertiesMap = extractLangchainPropertiesMap(this.tool);
125
+ const rawFn = (_c = (_b2 = (_a2 = this.tool._run) != null ? _a2 : this.tool._call) != null ? _b2 : this.tool.invoke) != null ? _c : this.tool.run;
126
+ return buildFunctionDeclarationForLangchain(
127
+ this.apiVariant === GoogleLLMVariant.VERTEX_AI,
128
+ this.name,
129
+ this.description,
130
+ rawFn,
131
+ propertiesMap
132
+ );
133
+ }
134
+ return buildFunctionDeclarationUtil(
135
+ this.apiVariant === GoogleLLMVariant.VERTEX_AI,
136
+ this.name,
137
+ this.description,
138
+ this.tool.run,
139
+ { properties: extractLangchainPropertiesMap(this.tool) }
140
+ );
141
+ }
142
+ };
143
+ __name(_LangchainTool, "LangchainTool");
144
+ let LangchainTool = _LangchainTool;
145
+ export {
146
+ LangchainTool,
147
+ isLangchainTool
148
+ };
@@ -5,7 +5,13 @@ const require = topLevelCreateRequire(import.meta.url);
5
5
  * Copyright 2026 Google LLC
6
6
  * SPDX-License-Identifier: Apache-2.0
7
7
  */
8
+ import { toGeminiSchema } from "../../utils/gemini_schema_util.js";
9
+ import { genaiSchemaToJsonSchema } from "../../utils/genai_schema_to_json.js";
8
10
  export * from "./load_mcp_resource_tool.js";
9
11
  export * from "./mcp_session_manager.js";
10
12
  export * from "./mcp_tool.js";
11
13
  export * from "./mcp_toolset.js";
14
+ export {
15
+ genaiSchemaToJsonSchema,
16
+ toGeminiSchema
17
+ };
@@ -52,6 +52,18 @@ function buildTransportOptions(params) {
52
52
  };
53
53
  }
54
54
  __name(buildTransportOptions, "buildTransportOptions");
55
+ function buildSseTransportOptions(params) {
56
+ const { transportOptions, header, headers } = params;
57
+ const callerHeaders = (transportOptions == null ? void 0 : transportOptions.requestInit) === void 0 ? header != null ? header : headers : transportOptions.requestInit.headers;
58
+ return {
59
+ ...transportOptions,
60
+ requestInit: {
61
+ ...transportOptions == null ? void 0 : transportOptions.requestInit,
62
+ headers: mergeTrackingHeaders(callerHeaders)
63
+ }
64
+ };
65
+ }
66
+ __name(buildSseTransportOptions, "buildSseTransportOptions");
55
67
  const _MCPSessionManager = class _MCPSessionManager {
56
68
  constructor(connectionParams) {
57
69
  this.activeSessions = /* @__PURE__ */ new Set();
@@ -90,6 +102,19 @@ const _MCPSessionManager = class _MCPSessionManager {
90
102
  await client.connect(transport);
91
103
  break;
92
104
  }
105
+ case "SseConnectionParams": {
106
+ const { SSEClientTransport } = await loadOptionalPeer(
107
+ MCP_SDK,
108
+ () => Promise.resolve().then(() => __toESM(require("@modelcontextprotocol/sdk/client/sse.js"), 1))
109
+ );
110
+ const transport = new SSEClientTransport(
111
+ new URL(this.connectionParams.url),
112
+ buildSseTransportOptions(this.connectionParams)
113
+ );
114
+ transport.onerror = logTransportError;
115
+ await client.connect(transport);
116
+ break;
117
+ }
93
118
  default: {
94
119
  const _exhaustiveCheck = this.connectionParams;
95
120
  break;
@@ -131,12 +131,11 @@ function bearerJwtScheme() {
131
131
  }
132
132
  __name(bearerJwtScheme, "bearerJwtScheme");
133
133
  function bearerTokenParam(authScheme, token) {
134
- var _a;
135
134
  const param = {
136
135
  originalName: "Authorization",
137
136
  paramLocation: "header",
138
137
  paramSchema: { type: "string" },
139
- description: (_a = authScheme.description) != null ? _a : "Bearer token",
138
+ description: authScheme.description || "Bearer token",
140
139
  name: `${INTERNAL_AUTH_PREFIX}Authorization`,
141
140
  required: true
142
141
  };