@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,215 @@
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 { experimental } from "../../../utils/experimental.js";
20
+ import { isJsonObject } from "../../../utils/json_utils.js";
21
+ import {
22
+ CloudPlatformTokenSource,
23
+ sendCloudRequest,
24
+ unexpectedError
25
+ } from "./cloud_request.js";
26
+ import {
27
+ actionRequest,
28
+ actionResponse,
29
+ ConnectionsClient,
30
+ CONNECTOR_BASE_SPEC,
31
+ connectorPayload,
32
+ createOperation,
33
+ createOperationRequest,
34
+ deleteOperation,
35
+ deleteOperationRequest,
36
+ executeCustomQueryRequest,
37
+ getActionOperation,
38
+ getOperation,
39
+ getOperationRequest,
40
+ listOperation,
41
+ listOperationRequest,
42
+ updateOperation,
43
+ updateOperationRequest
44
+ } from "./connections_client.js";
45
+ const EXECUTE_CONNECTION_INTEGRATION = "ExecuteConnection";
46
+ const EXECUTE_CUSTOM_QUERY_ACTION = "ExecuteCustomQuery";
47
+ let IntegrationClient = class {
48
+ constructor(options) {
49
+ var _a, _b;
50
+ this.project = options.project;
51
+ this.location = options.location;
52
+ this.integration = options.integration;
53
+ this.trigger = options.trigger;
54
+ this.connection = options.connection;
55
+ this.entityOperations = (_a = options.entityOperations) != null ? _a : {};
56
+ this.actions = (_b = options.actions) != null ? _b : [];
57
+ this.serviceAccountJson = options.serviceAccountJson;
58
+ this.tokenSource = new CloudPlatformTokenSource(options.serviceAccountJson);
59
+ }
60
+ /**
61
+ * Fetches the OpenAPI spec Application Integration generates for the API
62
+ * trigger of the integration.
63
+ *
64
+ * @throws Error For a rejected request, a missing credential, or a response
65
+ * that carries no parseable spec.
66
+ */
67
+ async getOpenApiSpecForIntegration() {
68
+ const url = `https://${this.location}-integrations.googleapis.com/v1/projects/${this.project}/locations/${this.location}:generateOpenApiSpec`;
69
+ const body = await sendCloudRequest({
70
+ url,
71
+ method: "POST",
72
+ body: {
73
+ apiTriggerResources: [
74
+ {
75
+ integrationResource: this.integration,
76
+ triggerId: [this.trigger]
77
+ }
78
+ ],
79
+ fileFormat: "JSON"
80
+ },
81
+ tokenSource: this.tokenSource,
82
+ invalidRequestMessage: `Invalid request. Please check the provided values of project(${this.project}), location(${this.location}), integration(${this.integration}) and trigger(${this.trigger}).`
83
+ });
84
+ try {
85
+ const spec = isJsonObject(body) ? body["openApiSpec"] : void 0;
86
+ if (typeof spec !== "string") {
87
+ throw new Error("The response carries no openApiSpec string.");
88
+ }
89
+ const parsed = JSON.parse(spec);
90
+ if (!isJsonObject(parsed)) {
91
+ throw new Error("The openApiSpec is not a JSON object.");
92
+ }
93
+ return parsed;
94
+ } catch (e) {
95
+ throw unexpectedError(e);
96
+ }
97
+ }
98
+ /**
99
+ * Builds an OpenAPI spec for the entity operations and actions of the
100
+ * connection.
101
+ *
102
+ * Every operation becomes a POST to the `ExecuteConnection` integration,
103
+ * with a path fragment that keeps the paths distinct.
104
+ *
105
+ * @param toolName Prefix of every generated `operationId`.
106
+ * @param toolInstructions Text appended to every operation description.
107
+ * @throws Error When neither entity operations nor actions are configured,
108
+ * or an operation is not one of create, update, delete, list or get.
109
+ */
110
+ async getOpenApiSpecForConnection(toolName = "", toolInstructions = "") {
111
+ var _a;
112
+ if (Object.keys(this.entityOperations).length === 0 && this.actions.length === 0) {
113
+ throw new Error(
114
+ "No entity operations or actions provided. Please provide at least one of them."
115
+ );
116
+ }
117
+ const connectionsClient = new ConnectionsClient({
118
+ project: this.project,
119
+ location: this.location,
120
+ connection: (_a = this.connection) != null ? _a : "",
121
+ serviceAccountJson: this.serviceAccountJson
122
+ });
123
+ const connectorSpec = structuredClone(CONNECTOR_BASE_SPEC);
124
+ const schemas = connectorSpec.components.schemas;
125
+ const pathPrefix = `/v2/projects/${this.project}/locations/${this.location}/integrations/${EXECUTE_CONNECTION_INTEGRATION}:execute?triggerId=api_trigger/${EXECUTE_CONNECTION_INTEGRATION}`;
126
+ for (const [entity, requestedOperations] of Object.entries(
127
+ this.entityOperations
128
+ )) {
129
+ const { schema, operations: supportedOperations } = await connectionsClient.getEntitySchemaAndOperations(entity);
130
+ const operations = requestedOperations.length > 0 ? requestedOperations : supportedOperations;
131
+ const schemaAsString = JSON.stringify(schema);
132
+ schemas[`connectorInputPayload_${entity}`] = connectorPayload(schema);
133
+ for (const operation of operations) {
134
+ const operationLower = operation.toLowerCase();
135
+ const path = `${pathPrefix}#${operationLower}_${entity}`;
136
+ switch (operationLower) {
137
+ case "create":
138
+ connectorSpec.paths[path] = createOperation({
139
+ entity,
140
+ toolName,
141
+ toolInstructions
142
+ });
143
+ schemas[`create_${entity}_Request`] = createOperationRequest(entity);
144
+ break;
145
+ case "update":
146
+ connectorSpec.paths[path] = updateOperation({
147
+ entity,
148
+ toolName,
149
+ toolInstructions
150
+ });
151
+ schemas[`update_${entity}_Request`] = updateOperationRequest(entity);
152
+ break;
153
+ case "delete":
154
+ connectorSpec.paths[path] = deleteOperation({
155
+ entity,
156
+ toolName,
157
+ toolInstructions
158
+ });
159
+ schemas[`delete_${entity}_Request`] = deleteOperationRequest();
160
+ break;
161
+ case "list":
162
+ connectorSpec.paths[path] = listOperation({
163
+ entity,
164
+ schemaAsString,
165
+ toolName,
166
+ toolInstructions
167
+ });
168
+ schemas[`list_${entity}_Request`] = listOperationRequest();
169
+ break;
170
+ case "get":
171
+ connectorSpec.paths[path] = getOperation({
172
+ entity,
173
+ schemaAsString,
174
+ toolName,
175
+ toolInstructions
176
+ });
177
+ schemas[`get_${entity}_Request`] = getOperationRequest();
178
+ break;
179
+ default:
180
+ throw new Error(
181
+ `Invalid operation: ${operation} for entity: ${entity}`
182
+ );
183
+ }
184
+ }
185
+ }
186
+ for (const action of this.actions) {
187
+ const { inputSchema, outputSchema, displayName } = await connectionsClient.getActionSchema(action);
188
+ let operation = "EXECUTE_ACTION";
189
+ if (action === EXECUTE_CUSTOM_QUERY_ACTION) {
190
+ schemas[`${action}_Request`] = executeCustomQueryRequest();
191
+ operation = "EXECUTE_QUERY";
192
+ } else {
193
+ schemas[`${displayName}_Request`] = actionRequest(displayName);
194
+ schemas[`connectorInputPayload_${displayName}`] = connectorPayload(inputSchema);
195
+ }
196
+ schemas[`connectorOutputPayload_${displayName}`] = connectorPayload(outputSchema);
197
+ schemas[`${displayName}_Response`] = actionResponse(displayName);
198
+ connectorSpec.paths[`${pathPrefix}#${action}`] = getActionOperation({
199
+ action,
200
+ operation,
201
+ actionDisplayName: displayName,
202
+ toolName,
203
+ toolInstructions
204
+ });
205
+ }
206
+ return connectorSpec;
207
+ }
208
+ };
209
+ __name(IntegrationClient, "IntegrationClient");
210
+ IntegrationClient = __decorateClass([
211
+ experimental
212
+ ], IntegrationClient);
213
+ export {
214
+ IntegrationClient
215
+ };
@@ -0,0 +1,107 @@
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
+ buildFunctionDeclarationForParamsForCrewai,
16
+ FunctionTool
17
+ } from "./function_tool.js";
18
+ const CREWAI_TOOL_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for("google.adk.crewaiTool");
19
+ function isCrewaiTool(obj) {
20
+ return typeof obj === "object" && obj !== null && CREWAI_TOOL_SIGNATURE_SYMBOL in obj && obj[CREWAI_TOOL_SIGNATURE_SYMBOL] === true;
21
+ }
22
+ __name(isCrewaiTool, "isCrewaiTool");
23
+ function isCrewaiToolConfig(value) {
24
+ return typeof value === "object" && value !== null && "tool" in value && typeof value.tool === "object" && value.tool !== null && typeof value.tool.run === "function";
25
+ }
26
+ __name(isCrewaiToolConfig, "isCrewaiToolConfig");
27
+ function normalizeCrewaiSchemaJson(argsSchema) {
28
+ if (!argsSchema) {
29
+ return {};
30
+ }
31
+ if (typeof argsSchema.modelJsonSchema === "function") {
32
+ return argsSchema.modelJsonSchema();
33
+ }
34
+ if (typeof argsSchema.jsonSchema === "function") {
35
+ return argsSchema.jsonSchema();
36
+ }
37
+ if (isZodSchema(argsSchema)) {
38
+ const raw = structuredClone(toJsonSchema(argsSchema));
39
+ const requiredSet = new Set(
40
+ Array.isArray(raw["required"]) ? raw["required"] : []
41
+ );
42
+ const properties = raw["properties"];
43
+ if (properties && typeof properties === "object") {
44
+ for (const [key, prop] of Object.entries(properties)) {
45
+ if (!prop || typeof prop !== "object") {
46
+ continue;
47
+ }
48
+ if (Array.isArray(prop["type"])) {
49
+ const types = prop["type"];
50
+ delete prop["type"];
51
+ prop["anyOf"] = types.map((t) => ({ type: t }));
52
+ } else if (!requiredSet.has(key) && !("default" in prop) && !("anyOf" in prop) && typeof prop["type"] === "string") {
53
+ const propType = prop["type"];
54
+ delete prop["type"];
55
+ prop["anyOf"] = [{ type: propType }, { type: "null" }];
56
+ }
57
+ }
58
+ }
59
+ return raw;
60
+ }
61
+ return structuredClone(argsSchema);
62
+ }
63
+ __name(normalizeCrewaiSchemaJson, "normalizeCrewaiSchemaJson");
64
+ const _CrewaiTool = class _CrewaiTool extends (_b = FunctionTool, _a = CREWAI_TOOL_SIGNATURE_SYMBOL, _b) {
65
+ constructor(toolOrConfig, options) {
66
+ const config = isCrewaiToolConfig(toolOrConfig) ? toolOrConfig : {
67
+ tool: toolOrConfig,
68
+ name: options == null ? void 0 : options.name,
69
+ description: options == null ? void 0 : options.description
70
+ };
71
+ const resolvedName = config.name || (config.tool.name ? config.tool.name.replace(/ /g, "_").toLowerCase() : config.tool.run.name || "crewai_tool");
72
+ const resolvedDescription = config.description || config.tool.description || "";
73
+ super({
74
+ name: resolvedName,
75
+ description: resolvedDescription,
76
+ parameters: isZodObject(config.tool.argsSchema) ? config.tool.argsSchema : void 0,
77
+ execute: /* @__PURE__ */ __name(async (args, toolContext) => {
78
+ return await config.tool.run(
79
+ args != null ? args : {},
80
+ toolContext
81
+ );
82
+ }, "execute")
83
+ });
84
+ /** A unique symbol to identify ADK CrewaiTool class. */
85
+ this[_a] = true;
86
+ this.tool = config.tool;
87
+ }
88
+ /**
89
+ * Builds the `FunctionDeclaration` for the wrapped CrewAI tool.
90
+ */
91
+ _getDeclaration() {
92
+ const schemaJson = normalizeCrewaiSchemaJson(this.tool.argsSchema);
93
+ return buildFunctionDeclarationForParamsForCrewai(
94
+ this.apiVariant === GoogleLLMVariant.VERTEX_AI,
95
+ this.name,
96
+ this.description,
97
+ this.tool.run,
98
+ schemaJson
99
+ );
100
+ }
101
+ };
102
+ __name(_CrewaiTool, "CrewaiTool");
103
+ let CrewaiTool = _CrewaiTool;
104
+ export {
105
+ CrewaiTool,
106
+ isCrewaiTool
107
+ };
@@ -7,12 +7,21 @@ 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
- import { buildExampleSi } from "../examples/example_util.js";
10
+ import {
11
+ isBaseExampleProvider
12
+ } from "../examples/base_example_provider.js";
13
+ import { buildExampleSi, validateExamples } from "../examples/example_util.js";
11
14
  import { appendInstructions } from "../models/llm_request.js";
12
15
  import {
13
16
  BaseTool
14
17
  } from "./base_tool.js";
15
18
  const _ExampleTool = class _ExampleTool extends BaseTool {
19
+ /**
20
+ * @param examples - A list of {@link Example}s, or a
21
+ * {@link BaseExampleProvider} that returns them for a query.
22
+ * @throws {InputValidationError} When `examples` is neither a
23
+ * {@link BaseExampleProvider} nor a list of well-formed examples.
24
+ */
16
25
  constructor(examples) {
17
26
  super({
18
27
  // Name and description are not used because this tool only changes
@@ -20,6 +29,9 @@ const _ExampleTool = class _ExampleTool extends BaseTool {
20
29
  name: "example_tool",
21
30
  description: "example tool"
22
31
  });
32
+ if (!isBaseExampleProvider(examples)) {
33
+ validateExamples(examples);
34
+ }
23
35
  this.examples = examples;
24
36
  }
25
37
  async runAsync(_request) {