@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,219 @@
|
|
|
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.triggers = options.triggers;
|
|
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
|
+
var _a;
|
|
69
|
+
const url = `https://${this.location}-integrations.googleapis.com/v1/projects/${this.project}/locations/${this.location}:generateOpenApiSpec`;
|
|
70
|
+
const triggerId = (_a = this.triggers) != null ? _a : null;
|
|
71
|
+
const invalidRequestMessage = `Invalid request. Please check the provided values of project(${this.project}), location(${this.location}), integration(${this.integration}).`;
|
|
72
|
+
const body = await sendCloudRequest({
|
|
73
|
+
url,
|
|
74
|
+
method: "POST",
|
|
75
|
+
body: {
|
|
76
|
+
apiTriggerResources: [
|
|
77
|
+
{
|
|
78
|
+
integrationResource: this.integration,
|
|
79
|
+
triggerId
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
fileFormat: "JSON"
|
|
83
|
+
},
|
|
84
|
+
tokenSource: this.tokenSource,
|
|
85
|
+
invalidRequestMessage
|
|
86
|
+
});
|
|
87
|
+
try {
|
|
88
|
+
const spec = isJsonObject(body) ? body["openApiSpec"] : void 0;
|
|
89
|
+
if (typeof spec !== "string") {
|
|
90
|
+
throw new Error("The response carries no openApiSpec string.");
|
|
91
|
+
}
|
|
92
|
+
const parsed = JSON.parse(spec);
|
|
93
|
+
if (!isJsonObject(parsed)) {
|
|
94
|
+
throw new Error("The openApiSpec is not a JSON object.");
|
|
95
|
+
}
|
|
96
|
+
return parsed;
|
|
97
|
+
} catch (e) {
|
|
98
|
+
throw unexpectedError(e);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Builds an OpenAPI spec for the entity operations and actions of the
|
|
103
|
+
* connection.
|
|
104
|
+
*
|
|
105
|
+
* Every operation becomes a POST to the `ExecuteConnection` integration,
|
|
106
|
+
* with a path fragment that keeps the paths distinct.
|
|
107
|
+
*
|
|
108
|
+
* @param toolName Prefix of every generated `operationId`.
|
|
109
|
+
* @param toolInstructions Text appended to every operation description.
|
|
110
|
+
* @throws Error When neither entity operations nor actions are configured,
|
|
111
|
+
* or an operation is not one of create, update, delete, list or get.
|
|
112
|
+
*/
|
|
113
|
+
async getOpenApiSpecForConnection(toolName = "", toolInstructions = "") {
|
|
114
|
+
var _a;
|
|
115
|
+
if (Object.keys(this.entityOperations).length === 0 && this.actions.length === 0) {
|
|
116
|
+
throw new Error(
|
|
117
|
+
"No entity operations or actions provided. Please provide at least one of them."
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
const connectionsClient = new ConnectionsClient({
|
|
121
|
+
project: this.project,
|
|
122
|
+
location: this.location,
|
|
123
|
+
connection: (_a = this.connection) != null ? _a : "",
|
|
124
|
+
serviceAccountJson: this.serviceAccountJson
|
|
125
|
+
});
|
|
126
|
+
const connectorSpec = structuredClone(CONNECTOR_BASE_SPEC);
|
|
127
|
+
const schemas = connectorSpec.components.schemas;
|
|
128
|
+
const pathPrefix = `/v2/projects/${this.project}/locations/${this.location}/integrations/${EXECUTE_CONNECTION_INTEGRATION}:execute?triggerId=api_trigger/${EXECUTE_CONNECTION_INTEGRATION}`;
|
|
129
|
+
for (const [entity, requestedOperations] of Object.entries(
|
|
130
|
+
this.entityOperations
|
|
131
|
+
)) {
|
|
132
|
+
const { schema, operations: supportedOperations } = await connectionsClient.getEntitySchemaAndOperations(entity);
|
|
133
|
+
const operations = requestedOperations.length > 0 ? requestedOperations : supportedOperations;
|
|
134
|
+
const schemaAsString = JSON.stringify(schema);
|
|
135
|
+
schemas[`connectorInputPayload_${entity}`] = connectorPayload(schema);
|
|
136
|
+
for (const operation of operations) {
|
|
137
|
+
const operationLower = operation.toLowerCase();
|
|
138
|
+
const path = `${pathPrefix}#${operationLower}_${entity}`;
|
|
139
|
+
switch (operationLower) {
|
|
140
|
+
case "create":
|
|
141
|
+
connectorSpec.paths[path] = createOperation({
|
|
142
|
+
entity,
|
|
143
|
+
toolName,
|
|
144
|
+
toolInstructions
|
|
145
|
+
});
|
|
146
|
+
schemas[`create_${entity}_Request`] = createOperationRequest(entity);
|
|
147
|
+
break;
|
|
148
|
+
case "update":
|
|
149
|
+
connectorSpec.paths[path] = updateOperation({
|
|
150
|
+
entity,
|
|
151
|
+
toolName,
|
|
152
|
+
toolInstructions
|
|
153
|
+
});
|
|
154
|
+
schemas[`update_${entity}_Request`] = updateOperationRequest(entity);
|
|
155
|
+
break;
|
|
156
|
+
case "delete":
|
|
157
|
+
connectorSpec.paths[path] = deleteOperation({
|
|
158
|
+
entity,
|
|
159
|
+
toolName,
|
|
160
|
+
toolInstructions
|
|
161
|
+
});
|
|
162
|
+
schemas[`delete_${entity}_Request`] = deleteOperationRequest();
|
|
163
|
+
break;
|
|
164
|
+
case "list":
|
|
165
|
+
connectorSpec.paths[path] = listOperation({
|
|
166
|
+
entity,
|
|
167
|
+
schemaAsString,
|
|
168
|
+
toolName,
|
|
169
|
+
toolInstructions
|
|
170
|
+
});
|
|
171
|
+
schemas[`list_${entity}_Request`] = listOperationRequest();
|
|
172
|
+
break;
|
|
173
|
+
case "get":
|
|
174
|
+
connectorSpec.paths[path] = getOperation({
|
|
175
|
+
entity,
|
|
176
|
+
schemaAsString,
|
|
177
|
+
toolName,
|
|
178
|
+
toolInstructions
|
|
179
|
+
});
|
|
180
|
+
schemas[`get_${entity}_Request`] = getOperationRequest();
|
|
181
|
+
break;
|
|
182
|
+
default:
|
|
183
|
+
throw new Error(
|
|
184
|
+
`Invalid operation: ${operation} for entity: ${entity}`
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
for (const action of this.actions) {
|
|
190
|
+
const { inputSchema, outputSchema, displayName } = await connectionsClient.getActionSchema(action);
|
|
191
|
+
const actionDisplayName = displayName.replace(/ /g, "");
|
|
192
|
+
let operation = "EXECUTE_ACTION";
|
|
193
|
+
if (action === EXECUTE_CUSTOM_QUERY_ACTION) {
|
|
194
|
+
schemas[`${actionDisplayName}_Request`] = executeCustomQueryRequest();
|
|
195
|
+
operation = "EXECUTE_QUERY";
|
|
196
|
+
} else {
|
|
197
|
+
schemas[`${actionDisplayName}_Request`] = actionRequest(actionDisplayName);
|
|
198
|
+
schemas[`connectorInputPayload_${actionDisplayName}`] = connectorPayload(inputSchema);
|
|
199
|
+
}
|
|
200
|
+
schemas[`connectorOutputPayload_${actionDisplayName}`] = connectorPayload(outputSchema);
|
|
201
|
+
schemas[`${actionDisplayName}_Response`] = actionResponse(actionDisplayName);
|
|
202
|
+
connectorSpec.paths[`${pathPrefix}#${action}`] = getActionOperation({
|
|
203
|
+
action,
|
|
204
|
+
operation,
|
|
205
|
+
actionDisplayName,
|
|
206
|
+
toolName,
|
|
207
|
+
toolInstructions
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
return connectorSpec;
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
__name(IntegrationClient, "IntegrationClient");
|
|
214
|
+
IntegrationClient = __decorateClass([
|
|
215
|
+
experimental
|
|
216
|
+
], IntegrationClient);
|
|
217
|
+
export {
|
|
218
|
+
IntegrationClient
|
|
219
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
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 { logger } from "../../utils/logger.js";
|
|
21
|
+
import { BaseTool } from "../base_tool.js";
|
|
22
|
+
import { ToolAuthHandler } from "../openapi_tool/openapi_spec_parser/tool_auth_handler.js";
|
|
23
|
+
const DYNAMIC_AUTH_EXCLUDE_FIELDS = Object.freeze([
|
|
24
|
+
"dynamic_auth_config",
|
|
25
|
+
"dynamicAuthConfig"
|
|
26
|
+
]);
|
|
27
|
+
let IntegrationConnectorTool = class extends BaseTool {
|
|
28
|
+
constructor(options) {
|
|
29
|
+
var _a, _b, _c;
|
|
30
|
+
super(options);
|
|
31
|
+
this.connectionName = options.connectionName;
|
|
32
|
+
this.connectionHost = options.connectionHost;
|
|
33
|
+
this.connectionServiceName = options.connectionServiceName;
|
|
34
|
+
this.entity = (_a = options.entity) != null ? _a : "";
|
|
35
|
+
this.operation = (_b = options.operation) != null ? _b : "";
|
|
36
|
+
this.action = (_c = options.action) != null ? _c : "";
|
|
37
|
+
this.restApiTool = options.restApiTool;
|
|
38
|
+
this.authScheme = options.authScheme;
|
|
39
|
+
this.authCredential = options.authCredential;
|
|
40
|
+
}
|
|
41
|
+
_getDeclaration() {
|
|
42
|
+
const declaration = this.restApiTool._getDeclaration();
|
|
43
|
+
const rawParameters = declaration == null ? void 0 : declaration.parameters;
|
|
44
|
+
let parameters;
|
|
45
|
+
if (rawParameters) {
|
|
46
|
+
parameters = { ...rawParameters };
|
|
47
|
+
if (rawParameters.properties) {
|
|
48
|
+
const properties = { ...rawParameters.properties };
|
|
49
|
+
for (const field of [
|
|
50
|
+
...IntegrationConnectorTool.EXCLUDE_FIELDS,
|
|
51
|
+
...DYNAMIC_AUTH_EXCLUDE_FIELDS
|
|
52
|
+
]) {
|
|
53
|
+
delete properties[field];
|
|
54
|
+
}
|
|
55
|
+
parameters.properties = properties;
|
|
56
|
+
}
|
|
57
|
+
if (rawParameters.required) {
|
|
58
|
+
parameters.required = rawParameters.required.filter(
|
|
59
|
+
(field) => !IntegrationConnectorTool.EXCLUDE_FIELDS.includes(field) && !DYNAMIC_AUTH_EXCLUDE_FIELDS.includes(field) && !IntegrationConnectorTool.OPTIONAL_FIELDS.includes(field)
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
name: this.name,
|
|
65
|
+
description: this.description,
|
|
66
|
+
parameters
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
async runAsync(request) {
|
|
70
|
+
const toolAuthHandler = ToolAuthHandler.fromToolContext(
|
|
71
|
+
request.toolContext,
|
|
72
|
+
this.authScheme,
|
|
73
|
+
this.authCredential
|
|
74
|
+
);
|
|
75
|
+
const authResult = await toolAuthHandler.prepareAuthCredentials();
|
|
76
|
+
if (authResult.state === "pending") {
|
|
77
|
+
return {
|
|
78
|
+
pending: true,
|
|
79
|
+
message: "Needs your authorization to access your data."
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const updatedArgs = {
|
|
83
|
+
...request.args,
|
|
84
|
+
connection_name: this.connectionName,
|
|
85
|
+
connectionName: this.connectionName,
|
|
86
|
+
service_name: this.connectionServiceName,
|
|
87
|
+
serviceName: this.connectionServiceName,
|
|
88
|
+
host: this.connectionHost
|
|
89
|
+
};
|
|
90
|
+
if (this.entity) {
|
|
91
|
+
updatedArgs["entity"] = this.entity;
|
|
92
|
+
}
|
|
93
|
+
if (this.operation) {
|
|
94
|
+
updatedArgs["operation"] = this.operation;
|
|
95
|
+
}
|
|
96
|
+
if (this.action) {
|
|
97
|
+
updatedArgs["action"] = this.action;
|
|
98
|
+
}
|
|
99
|
+
if (authResult.authCredential) {
|
|
100
|
+
const token = prepareDynamicEuc(authResult.authCredential);
|
|
101
|
+
const dynamicAuthPayload = {
|
|
102
|
+
"oauth2_auth_code_flow.access_token": token != null ? token : {}
|
|
103
|
+
};
|
|
104
|
+
updatedArgs["dynamic_auth_config"] = dynamicAuthPayload;
|
|
105
|
+
updatedArgs["dynamicAuthConfig"] = dynamicAuthPayload;
|
|
106
|
+
}
|
|
107
|
+
logger.debug(`Running tool: ${this.name}`);
|
|
108
|
+
return this.restApiTool.runAsync({
|
|
109
|
+
args: updatedArgs,
|
|
110
|
+
toolContext: request.toolContext
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
__name(IntegrationConnectorTool, "IntegrationConnectorTool");
|
|
115
|
+
/**
|
|
116
|
+
* Request fields that {@link IntegrationConnectorTool} injects at runtime and
|
|
117
|
+
* excludes from the function declaration shown to the model.
|
|
118
|
+
*/
|
|
119
|
+
IntegrationConnectorTool.EXCLUDE_FIELDS = Object.freeze([
|
|
120
|
+
"connection_name",
|
|
121
|
+
"connectionName",
|
|
122
|
+
"service_name",
|
|
123
|
+
"serviceName",
|
|
124
|
+
"host",
|
|
125
|
+
"entity",
|
|
126
|
+
"operation",
|
|
127
|
+
"action"
|
|
128
|
+
]);
|
|
129
|
+
/**
|
|
130
|
+
* Request fields that {@link IntegrationConnectorTool} removes from the
|
|
131
|
+
* `required` list in the function declaration shown to the model.
|
|
132
|
+
*/
|
|
133
|
+
IntegrationConnectorTool.OPTIONAL_FIELDS = Object.freeze([
|
|
134
|
+
"page_size",
|
|
135
|
+
"pageSize",
|
|
136
|
+
"page_token",
|
|
137
|
+
"pageToken",
|
|
138
|
+
"filter",
|
|
139
|
+
"filter_clause",
|
|
140
|
+
"filterClause"
|
|
141
|
+
]);
|
|
142
|
+
__decorateClass([
|
|
143
|
+
experimental
|
|
144
|
+
], IntegrationConnectorTool.prototype, "_getDeclaration", 1);
|
|
145
|
+
__decorateClass([
|
|
146
|
+
experimental
|
|
147
|
+
], IntegrationConnectorTool.prototype, "runAsync", 1);
|
|
148
|
+
IntegrationConnectorTool = __decorateClass([
|
|
149
|
+
experimental
|
|
150
|
+
], IntegrationConnectorTool);
|
|
151
|
+
function prepareDynamicEuc(authCredential) {
|
|
152
|
+
var _a, _b;
|
|
153
|
+
return ((_b = (_a = authCredential.http) == null ? void 0 : _a.credentials) == null ? void 0 : _b.token) || void 0;
|
|
154
|
+
}
|
|
155
|
+
__name(prepareDynamicEuc, "prepareDynamicEuc");
|
|
156
|
+
export {
|
|
157
|
+
IntegrationConnectorTool
|
|
158
|
+
};
|
|
@@ -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 {
|
|
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) {
|