@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
|
@@ -26,12 +26,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
26
26
|
var function_tool_exports = {};
|
|
27
27
|
__export(function_tool_exports, {
|
|
28
28
|
FunctionTool: () => FunctionTool,
|
|
29
|
+
buildFunctionDeclarationForLangchain: () => buildFunctionDeclarationForLangchain,
|
|
30
|
+
buildFunctionDeclarationForParamsForCrewai: () => buildFunctionDeclarationForParamsForCrewai,
|
|
31
|
+
buildFunctionDeclarationUtil: () => buildFunctionDeclarationUtil,
|
|
29
32
|
isFunctionTool: () => isFunctionTool
|
|
30
33
|
});
|
|
31
34
|
module.exports = __toCommonJS(function_tool_exports);
|
|
32
35
|
var import_genai = require("@google/genai");
|
|
33
36
|
var import_simple_zod_to_json = require("../utils/simple_zod_to_json.js");
|
|
34
37
|
var import_base_tool = require("./base_tool.js");
|
|
38
|
+
var import_gemini_schema_util = require("../utils/gemini_schema_util.js");
|
|
39
|
+
var import_schema = require("../utils/schema.js");
|
|
35
40
|
/**
|
|
36
41
|
* @license
|
|
37
42
|
* Copyright 2025 Google LLC
|
|
@@ -48,6 +53,27 @@ function toSchema(parameters) {
|
|
|
48
53
|
return parameters;
|
|
49
54
|
}
|
|
50
55
|
__name(toSchema, "toSchema");
|
|
56
|
+
function toResponseSchema(response) {
|
|
57
|
+
var _a2;
|
|
58
|
+
if ((0, import_simple_zod_to_json.isZodObject)(response)) {
|
|
59
|
+
return (0, import_simple_zod_to_json.zodObjectToSchema)(response);
|
|
60
|
+
}
|
|
61
|
+
if (typeof response === "object" && response !== null && "safeParse" in response && typeof response.safeParse === "function") {
|
|
62
|
+
return (_a2 = (0, import_gemini_schema_util.toGeminiSchema)(
|
|
63
|
+
(0, import_schema.toJsonSchema)(response)
|
|
64
|
+
)) != null ? _a2 : { type: import_genai.Type.TYPE_UNSPECIFIED };
|
|
65
|
+
}
|
|
66
|
+
return response;
|
|
67
|
+
}
|
|
68
|
+
__name(toResponseSchema, "toResponseSchema");
|
|
69
|
+
function isPlainRecord(value) {
|
|
70
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
71
|
+
}
|
|
72
|
+
__name(isPlainRecord, "isPlainRecord");
|
|
73
|
+
function isAsyncIterable(value) {
|
|
74
|
+
return typeof value === "object" && value !== null && Symbol.asyncIterator in value && typeof value[Symbol.asyncIterator] === "function";
|
|
75
|
+
}
|
|
76
|
+
__name(isAsyncIterable, "isAsyncIterable");
|
|
51
77
|
const FUNCTION_TOOL_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for("google.adk.functionTool");
|
|
52
78
|
function isFunctionTool(obj) {
|
|
53
79
|
return typeof obj === "object" && obj !== null && FUNCTION_TOOL_SIGNATURE_SYMBOL in obj && obj[FUNCTION_TOOL_SIGNATURE_SYMBOL] === true;
|
|
@@ -75,6 +101,7 @@ const _FunctionTool = class _FunctionTool extends (_b = import_base_tool.BaseToo
|
|
|
75
101
|
this[_a] = true;
|
|
76
102
|
this.execute = options.execute;
|
|
77
103
|
this.parameters = options.parameters;
|
|
104
|
+
this.response = options.response;
|
|
78
105
|
this.requireConfirmation = (_b2 = options.requireConfirmation) != null ? _b2 : false;
|
|
79
106
|
}
|
|
80
107
|
/**
|
|
@@ -82,6 +109,14 @@ const _FunctionTool = class _FunctionTool extends (_b = import_base_tool.BaseToo
|
|
|
82
109
|
* and parameter schema.
|
|
83
110
|
*/
|
|
84
111
|
_getDeclaration() {
|
|
112
|
+
if (this.response !== void 0) {
|
|
113
|
+
return {
|
|
114
|
+
name: this.name,
|
|
115
|
+
description: this.description,
|
|
116
|
+
parameters: toSchema(this.parameters),
|
|
117
|
+
response: toResponseSchema(this.response)
|
|
118
|
+
};
|
|
119
|
+
}
|
|
85
120
|
return {
|
|
86
121
|
name: this.name,
|
|
87
122
|
description: this.description,
|
|
@@ -114,6 +149,41 @@ const _FunctionTool = class _FunctionTool extends (_b = import_base_tool.BaseToo
|
|
|
114
149
|
throw new Error(`Error in tool '${this.name}': ${errorMessage}`);
|
|
115
150
|
}
|
|
116
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Invokes the tool in live streaming mode, injecting any active input stream
|
|
154
|
+
* from the invocation context and yielding items from the returned stream.
|
|
155
|
+
*
|
|
156
|
+
* @param req The live tool invocation request.
|
|
157
|
+
*/
|
|
158
|
+
async *_callLive(req) {
|
|
159
|
+
var _a2;
|
|
160
|
+
const validatedArgs = this.validateArgs(req.args);
|
|
161
|
+
const argsToCall = isPlainRecord(validatedArgs) ? { ...validatedArgs } : { ...req.args };
|
|
162
|
+
const activeTool = (_a2 = req.invocationContext.activeStreamingTools) == null ? void 0 : _a2[this.name];
|
|
163
|
+
if (activeTool == null ? void 0 : activeTool.stream) {
|
|
164
|
+
argsToCall["inputStream"] = activeTool.stream;
|
|
165
|
+
}
|
|
166
|
+
const rawResult = this.execute(
|
|
167
|
+
argsToCall,
|
|
168
|
+
req.toolContext
|
|
169
|
+
);
|
|
170
|
+
if (isAsyncIterable(rawResult)) {
|
|
171
|
+
for await (const item of rawResult) {
|
|
172
|
+
yield item;
|
|
173
|
+
}
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const awaited = await rawResult;
|
|
177
|
+
if (isAsyncIterable(awaited)) {
|
|
178
|
+
for await (const item of awaited) {
|
|
179
|
+
yield item;
|
|
180
|
+
}
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (awaited !== void 0) {
|
|
184
|
+
yield awaited;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
117
187
|
/**
|
|
118
188
|
* Whether this call is gated on human approval — the static flag, or the
|
|
119
189
|
* predicate evaluated against the validated arguments.
|
|
@@ -175,8 +245,257 @@ const _FunctionTool = class _FunctionTool extends (_b = import_base_tool.BaseToo
|
|
|
175
245
|
};
|
|
176
246
|
__name(_FunctionTool, "FunctionTool");
|
|
177
247
|
let FunctionTool = _FunctionTool;
|
|
248
|
+
const SCHEMA_TYPE_MAP = {
|
|
249
|
+
str: import_genai.Type.STRING,
|
|
250
|
+
int: import_genai.Type.INTEGER,
|
|
251
|
+
float: import_genai.Type.NUMBER,
|
|
252
|
+
bool: import_genai.Type.BOOLEAN,
|
|
253
|
+
string: import_genai.Type.STRING,
|
|
254
|
+
integer: import_genai.Type.INTEGER,
|
|
255
|
+
number: import_genai.Type.NUMBER,
|
|
256
|
+
boolean: import_genai.Type.BOOLEAN,
|
|
257
|
+
list: import_genai.Type.ARRAY,
|
|
258
|
+
array: import_genai.Type.ARRAY,
|
|
259
|
+
tuple: import_genai.Type.ARRAY,
|
|
260
|
+
object: import_genai.Type.OBJECT,
|
|
261
|
+
Dict: import_genai.Type.OBJECT,
|
|
262
|
+
List: import_genai.Type.ARRAY,
|
|
263
|
+
Tuple: import_genai.Type.ARRAY,
|
|
264
|
+
Any: import_genai.Type.TYPE_UNSPECIFIED,
|
|
265
|
+
STRING: import_genai.Type.STRING,
|
|
266
|
+
INTEGER: import_genai.Type.INTEGER,
|
|
267
|
+
NUMBER: import_genai.Type.NUMBER,
|
|
268
|
+
BOOLEAN: import_genai.Type.BOOLEAN,
|
|
269
|
+
ARRAY: import_genai.Type.ARRAY,
|
|
270
|
+
OBJECT: import_genai.Type.OBJECT,
|
|
271
|
+
NULL: import_genai.Type.NULL,
|
|
272
|
+
null: import_genai.Type.NULL,
|
|
273
|
+
TYPE_UNSPECIFIED: import_genai.Type.TYPE_UNSPECIFIED
|
|
274
|
+
};
|
|
275
|
+
function annotateNullableFields(schema) {
|
|
276
|
+
const properties = schema["properties"];
|
|
277
|
+
if (!isPlainRecord(properties)) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
for (const propertySchema of Object.values(properties)) {
|
|
281
|
+
if (!isPlainRecord(propertySchema)) {
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
const anyOf = propertySchema["anyOf"];
|
|
285
|
+
if (!Array.isArray(anyOf)) {
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
for (let i = 0; i < anyOf.length; i++) {
|
|
289
|
+
const branch = anyOf[i];
|
|
290
|
+
if (isPlainRecord(branch) && (branch["type"] === "null" || branch["type"] === import_genai.Type.NULL)) {
|
|
291
|
+
propertySchema["nullable"] = true;
|
|
292
|
+
anyOf.splice(i, 1);
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
__name(annotateNullableFields, "annotateNullableFields");
|
|
299
|
+
function annotateRequiredFields(schema) {
|
|
300
|
+
const properties = schema["properties"];
|
|
301
|
+
if (!isPlainRecord(properties)) {
|
|
302
|
+
schema["required"] = [];
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
const required = [];
|
|
306
|
+
for (const [fieldName, fieldSchema] of Object.entries(properties)) {
|
|
307
|
+
if (isPlainRecord(fieldSchema) && !fieldSchema["nullable"] && !("default" in fieldSchema)) {
|
|
308
|
+
required.push(fieldName);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
schema["required"] = required;
|
|
312
|
+
}
|
|
313
|
+
__name(annotateRequiredFields, "annotateRequiredFields");
|
|
314
|
+
function removeAnyOf(schema) {
|
|
315
|
+
const properties = schema["properties"];
|
|
316
|
+
if (!isPlainRecord(properties)) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
for (const propertySchema of Object.values(properties)) {
|
|
320
|
+
if (!isPlainRecord(propertySchema)) {
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
const unionTypes = propertySchema["anyOf"];
|
|
324
|
+
delete propertySchema["anyOf"];
|
|
325
|
+
if (Array.isArray(unionTypes)) {
|
|
326
|
+
for (const branch of unionTypes) {
|
|
327
|
+
if (isPlainRecord(branch) && branch["type"] !== "null" && branch["type"] !== import_genai.Type.NULL) {
|
|
328
|
+
Object.assign(propertySchema, branch);
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
__name(removeAnyOf, "removeAnyOf");
|
|
336
|
+
function removeDefault(schema) {
|
|
337
|
+
const properties = schema["properties"];
|
|
338
|
+
if (!isPlainRecord(properties)) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
for (const propertySchema of Object.values(properties)) {
|
|
342
|
+
if (isPlainRecord(propertySchema)) {
|
|
343
|
+
delete propertySchema["default"];
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
__name(removeDefault, "removeDefault");
|
|
348
|
+
function removeNullable(schema) {
|
|
349
|
+
const properties = schema["properties"];
|
|
350
|
+
if (!isPlainRecord(properties)) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
for (const propertySchema of Object.values(properties)) {
|
|
354
|
+
if (isPlainRecord(propertySchema)) {
|
|
355
|
+
delete propertySchema["nullable"];
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
__name(removeNullable, "removeNullable");
|
|
360
|
+
function removeTitle(schema) {
|
|
361
|
+
const properties = schema["properties"];
|
|
362
|
+
if (!isPlainRecord(properties)) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
for (const propertySchema of Object.values(properties)) {
|
|
366
|
+
if (isPlainRecord(propertySchema)) {
|
|
367
|
+
delete propertySchema["title"];
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
__name(removeTitle, "removeTitle");
|
|
372
|
+
function processParameterSchema(vertexai, schema) {
|
|
373
|
+
annotateNullableFields(schema);
|
|
374
|
+
annotateRequiredFields(schema);
|
|
375
|
+
if (!vertexai) {
|
|
376
|
+
removeAnyOf(schema);
|
|
377
|
+
removeDefault(schema);
|
|
378
|
+
removeNullable(schema);
|
|
379
|
+
removeTitle(schema);
|
|
380
|
+
}
|
|
381
|
+
return schema;
|
|
382
|
+
}
|
|
383
|
+
__name(processParameterSchema, "processParameterSchema");
|
|
384
|
+
function mapPropertySchemaType(propertySchema) {
|
|
385
|
+
var _a2, _b2;
|
|
386
|
+
if (typeof propertySchema["type"] === "string") {
|
|
387
|
+
propertySchema["type"] = (_a2 = SCHEMA_TYPE_MAP[propertySchema["type"]]) != null ? _a2 : import_genai.Type.TYPE_UNSPECIFIED;
|
|
388
|
+
if (propertySchema["type"] === import_genai.Type.ARRAY && isPlainRecord(propertySchema["items"])) {
|
|
389
|
+
mapPropertySchemaType(propertySchema["items"]);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (isPlainRecord(propertySchema["properties"])) {
|
|
393
|
+
for (const nestedProp of Object.values(propertySchema["properties"])) {
|
|
394
|
+
if (isPlainRecord(nestedProp)) {
|
|
395
|
+
mapPropertySchemaType(nestedProp);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (Array.isArray(propertySchema["anyOf"])) {
|
|
400
|
+
for (const branch of propertySchema["anyOf"]) {
|
|
401
|
+
if (isPlainRecord(branch) && typeof branch["type"] === "string") {
|
|
402
|
+
branch["type"] = (_b2 = SCHEMA_TYPE_MAP[branch["type"]]) != null ? _b2 : import_genai.Type.TYPE_UNSPECIFIED;
|
|
403
|
+
propertySchema["type"] = branch["type"];
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
__name(mapPropertySchemaType, "mapPropertySchemaType");
|
|
409
|
+
function mapSchemaTypes(schema) {
|
|
410
|
+
const properties = schema["properties"];
|
|
411
|
+
if (!isPlainRecord(properties)) {
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
for (const propertySchema of Object.values(properties)) {
|
|
415
|
+
if (isPlainRecord(propertySchema)) {
|
|
416
|
+
mapPropertySchemaType(propertySchema);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
__name(mapSchemaTypes, "mapSchemaTypes");
|
|
421
|
+
function resolveReturnSchema(func, beforeParamSchema) {
|
|
422
|
+
var _a2, _b2, _c;
|
|
423
|
+
const funcObj = typeof func === "function" || isPlainRecord(func) ? func : void 0;
|
|
424
|
+
const responseCandidate = (_a2 = funcObj == null ? void 0 : funcObj.response) != null ? _a2 : beforeParamSchema["response"];
|
|
425
|
+
if (responseCandidate !== void 0) {
|
|
426
|
+
return toResponseSchema(responseCandidate);
|
|
427
|
+
}
|
|
428
|
+
const returnTypeCandidate = (_b2 = funcObj == null ? void 0 : funcObj.returnType) != null ? _b2 : typeof beforeParamSchema["returnType"] === "string" ? beforeParamSchema["returnType"] : void 0;
|
|
429
|
+
if (typeof returnTypeCandidate === "string") {
|
|
430
|
+
return {
|
|
431
|
+
type: (_c = SCHEMA_TYPE_MAP[returnTypeCandidate]) != null ? _c : import_genai.Type.TYPE_UNSPECIFIED
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
if (typeof func === "function") {
|
|
435
|
+
return { type: import_genai.Type.TYPE_UNSPECIFIED };
|
|
436
|
+
}
|
|
437
|
+
return void 0;
|
|
438
|
+
}
|
|
439
|
+
__name(resolveReturnSchema, "resolveReturnSchema");
|
|
440
|
+
function buildFunctionDeclarationUtil(vertexai, name, description, func, beforeParamSchema) {
|
|
441
|
+
const schemaCopy = structuredClone(beforeParamSchema);
|
|
442
|
+
mapSchemaTypes(schemaCopy);
|
|
443
|
+
const properties = isPlainRecord(schemaCopy["properties"]) ? schemaCopy["properties"] : {};
|
|
444
|
+
const hasProperties = Object.keys(properties).length > 0;
|
|
445
|
+
const declaration = {
|
|
446
|
+
name,
|
|
447
|
+
description
|
|
448
|
+
};
|
|
449
|
+
if (hasProperties) {
|
|
450
|
+
const parameters = {
|
|
451
|
+
type: import_genai.Type.OBJECT,
|
|
452
|
+
properties
|
|
453
|
+
};
|
|
454
|
+
if (Array.isArray(schemaCopy["required"]) && schemaCopy["required"].length > 0) {
|
|
455
|
+
parameters.required = schemaCopy["required"];
|
|
456
|
+
}
|
|
457
|
+
declaration.parameters = parameters;
|
|
458
|
+
}
|
|
459
|
+
if (vertexai) {
|
|
460
|
+
const responseSchema = resolveReturnSchema(func, schemaCopy);
|
|
461
|
+
if (responseSchema !== void 0) {
|
|
462
|
+
declaration.response = responseSchema;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
return declaration;
|
|
466
|
+
}
|
|
467
|
+
__name(buildFunctionDeclarationUtil, "buildFunctionDeclarationUtil");
|
|
468
|
+
function buildFunctionDeclarationForLangchain(vertexai, name, description, func, paramSchema) {
|
|
469
|
+
const rawCopy = structuredClone(paramSchema);
|
|
470
|
+
const explicitRequired = Array.isArray(rawCopy["required"]) ? rawCopy["required"] : void 0;
|
|
471
|
+
delete rawCopy["required"];
|
|
472
|
+
const wrapped = processParameterSchema(vertexai, {
|
|
473
|
+
properties: rawCopy
|
|
474
|
+
});
|
|
475
|
+
const properties = isPlainRecord(wrapped["properties"]) ? { ...wrapped["properties"] } : {};
|
|
476
|
+
const computedRequired = Array.isArray(wrapped["required"]) ? wrapped["required"] : [];
|
|
477
|
+
const requiredFields = explicitRequired !== void 0 ? explicitRequired : computedRequired;
|
|
478
|
+
return buildFunctionDeclarationUtil(vertexai, name, description, func, {
|
|
479
|
+
properties,
|
|
480
|
+
required: requiredFields
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
__name(buildFunctionDeclarationForLangchain, "buildFunctionDeclarationForLangchain");
|
|
484
|
+
function buildFunctionDeclarationForParamsForCrewai(vertexai, name, description, func, paramSchema) {
|
|
485
|
+
const processed = processParameterSchema(
|
|
486
|
+
vertexai,
|
|
487
|
+
structuredClone(paramSchema)
|
|
488
|
+
);
|
|
489
|
+
return buildFunctionDeclarationUtil(vertexai, name, description, func, {
|
|
490
|
+
...processed
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
__name(buildFunctionDeclarationForParamsForCrewai, "buildFunctionDeclarationForParamsForCrewai");
|
|
178
494
|
// Annotate the CommonJS export names for ESM import in node:
|
|
179
495
|
0 && (module.exports = {
|
|
180
496
|
FunctionTool,
|
|
497
|
+
buildFunctionDeclarationForLangchain,
|
|
498
|
+
buildFunctionDeclarationForParamsForCrewai,
|
|
499
|
+
buildFunctionDeclarationUtil,
|
|
181
500
|
isFunctionTool
|
|
182
501
|
});
|
|
@@ -0,0 +1,100 @@
|
|
|
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 google_api_tool_exports = {};
|
|
35
|
+
__export(google_api_tool_exports, {
|
|
36
|
+
GoogleApiTool: () => GoogleApiTool,
|
|
37
|
+
isGoogleApiTool: () => isGoogleApiTool
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(google_api_tool_exports);
|
|
40
|
+
var import_auth_credential = require("../../auth/auth_credential.js");
|
|
41
|
+
var import_experimental = require("../../utils/experimental.js");
|
|
42
|
+
var import_base_tool = require("../base_tool.js");
|
|
43
|
+
/**
|
|
44
|
+
* @license
|
|
45
|
+
* Copyright 2026 Google LLC
|
|
46
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
47
|
+
*/
|
|
48
|
+
var _a, _b;
|
|
49
|
+
const GOOGLE_API_TOOL_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for("google.adk.googleApiTool");
|
|
50
|
+
function isGoogleApiTool(obj) {
|
|
51
|
+
return typeof obj === "object" && obj !== null && GOOGLE_API_TOOL_SIGNATURE_SYMBOL in obj && obj[GOOGLE_API_TOOL_SIGNATURE_SYMBOL] === true;
|
|
52
|
+
}
|
|
53
|
+
__name(isGoogleApiTool, "isGoogleApiTool");
|
|
54
|
+
let GoogleApiTool = class extends (_b = import_base_tool.BaseTool, _a = GOOGLE_API_TOOL_SIGNATURE_SYMBOL, _b) {
|
|
55
|
+
constructor(restApiTool, options = {}) {
|
|
56
|
+
super({
|
|
57
|
+
name: restApiTool.name,
|
|
58
|
+
description: restApiTool.description,
|
|
59
|
+
isLongRunning: restApiTool.isLongRunning
|
|
60
|
+
});
|
|
61
|
+
this[_a] = true;
|
|
62
|
+
this.restApiTool = restApiTool;
|
|
63
|
+
if (options.clientId !== void 0 || options.clientSecret !== void 0) {
|
|
64
|
+
this.configureAuth(options.clientId, options.clientSecret);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
_getDeclaration() {
|
|
68
|
+
return this.restApiTool._getDeclaration();
|
|
69
|
+
}
|
|
70
|
+
runAsync(request) {
|
|
71
|
+
return this.restApiTool.runAsync(request);
|
|
72
|
+
}
|
|
73
|
+
configureAuth(clientId, clientSecret) {
|
|
74
|
+
this.restApiTool.configureAuthCredential({
|
|
75
|
+
authType: import_auth_credential.AuthCredentialTypes.OPEN_ID_CONNECT,
|
|
76
|
+
oauth2: {
|
|
77
|
+
clientId,
|
|
78
|
+
clientSecret
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
__name(GoogleApiTool, "GoogleApiTool");
|
|
84
|
+
__decorateClass([
|
|
85
|
+
import_experimental.experimental
|
|
86
|
+
], GoogleApiTool.prototype, "_getDeclaration", 1);
|
|
87
|
+
__decorateClass([
|
|
88
|
+
import_experimental.experimental
|
|
89
|
+
], GoogleApiTool.prototype, "runAsync", 1);
|
|
90
|
+
__decorateClass([
|
|
91
|
+
import_experimental.experimental
|
|
92
|
+
], GoogleApiTool.prototype, "configureAuth", 1);
|
|
93
|
+
GoogleApiTool = __decorateClass([
|
|
94
|
+
import_experimental.experimental
|
|
95
|
+
], GoogleApiTool);
|
|
96
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
97
|
+
0 && (module.exports = {
|
|
98
|
+
GoogleApiTool,
|
|
99
|
+
isGoogleApiTool
|
|
100
|
+
});
|
|
@@ -0,0 +1,173 @@
|
|
|
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 google_api_toolset_exports = {};
|
|
35
|
+
__export(google_api_toolset_exports, {
|
|
36
|
+
GoogleApiToolset: () => GoogleApiToolset,
|
|
37
|
+
isGoogleApiToolset: () => isGoogleApiToolset
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(google_api_toolset_exports);
|
|
40
|
+
var import_experimental = require("../../utils/experimental.js");
|
|
41
|
+
var import_base_toolset = require("../base_toolset.js");
|
|
42
|
+
var import_openapi_toolset = require("../openapi_tool/openapi_toolset.js");
|
|
43
|
+
var import_google_api_tool = require("./google_api_tool.js");
|
|
44
|
+
var import_googleapi_to_openapi_converter = require("./googleapi_to_openapi_converter.js");
|
|
45
|
+
/**
|
|
46
|
+
* @license
|
|
47
|
+
* Copyright 2026 Google LLC
|
|
48
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
49
|
+
*/
|
|
50
|
+
var _a, _b;
|
|
51
|
+
const GOOGLE_API_TOOLSET_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for(
|
|
52
|
+
"google.adk.googleApiToolset"
|
|
53
|
+
);
|
|
54
|
+
const GOOGLE_OIDC_AUTH_ENDPOINT = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
55
|
+
const GOOGLE_OIDC_TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token";
|
|
56
|
+
const GOOGLE_OIDC_USERINFO_ENDPOINT = "https://openidconnect.googleapis.com/v1/userinfo";
|
|
57
|
+
const GOOGLE_OIDC_REVOCATION_ENDPOINT = "https://oauth2.googleapis.com/revoke";
|
|
58
|
+
function isGoogleApiToolset(obj) {
|
|
59
|
+
return typeof obj === "object" && obj !== null && GOOGLE_API_TOOLSET_SIGNATURE_SYMBOL in obj && obj[GOOGLE_API_TOOLSET_SIGNATURE_SYMBOL] === true;
|
|
60
|
+
}
|
|
61
|
+
__name(isGoogleApiToolset, "isGoogleApiToolset");
|
|
62
|
+
let GoogleApiToolset = class extends (_b = import_base_toolset.BaseToolset, _a = GOOGLE_API_TOOLSET_SIGNATURE_SYMBOL, _b) {
|
|
63
|
+
constructor(options = {}) {
|
|
64
|
+
var _a2;
|
|
65
|
+
const toolFilter = (_a2 = options.toolFilter) != null ? _a2 : [];
|
|
66
|
+
super(toolFilter);
|
|
67
|
+
this[_a] = true;
|
|
68
|
+
this.tools = [];
|
|
69
|
+
this.toolFilter = toolFilter;
|
|
70
|
+
this.apiName = options.apiName;
|
|
71
|
+
this.apiVersion = options.apiVersion;
|
|
72
|
+
this.clientId = options.clientId;
|
|
73
|
+
this.clientSecret = options.clientSecret;
|
|
74
|
+
}
|
|
75
|
+
async loadToolsetWithOidcAuth() {
|
|
76
|
+
var _a2, _b2, _c, _d, _e;
|
|
77
|
+
if (!this.apiName || !this.apiVersion) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
"Both apiName and apiVersion are required to load a GoogleApiToolset."
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
const specDict = await new import_googleapi_to_openapi_converter.GoogleApiToOpenApiConverter(
|
|
83
|
+
this.apiName,
|
|
84
|
+
this.apiVersion
|
|
85
|
+
).convert();
|
|
86
|
+
const oauth2Scheme = (_b2 = (_a2 = specDict.components) == null ? void 0 : _a2.securitySchemes) == null ? void 0 : _b2["oauth2"];
|
|
87
|
+
const scopesMap = (_e = (_d = (_c = oauth2Scheme == null ? void 0 : oauth2Scheme.flows) == null ? void 0 : _c.authorizationCode) == null ? void 0 : _d.scopes) != null ? _e : {};
|
|
88
|
+
const firstScope = Object.keys(scopesMap)[0];
|
|
89
|
+
const scopes = firstScope ? [firstScope] : void 0;
|
|
90
|
+
const authScheme = {
|
|
91
|
+
type: "openIdConnect",
|
|
92
|
+
openIdConnectUrl: "",
|
|
93
|
+
authorizationEndpoint: GOOGLE_OIDC_AUTH_ENDPOINT,
|
|
94
|
+
tokenEndpoint: GOOGLE_OIDC_TOKEN_ENDPOINT,
|
|
95
|
+
userinfoEndpoint: GOOGLE_OIDC_USERINFO_ENDPOINT,
|
|
96
|
+
revocationEndpoint: GOOGLE_OIDC_REVOCATION_ENDPOINT,
|
|
97
|
+
tokenEndpointAuthMethodsSupported: [
|
|
98
|
+
"client_secret_post",
|
|
99
|
+
"client_secret_basic"
|
|
100
|
+
],
|
|
101
|
+
grantTypesSupported: ["authorization_code"],
|
|
102
|
+
scopes
|
|
103
|
+
};
|
|
104
|
+
return new import_openapi_toolset.OpenAPIToolset({
|
|
105
|
+
specDict,
|
|
106
|
+
specType: "yaml",
|
|
107
|
+
authScheme
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
async ensureToolsLoaded() {
|
|
111
|
+
var _a2;
|
|
112
|
+
if (this.openapiToolset || !this.apiName || !this.apiVersion) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
(_a2 = this.loadingPromise) != null ? _a2 : this.loadingPromise = (async () => {
|
|
116
|
+
try {
|
|
117
|
+
const openapiToolset = await this.loadToolsetWithOidcAuth();
|
|
118
|
+
const restTools = await openapiToolset.getTools();
|
|
119
|
+
this.tools = restTools.map(
|
|
120
|
+
(tool) => new import_google_api_tool.GoogleApiTool(tool, {
|
|
121
|
+
clientId: this.clientId,
|
|
122
|
+
clientSecret: this.clientSecret
|
|
123
|
+
})
|
|
124
|
+
);
|
|
125
|
+
this.openapiToolset = openapiToolset;
|
|
126
|
+
} catch (error) {
|
|
127
|
+
this.loadingPromise = void 0;
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
})();
|
|
131
|
+
await this.loadingPromise;
|
|
132
|
+
}
|
|
133
|
+
async getTools(context) {
|
|
134
|
+
await this.ensureToolsLoaded();
|
|
135
|
+
return this.tools.filter((tool) => this.isToolSelected(tool, context));
|
|
136
|
+
}
|
|
137
|
+
setToolFilter(toolFilter) {
|
|
138
|
+
this.toolFilter = toolFilter;
|
|
139
|
+
}
|
|
140
|
+
configureAuth(clientId, clientSecret) {
|
|
141
|
+
this.clientId = clientId;
|
|
142
|
+
this.clientSecret = clientSecret;
|
|
143
|
+
for (const tool of this.tools) {
|
|
144
|
+
tool.configureAuth(clientId, clientSecret);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async close() {
|
|
148
|
+
if (this.openapiToolset) {
|
|
149
|
+
await this.openapiToolset.close();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
__name(GoogleApiToolset, "GoogleApiToolset");
|
|
154
|
+
__decorateClass([
|
|
155
|
+
import_experimental.experimental
|
|
156
|
+
], GoogleApiToolset.prototype, "getTools", 1);
|
|
157
|
+
__decorateClass([
|
|
158
|
+
import_experimental.experimental
|
|
159
|
+
], GoogleApiToolset.prototype, "setToolFilter", 1);
|
|
160
|
+
__decorateClass([
|
|
161
|
+
import_experimental.experimental
|
|
162
|
+
], GoogleApiToolset.prototype, "configureAuth", 1);
|
|
163
|
+
__decorateClass([
|
|
164
|
+
import_experimental.experimental
|
|
165
|
+
], GoogleApiToolset.prototype, "close", 1);
|
|
166
|
+
GoogleApiToolset = __decorateClass([
|
|
167
|
+
import_experimental.experimental
|
|
168
|
+
], GoogleApiToolset);
|
|
169
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
170
|
+
0 && (module.exports = {
|
|
171
|
+
GoogleApiToolset,
|
|
172
|
+
isGoogleApiToolset
|
|
173
|
+
});
|