@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.
- package/dist/cjs/a2a/a2a_remote_agent.js +4 -1
- package/dist/cjs/a2a/agent_card.js +102 -26
- package/dist/cjs/a2a/agent_to_a2a.js +1 -1
- package/dist/cjs/agents/agent_engine_client.js +172 -0
- package/dist/cjs/agents/base_agent.js +20 -4
- package/dist/cjs/agents/functions.js +227 -25
- package/dist/cjs/agents/instructions.js +6 -2
- package/dist/cjs/agents/invocation_context.js +26 -4
- package/dist/cjs/agents/langgraph_agent.js +152 -0
- package/dist/cjs/agents/llm_agent.js +194 -107
- package/dist/cjs/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/code_execution_request_processor.js +18 -6
- package/dist/cjs/agents/processors/content_processor_utils.js +38 -10
- package/dist/cjs/agents/processors/content_request_processor.js +34 -2
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/nl_planning_processor.js +12 -3
- package/dist/cjs/artifacts/in_memory_artifact_service.js +14 -0
- package/dist/cjs/auth/auth_handler.js +37 -5
- package/dist/cjs/auth/auth_schemes.js +9 -0
- package/dist/cjs/cli/cli_eval.js +532 -0
- package/dist/cjs/cli/utils/envs.js +116 -0
- package/dist/cjs/cli/utils/evals.js +137 -0
- package/dist/cjs/cli/utils/logs.js +150 -0
- package/dist/cjs/code_executors/agent_engine_sandbox_code_executor.js +7 -2
- package/dist/cjs/code_executors/code_execution_utils.js +48 -16
- package/dist/cjs/code_executors/code_executor_context.js +6 -2
- package/dist/cjs/code_executors/container_code_executor.js +27 -16
- package/dist/cjs/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/cjs/common.js +61 -0
- package/dist/cjs/context/summarizers/llm_summarizer.js +12 -10
- package/dist/cjs/context/token_based_context_compactor.js +2 -1
- package/dist/cjs/errors/input_validation_error.js +3 -2
- package/dist/cjs/events/event.js +4 -2
- package/dist/cjs/examples/example_util.js +23 -2
- package/dist/cjs/flows/llm_flows/audio_transcriber.js +170 -0
- package/dist/cjs/index.js +104 -1
- package/dist/cjs/integrations/agent_registry/helpers.js +1 -1
- package/dist/cjs/models/gemini_llm_connection.js +16 -8
- package/dist/cjs/models/google_llm.js +13 -16
- package/dist/cjs/models/llm_response.js +9 -1
- package/dist/cjs/models/registry.js +1 -1
- package/dist/cjs/models/routed_llm.js +9 -8
- package/dist/cjs/planners/plan_re_act_planner.js +1 -1
- package/dist/cjs/plugins/base_plugin.js +13 -23
- package/dist/cjs/runner/in_memory_runner.js +6 -11
- package/dist/cjs/runner/runner.js +105 -33
- package/dist/cjs/sessions/base_session_service.js +14 -8
- package/dist/cjs/sessions/database_session_service.js +50 -28
- package/dist/cjs/sessions/db/operations.js +1 -1
- package/dist/cjs/sessions/in_memory_session_service.js +3 -1
- package/dist/cjs/sessions/stale_session_error.js +59 -0
- package/dist/cjs/sessions/state.js +8 -4
- package/dist/cjs/sessions/vertex_ai_session_service.js +34 -15
- package/dist/cjs/skills/loader.js +52 -18
- package/dist/cjs/telemetry/setup.js +0 -1
- package/dist/cjs/telemetry/tracing.js +147 -73
- package/dist/cjs/tools/agent_tool.js +44 -0
- package/dist/cjs/tools/apihub_tool/apihub_toolset.js +137 -0
- package/dist/cjs/tools/apihub_tool/clients/apihub_client.js +272 -0
- package/dist/cjs/tools/apihub_tool/clients/secret_client.js +148 -0
- package/dist/cjs/tools/apihub_tool/clients/service_account.js +48 -0
- package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +263 -0
- package/dist/cjs/tools/application_integration_tool/clients/cloud_request.js +133 -0
- package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +671 -0
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +223 -0
- package/dist/cjs/tools/application_integration_tool/integration_connector_tool.js +184 -0
- package/dist/cjs/tools/example_tool.js +10 -0
- package/dist/cjs/tools/function_tool.js +319 -0
- package/dist/cjs/tools/google_api_tool/google_api_tool.js +100 -0
- package/dist/cjs/tools/google_api_tool/google_api_toolset.js +173 -0
- package/dist/cjs/tools/google_api_tool/google_api_toolsets.js +124 -0
- package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +440 -0
- package/dist/cjs/tools/google_api_tool/index.js +61 -0
- package/dist/cjs/tools/load_artifacts_tool.js +12 -6
- package/dist/cjs/tools/load_memory_tool.js +12 -10
- package/dist/cjs/tools/mcp/index.js +12 -0
- package/dist/cjs/tools/mcp/mcp_session_manager.js +25 -0
- package/dist/cjs/tools/mcp/mcp_toolset.js +1 -14
- package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +1 -2
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +46 -2
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +4 -3
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +14 -2
- package/dist/cjs/tools/openapi_tool/openapi_toolset.js +7 -13
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +17 -1
- package/dist/cjs/tools/retrieval/base_retrieval_tool.js +18 -3
- package/dist/cjs/tools/toolbox_toolset.js +174 -0
- package/dist/cjs/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/cjs/utils/client_labels.js +19 -2
- package/dist/cjs/utils/env_aware_utils.js +6 -8
- package/dist/cjs/utils/error_utils.js +11 -11
- package/dist/cjs/utils/failover_utils.js +1 -1
- package/dist/cjs/utils/file_extension_utils.js +11 -0
- package/dist/cjs/utils/file_utils.js +2 -24
- package/dist/cjs/utils/gemini_schema_util.js +28 -7
- package/dist/cjs/utils/json_utils.js +49 -0
- package/dist/cjs/utils/live_connection_utils.js +4 -5
- package/dist/cjs/utils/logger_node.js +11 -1
- package/dist/cjs/utils/object_notation_utils.js +6 -3
- package/dist/cjs/utils/output_schema_utils.js +5 -2
- package/dist/cjs/utils/streaming_utils.js +12 -12
- package/dist/cjs/utils/task.js +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/a2a/a2a_remote_agent.js +4 -1
- package/dist/esm/a2a/agent_card.js +103 -27
- package/dist/esm/a2a/agent_to_a2a.js +5 -2
- package/dist/esm/agents/agent_engine_client.js +144 -0
- package/dist/esm/agents/base_agent.js +20 -4
- package/dist/esm/agents/functions.js +226 -25
- package/dist/esm/agents/instructions.js +6 -2
- package/dist/esm/agents/invocation_context.js +24 -4
- package/dist/esm/agents/langgraph_agent.js +123 -0
- package/dist/esm/agents/llm_agent.js +204 -110
- package/dist/esm/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/code_execution_request_processor.js +21 -8
- package/dist/esm/agents/processors/content_processor_utils.js +38 -10
- package/dist/esm/agents/processors/content_request_processor.js +34 -2
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/nl_planning_processor.js +12 -3
- package/dist/esm/artifacts/in_memory_artifact_service.js +14 -0
- package/dist/esm/auth/auth_handler.js +37 -5
- package/dist/esm/auth/auth_schemes.js +8 -0
- package/dist/esm/cli/cli_eval.js +510 -0
- package/dist/esm/cli/utils/envs.js +78 -0
- package/dist/esm/cli/utils/evals.js +109 -0
- package/dist/esm/cli/utils/logs.js +111 -0
- package/dist/esm/code_executors/agent_engine_sandbox_code_executor.js +7 -2
- package/dist/esm/code_executors/code_execution_utils.js +46 -16
- package/dist/esm/code_executors/code_executor_context.js +5 -2
- package/dist/esm/code_executors/container_code_executor.js +27 -16
- package/dist/esm/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/esm/common.js +65 -4
- package/dist/esm/context/summarizers/llm_summarizer.js +12 -10
- package/dist/esm/context/token_based_context_compactor.js +2 -1
- package/dist/esm/errors/input_validation_error.js +3 -2
- package/dist/esm/events/event.js +4 -2
- package/dist/esm/examples/example_util.js +21 -1
- package/dist/esm/flows/llm_flows/audio_transcriber.js +142 -0
- package/dist/esm/index.js +114 -2
- package/dist/esm/integrations/agent_registry/helpers.js +1 -1
- package/dist/esm/models/gemini_llm_connection.js +16 -8
- package/dist/esm/models/google_llm.js +14 -17
- package/dist/esm/models/llm_response.js +9 -1
- package/dist/esm/models/registry.js +1 -1
- package/dist/esm/models/routed_llm.js +9 -8
- package/dist/esm/planners/plan_re_act_planner.js +1 -1
- package/dist/esm/plugins/base_plugin.js +13 -23
- package/dist/esm/runner/in_memory_runner.js +6 -11
- package/dist/esm/runner/runner.js +105 -33
- package/dist/esm/sessions/base_session_service.js +12 -7
- package/dist/esm/sessions/database_session_service.js +49 -28
- package/dist/esm/sessions/db/operations.js +1 -1
- package/dist/esm/sessions/in_memory_session_service.js +3 -1
- package/dist/esm/sessions/stale_session_error.js +31 -0
- package/dist/esm/sessions/state.js +8 -4
- package/dist/esm/sessions/vertex_ai_session_service.js +34 -15
- package/dist/esm/skills/loader.js +51 -17
- package/dist/esm/telemetry/setup.js +1 -2
- package/dist/esm/telemetry/tracing.js +151 -74
- package/dist/esm/tools/agent_tool.js +44 -0
- package/dist/esm/tools/apihub_tool/apihub_toolset.js +101 -0
- package/dist/esm/tools/apihub_tool/clients/apihub_client.js +244 -0
- package/dist/esm/tools/apihub_tool/clients/secret_client.js +132 -0
- package/dist/esm/tools/apihub_tool/clients/service_account.js +21 -0
- package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +245 -0
- package/dist/esm/tools/application_integration_tool/clients/cloud_request.js +103 -0
- package/dist/esm/tools/application_integration_tool/clients/connections_client.js +629 -0
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +219 -0
- package/dist/esm/tools/application_integration_tool/integration_connector_tool.js +158 -0
- package/dist/esm/tools/example_tool.js +13 -1
- package/dist/esm/tools/function_tool.js +316 -0
- package/dist/esm/tools/google_api_tool/google_api_tool.js +73 -0
- package/dist/esm/tools/google_api_tool/google_api_toolset.js +146 -0
- package/dist/esm/tools/google_api_tool/google_api_toolsets.js +94 -0
- package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +393 -0
- package/dist/esm/tools/google_api_tool/index.js +31 -0
- package/dist/esm/tools/load_artifacts_tool.js +10 -5
- package/dist/esm/tools/load_memory_tool.js +12 -10
- package/dist/esm/tools/mcp/index.js +6 -0
- package/dist/esm/tools/mcp/mcp_session_manager.js +25 -0
- package/dist/esm/tools/mcp/mcp_toolset.js +1 -14
- package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +1 -2
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +50 -3
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +4 -3
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +15 -2
- package/dist/esm/tools/openapi_tool/openapi_toolset.js +6 -12
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +17 -1
- package/dist/esm/tools/retrieval/base_retrieval_tool.js +16 -2
- package/dist/esm/tools/toolbox_toolset.js +148 -0
- package/dist/esm/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/esm/utils/client_labels.js +19 -2
- package/dist/esm/utils/env_aware_utils.js +6 -8
- package/dist/esm/utils/error_utils.js +9 -10
- package/dist/esm/utils/failover_utils.js +1 -1
- package/dist/esm/utils/file_extension_utils.js +11 -0
- package/dist/esm/utils/file_utils.js +2 -23
- package/dist/esm/utils/gemini_schema_util.js +27 -7
- package/dist/esm/utils/json_utils.js +21 -0
- package/dist/esm/utils/live_connection_utils.js +4 -5
- package/dist/esm/utils/logger_node.js +11 -1
- package/dist/esm/utils/object_notation_utils.js +4 -2
- package/dist/esm/utils/output_schema_utils.js +5 -2
- package/dist/esm/utils/streaming_utils.js +11 -11
- package/dist/esm/utils/task.js +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/a2a_remote_agent.d.ts +9 -0
- package/dist/types/a2a/agent_card.d.ts +44 -1
- package/dist/types/a2a/agent_to_a2a.d.ts +9 -0
- package/dist/types/a2a/index.d.ts +1 -0
- package/dist/types/agents/agent_engine_client.d.ts +37 -0
- package/dist/types/agents/base_agent.d.ts +12 -0
- package/dist/types/agents/functions.d.ts +33 -1
- package/dist/types/agents/invocation_context.d.ts +20 -1
- package/dist/types/agents/langgraph_agent.d.ts +153 -0
- package/dist/types/agents/llm_agent.d.ts +5 -1
- package/dist/types/agents/processors/content_processor_utils.d.ts +4 -2
- package/dist/types/agents/processors/nl_planning_processor.d.ts +2 -1
- package/dist/types/auth/auth_handler.d.ts +28 -1
- package/dist/types/auth/auth_schemes.d.ts +13 -0
- package/dist/types/cli/cli_eval.d.ts +173 -0
- package/dist/types/cli/utils/envs.d.ts +23 -0
- package/dist/types/cli/utils/evals.d.ts +47 -0
- package/dist/types/cli/utils/logs.d.ts +38 -0
- package/dist/types/code_executors/code_execution_utils.d.ts +39 -0
- package/dist/types/code_executors/code_executor_context.d.ts +1 -0
- package/dist/types/code_executors/container_code_executor.d.ts +17 -5
- package/dist/types/common.d.ts +24 -5
- package/dist/types/errors/input_validation_error.d.ts +2 -1
- package/dist/types/events/event.d.ts +4 -0
- package/dist/types/examples/example_util.d.ts +17 -0
- package/dist/types/flows/llm_flows/audio_transcriber.d.ts +85 -0
- package/dist/types/index.d.ts +19 -2
- package/dist/types/models/gemini_llm_connection.d.ts +6 -7
- package/dist/types/models/routed_llm.d.ts +1 -1
- package/dist/types/plugins/base_plugin.d.ts +0 -10
- package/dist/types/runner/in_memory_runner.d.ts +2 -1
- package/dist/types/runner/runner.d.ts +34 -0
- package/dist/types/sessions/base_session_service.d.ts +5 -0
- package/dist/types/sessions/database_session_service.d.ts +17 -1
- package/dist/types/sessions/stale_session_error.d.ts +21 -0
- package/dist/types/sessions/state.d.ts +5 -1
- package/dist/types/sessions/vertex_ai_session_service.d.ts +8 -0
- package/dist/types/skills/loader.d.ts +3 -2
- package/dist/types/skills/skill.d.ts +1 -1
- package/dist/types/telemetry/tracing.d.ts +20 -4
- package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +115 -0
- package/dist/types/tools/apihub_tool/clients/apihub_client.d.ts +142 -0
- package/dist/types/tools/apihub_tool/clients/secret_client.d.ts +55 -0
- package/dist/types/tools/apihub_tool/clients/service_account.d.ts +11 -0
- package/dist/types/tools/application_integration_tool/application_integration_toolset.d.ts +109 -0
- package/dist/types/tools/application_integration_tool/clients/cloud_request.d.ts +53 -0
- package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +229 -0
- package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +72 -0
- package/dist/types/tools/application_integration_tool/integration_connector_tool.d.ts +70 -0
- package/dist/types/tools/base_toolset.d.ts +6 -5
- package/dist/types/tools/example_tool.d.ts +10 -0
- package/dist/types/tools/function_tool.d.ts +32 -0
- package/dist/types/tools/google_api_tool/google_api_tool.d.ts +37 -0
- package/dist/types/tools/google_api_tool/google_api_toolset.d.ts +55 -0
- package/dist/types/tools/google_api_tool/google_api_toolsets.d.ts +48 -0
- package/dist/types/tools/google_api_tool/googleapi_to_openapi_converter.d.ts +165 -0
- package/dist/types/tools/google_api_tool/index.d.ts +10 -0
- package/dist/types/tools/load_artifacts_tool.d.ts +14 -1
- package/dist/types/tools/load_memory_tool.d.ts +23 -1
- package/dist/types/tools/mcp/index.d.ts +3 -0
- package/dist/types/tools/mcp/mcp_session_manager.d.ts +34 -1
- package/dist/types/tools/mcp/mcp_toolset.d.ts +15 -0
- package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +19 -0
- package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +18 -1
- package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +12 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +8 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +2 -1
- package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +5 -0
- package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +10 -0
- package/dist/types/tools/retrieval/base_retrieval_tool.d.ts +15 -0
- package/dist/types/tools/toolbox_toolset.d.ts +159 -0
- package/dist/types/utils/client_labels.d.ts +2 -1
- package/dist/types/utils/env_aware_utils.d.ts +18 -2
- package/dist/types/utils/error_utils.d.ts +7 -0
- package/dist/types/utils/file_utils.d.ts +6 -1
- package/dist/types/utils/gemini_schema_util.d.ts +9 -2
- package/dist/types/utils/json_utils.d.ts +11 -0
- package/dist/types/utils/object_notation_utils.d.ts +7 -0
- package/dist/types/utils/output_schema_utils.d.ts +3 -2
- package/dist/types/utils/simple_zod_to_json.d.ts +1 -2
- package/dist/types/utils/streaming_utils.d.ts +11 -4
- package/dist/types/version.d.ts +1 -1
- package/dist/web/index_web.js +117 -110
- package/dist/web/index_web.js.map +4 -4
- package/package.json +38 -26
- package/dist/cjs/models/gemini_continuation.js +0 -232
- package/dist/esm/models/gemini_continuation.js +0 -205
- package/dist/types/models/gemini_continuation.d.ts +0 -59
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
27
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
28
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
29
|
+
if (decorator = decorators[i])
|
|
30
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
31
|
+
if (kind && result) __defProp(target, key, result);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
var application_integration_toolset_exports = {};
|
|
35
|
+
__export(application_integration_toolset_exports, {
|
|
36
|
+
ApplicationIntegrationToolset: () => ApplicationIntegrationToolset,
|
|
37
|
+
IntegrationConnectorTool: () => import_integration_connector_tool.IntegrationConnectorTool
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(application_integration_toolset_exports);
|
|
40
|
+
var import_auth_credential = require("../../auth/auth_credential.js");
|
|
41
|
+
var import_experimental = require("../../utils/experimental.js");
|
|
42
|
+
var import_json_utils = require("../../utils/json_utils.js");
|
|
43
|
+
var import_logger = require("../../utils/logger.js");
|
|
44
|
+
var import_base_toolset = require("../base_toolset.js");
|
|
45
|
+
var import_auth_helpers = require("../openapi_tool/auth/auth_helpers.js");
|
|
46
|
+
var import_openapi_spec_parser = require("../openapi_tool/openapi_spec_parser/openapi_spec_parser.js");
|
|
47
|
+
var import_openapi_toolset = require("../openapi_tool/openapi_toolset.js");
|
|
48
|
+
var import_rest_api_tool = require("../openapi_tool/rest_api_tool.js");
|
|
49
|
+
var import_cloud_request = require("./clients/cloud_request.js");
|
|
50
|
+
var import_connections_client = require("./clients/connections_client.js");
|
|
51
|
+
var import_integration_client = require("./clients/integration_client.js");
|
|
52
|
+
var import_integration_connector_tool = require("./integration_connector_tool.js");
|
|
53
|
+
/**
|
|
54
|
+
* @license
|
|
55
|
+
* Copyright 2026 Google LLC
|
|
56
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
57
|
+
*/
|
|
58
|
+
const AUTH_SCHEME = {
|
|
59
|
+
type: "http",
|
|
60
|
+
scheme: "bearer",
|
|
61
|
+
bearerFormat: "JWT"
|
|
62
|
+
};
|
|
63
|
+
let ApplicationIntegrationToolset = class extends import_base_toolset.BaseToolset {
|
|
64
|
+
/**
|
|
65
|
+
* @throws Error Unless the options name either an integration, or a
|
|
66
|
+
* connection with at least one entity operation or action.
|
|
67
|
+
*/
|
|
68
|
+
constructor(options) {
|
|
69
|
+
var _a, _b, _c;
|
|
70
|
+
super((_a = options.toolFilter) != null ? _a : []);
|
|
71
|
+
this.openApiToolsets = [];
|
|
72
|
+
const hasIntegration = Boolean(options.integration);
|
|
73
|
+
const hasConnection = Boolean(
|
|
74
|
+
options.connection && (Object.keys((_b = options.entityOperations) != null ? _b : {}).length > 0 || ((_c = options.actions) != null ? _c : []).length > 0)
|
|
75
|
+
);
|
|
76
|
+
if (!hasIntegration && !hasConnection) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
"Either integration or (connection and (entityOperations or actions)) should be provided."
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
this.options = options;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Returns the generated tools.
|
|
85
|
+
*
|
|
86
|
+
* The first call fetches the spec and builds the tools. Concurrent calls
|
|
87
|
+
* share that load. When it fails, the next call tries again.
|
|
88
|
+
*/
|
|
89
|
+
async getTools(context) {
|
|
90
|
+
if (!this.toolsPromise) {
|
|
91
|
+
this.toolsPromise = this.loadTools();
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const tools = await this.toolsPromise;
|
|
95
|
+
return tools.filter((tool) => this.isToolSelected(tool, context));
|
|
96
|
+
} catch (e) {
|
|
97
|
+
this.toolsPromise = void 0;
|
|
98
|
+
throw e;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async close() {
|
|
102
|
+
for (const openApiToolset of this.openApiToolsets) {
|
|
103
|
+
await openApiToolset.close();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async loadTools() {
|
|
107
|
+
var _a, _b;
|
|
108
|
+
const {
|
|
109
|
+
project,
|
|
110
|
+
location,
|
|
111
|
+
integration,
|
|
112
|
+
triggers,
|
|
113
|
+
connection,
|
|
114
|
+
entityOperations,
|
|
115
|
+
actions,
|
|
116
|
+
toolNamePrefix,
|
|
117
|
+
toolInstructions = "",
|
|
118
|
+
serviceAccountJson,
|
|
119
|
+
authScheme,
|
|
120
|
+
authCredential: dynamicAuthCredential
|
|
121
|
+
} = this.options;
|
|
122
|
+
const resolvedToolName = toolNamePrefix != null ? toolNamePrefix : "";
|
|
123
|
+
this.openApiToolsets = [];
|
|
124
|
+
const integrationClient = new import_integration_client.IntegrationClient({
|
|
125
|
+
project,
|
|
126
|
+
location,
|
|
127
|
+
integration,
|
|
128
|
+
triggers,
|
|
129
|
+
connection,
|
|
130
|
+
entityOperations,
|
|
131
|
+
actions,
|
|
132
|
+
serviceAccountJson
|
|
133
|
+
});
|
|
134
|
+
const authCredential = buildAuthCredential(serviceAccountJson);
|
|
135
|
+
const toolsByName = /* @__PURE__ */ new Map();
|
|
136
|
+
if (integration) {
|
|
137
|
+
const specDict2 = await integrationClient.getOpenApiSpecForIntegration();
|
|
138
|
+
const spec2 = toOpenApiDocument(specDict2);
|
|
139
|
+
for (const [path, pathItem] of Object.entries((_a = spec2.paths) != null ? _a : {})) {
|
|
140
|
+
const openApiToolset = new import_openapi_toolset.OpenAPIToolset({
|
|
141
|
+
specDict: { ...spec2, paths: { [removeFragment(path)]: pathItem } },
|
|
142
|
+
authCredential,
|
|
143
|
+
authScheme: AUTH_SCHEME
|
|
144
|
+
});
|
|
145
|
+
this.openApiToolsets.push(openApiToolset);
|
|
146
|
+
const tools = await openApiToolset.getTools();
|
|
147
|
+
for (const tool of tools) {
|
|
148
|
+
toolsByName.set(tool.name, tool);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return [...toolsByName.values()];
|
|
152
|
+
}
|
|
153
|
+
const connectionName = connection != null ? connection : "";
|
|
154
|
+
const connectionDetails = await new import_connections_client.ConnectionsClient({
|
|
155
|
+
project,
|
|
156
|
+
location,
|
|
157
|
+
connection: connectionName,
|
|
158
|
+
serviceAccountJson
|
|
159
|
+
}).getConnectionDetails();
|
|
160
|
+
if (authScheme && dynamicAuthCredential && !connectionDetails.authOverrideEnabled) {
|
|
161
|
+
import_logger.logger.warn(
|
|
162
|
+
"Authentication schema and credentials are not used because authOverrideEnabled is not enabled in the connection."
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
const specDict = await integrationClient.getOpenApiSpecForConnection(
|
|
166
|
+
resolvedToolName,
|
|
167
|
+
toolInstructions
|
|
168
|
+
);
|
|
169
|
+
const spec = toOpenApiDocument(specDict);
|
|
170
|
+
addDynamicAuthConfigToConnectionSchemas(spec);
|
|
171
|
+
const operations = new import_openapi_spec_parser.OpenApiSpecParser().parse(spec);
|
|
172
|
+
for (const openApiOperation of operations) {
|
|
173
|
+
const operationObject = (0, import_json_utils.toJsonObject)(openApiOperation.operation);
|
|
174
|
+
const operation = toStringValue(operationObject["x-operation"]);
|
|
175
|
+
const entity = toStringValue(operationObject["x-entity"]);
|
|
176
|
+
const action = toStringValue(operationObject["x-action"]);
|
|
177
|
+
const restApiTool = (0, import_rest_api_tool.createRestApiTool)({
|
|
178
|
+
...openApiOperation,
|
|
179
|
+
endpoint: {
|
|
180
|
+
...openApiOperation.endpoint,
|
|
181
|
+
path: removeFragment(openApiOperation.endpoint.path)
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
restApiTool.configureAuthScheme(AUTH_SCHEME);
|
|
185
|
+
restApiTool.configureAuthCredential(authCredential);
|
|
186
|
+
const tool = new import_integration_connector_tool.IntegrationConnectorTool({
|
|
187
|
+
name: restApiTool.name,
|
|
188
|
+
description: restApiTool.description,
|
|
189
|
+
connectionName: (_b = connectionDetails.name) != null ? _b : "",
|
|
190
|
+
connectionHost: connectionDetails.host,
|
|
191
|
+
connectionServiceName: connectionDetails.serviceName,
|
|
192
|
+
entity,
|
|
193
|
+
action,
|
|
194
|
+
operation,
|
|
195
|
+
restApiTool,
|
|
196
|
+
authScheme: connectionDetails.authOverrideEnabled ? authScheme : void 0,
|
|
197
|
+
authCredential: connectionDetails.authOverrideEnabled ? dynamicAuthCredential : void 0
|
|
198
|
+
});
|
|
199
|
+
toolsByName.set(tool.name, tool);
|
|
200
|
+
}
|
|
201
|
+
return [...toolsByName.values()];
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
__name(ApplicationIntegrationToolset, "ApplicationIntegrationToolset");
|
|
205
|
+
ApplicationIntegrationToolset = __decorateClass([
|
|
206
|
+
import_experimental.experimental
|
|
207
|
+
], ApplicationIntegrationToolset);
|
|
208
|
+
function addDynamicAuthConfigToConnectionSchemas(spec) {
|
|
209
|
+
var _a;
|
|
210
|
+
const schemas = (_a = spec.components) == null ? void 0 : _a.schemas;
|
|
211
|
+
if (!schemas) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
for (const [schemaName, schema] of Object.entries(schemas)) {
|
|
215
|
+
if (schemaName.endsWith("_Request") && (0, import_json_utils.isJsonObject)(schema) && (0, import_json_utils.isJsonObject)(schema.properties) && !("query" in schema.properties) && !("dynamicAuthConfig" in schema.properties)) {
|
|
216
|
+
schema.properties = {
|
|
217
|
+
...schema.properties,
|
|
218
|
+
dynamicAuthConfig: {
|
|
219
|
+
$ref: "#/components/schemas/dynamicAuthConfig"
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
__name(addDynamicAuthConfigToConnectionSchemas, "addDynamicAuthConfigToConnectionSchemas");
|
|
226
|
+
function toOpenApiDocument(specDict) {
|
|
227
|
+
return specDict;
|
|
228
|
+
}
|
|
229
|
+
__name(toOpenApiDocument, "toOpenApiDocument");
|
|
230
|
+
function toStringValue(value) {
|
|
231
|
+
return typeof value === "string" ? value : "";
|
|
232
|
+
}
|
|
233
|
+
__name(toStringValue, "toStringValue");
|
|
234
|
+
function buildAuthCredential(serviceAccountJson) {
|
|
235
|
+
if (!serviceAccountJson) {
|
|
236
|
+
return {
|
|
237
|
+
authType: import_auth_credential.AuthCredentialTypes.SERVICE_ACCOUNT,
|
|
238
|
+
serviceAccount: {
|
|
239
|
+
useDefaultCredential: true,
|
|
240
|
+
scopes: [import_cloud_request.CLOUD_PLATFORM_SCOPE]
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
const key = JSON.parse(serviceAccountJson);
|
|
245
|
+
if (!(0, import_json_utils.isJsonObject)(key)) {
|
|
246
|
+
throw new Error("serviceAccountJson must hold a JSON object.");
|
|
247
|
+
}
|
|
248
|
+
const [, authCredential] = (0, import_auth_helpers.serviceAccountDictToSchemeCredential)(key, [
|
|
249
|
+
import_cloud_request.CLOUD_PLATFORM_SCOPE
|
|
250
|
+
]);
|
|
251
|
+
return authCredential;
|
|
252
|
+
}
|
|
253
|
+
__name(buildAuthCredential, "buildAuthCredential");
|
|
254
|
+
function removeFragment(path) {
|
|
255
|
+
const fragmentStart = path.indexOf("#");
|
|
256
|
+
return fragmentStart === -1 ? path : path.slice(0, fragmentStart);
|
|
257
|
+
}
|
|
258
|
+
__name(removeFragment, "removeFragment");
|
|
259
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
260
|
+
0 && (module.exports = {
|
|
261
|
+
ApplicationIntegrationToolset,
|
|
262
|
+
IntegrationConnectorTool
|
|
263
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
+
var cloud_request_exports = {};
|
|
27
|
+
__export(cloud_request_exports, {
|
|
28
|
+
CLOUD_PLATFORM_SCOPE: () => CLOUD_PLATFORM_SCOPE,
|
|
29
|
+
CloudPlatformTokenSource: () => CloudPlatformTokenSource,
|
|
30
|
+
sendCloudRequest: () => sendCloudRequest,
|
|
31
|
+
unexpectedError: () => unexpectedError
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(cloud_request_exports);
|
|
34
|
+
var import_google_auth_library = require("google-auth-library");
|
|
35
|
+
var import_error_utils = require("../../../utils/error_utils.js");
|
|
36
|
+
/**
|
|
37
|
+
* @license
|
|
38
|
+
* Copyright 2026 Google LLC
|
|
39
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
40
|
+
*/
|
|
41
|
+
const CLOUD_PLATFORM_SCOPE = "https://www.googleapis.com/auth/cloud-platform";
|
|
42
|
+
const MISSING_CREDENTIALS_MESSAGE = "Please provide a service account that has the required permissions to access the connection.";
|
|
43
|
+
function unexpectedError(e) {
|
|
44
|
+
return new Error(`An unexpected error occurred: ${(0, import_error_utils.getErrorMessage)(e)}`, {
|
|
45
|
+
cause: e
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
__name(unexpectedError, "unexpectedError");
|
|
49
|
+
const _CloudPlatformTokenSource = class _CloudPlatformTokenSource {
|
|
50
|
+
constructor(serviceAccountJson) {
|
|
51
|
+
this.serviceAccountJson = serviceAccountJson;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Returns an access token.
|
|
55
|
+
*
|
|
56
|
+
* @throws Error When no key is given and Application Default Credentials are
|
|
57
|
+
* unavailable, or when no token is issued.
|
|
58
|
+
*/
|
|
59
|
+
async getAccessToken() {
|
|
60
|
+
let token;
|
|
61
|
+
try {
|
|
62
|
+
token = await this.getAuth().getAccessToken();
|
|
63
|
+
} catch (e) {
|
|
64
|
+
if (this.serviceAccountJson) {
|
|
65
|
+
throw e;
|
|
66
|
+
}
|
|
67
|
+
throw new Error(MISSING_CREDENTIALS_MESSAGE, { cause: e });
|
|
68
|
+
}
|
|
69
|
+
if (!token) {
|
|
70
|
+
throw new Error(MISSING_CREDENTIALS_MESSAGE);
|
|
71
|
+
}
|
|
72
|
+
return token;
|
|
73
|
+
}
|
|
74
|
+
getAuth() {
|
|
75
|
+
if (!this.auth) {
|
|
76
|
+
if (this.serviceAccountJson) {
|
|
77
|
+
const credentials = JSON.parse(this.serviceAccountJson);
|
|
78
|
+
this.auth = new import_google_auth_library.GoogleAuth({
|
|
79
|
+
scopes: [CLOUD_PLATFORM_SCOPE],
|
|
80
|
+
credentials
|
|
81
|
+
});
|
|
82
|
+
} else {
|
|
83
|
+
this.auth = new import_google_auth_library.GoogleAuth({ scopes: [CLOUD_PLATFORM_SCOPE] });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return this.auth;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
__name(_CloudPlatformTokenSource, "CloudPlatformTokenSource");
|
|
90
|
+
let CloudPlatformTokenSource = _CloudPlatformTokenSource;
|
|
91
|
+
async function sendCloudRequest(options) {
|
|
92
|
+
const { url, method, body, tokenSource, invalidRequestMessage } = options;
|
|
93
|
+
let token;
|
|
94
|
+
try {
|
|
95
|
+
token = await tokenSource.getAccessToken();
|
|
96
|
+
} catch (e) {
|
|
97
|
+
throw unexpectedError(e);
|
|
98
|
+
}
|
|
99
|
+
let response;
|
|
100
|
+
try {
|
|
101
|
+
response = await fetch(url, {
|
|
102
|
+
method,
|
|
103
|
+
headers: {
|
|
104
|
+
"Content-Type": "application/json",
|
|
105
|
+
"Authorization": `Bearer ${token}`
|
|
106
|
+
},
|
|
107
|
+
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
108
|
+
});
|
|
109
|
+
} catch (e) {
|
|
110
|
+
throw new Error(`Request error: ${(0, import_error_utils.getErrorMessage)(e)}`, { cause: e });
|
|
111
|
+
}
|
|
112
|
+
if (response.status === 400 || response.status === 404) {
|
|
113
|
+
throw new Error(invalidRequestMessage);
|
|
114
|
+
}
|
|
115
|
+
if (!response.ok) {
|
|
116
|
+
throw new Error(
|
|
117
|
+
`Request error: HTTP ${response.status} ${response.statusText} for url: ${url}`
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
return await response.json();
|
|
122
|
+
} catch (e) {
|
|
123
|
+
throw unexpectedError(e);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
__name(sendCloudRequest, "sendCloudRequest");
|
|
127
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
128
|
+
0 && (module.exports = {
|
|
129
|
+
CLOUD_PLATFORM_SCOPE,
|
|
130
|
+
CloudPlatformTokenSource,
|
|
131
|
+
sendCloudRequest,
|
|
132
|
+
unexpectedError
|
|
133
|
+
});
|