@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
|
@@ -63,7 +63,10 @@ const _RemoteA2AAgent = class _RemoteA2AAgent extends import_base_agent.BaseAgen
|
|
|
63
63
|
this.client = this.a2aConfig.client;
|
|
64
64
|
}
|
|
65
65
|
if (this.a2aConfig.agentCard) {
|
|
66
|
-
this.card = await (0, import_agent_card.resolveAgentCard)(
|
|
66
|
+
this.card = await (0, import_agent_card.resolveAgentCard)(
|
|
67
|
+
this.a2aConfig.agentCard,
|
|
68
|
+
this.a2aConfig.resolveAgentCardOptions
|
|
69
|
+
);
|
|
67
70
|
if (!this.client) {
|
|
68
71
|
const factory = this.a2aConfig.clientFactory || new import_client.ClientFactory();
|
|
69
72
|
this.client = await factory.createFromAgentCard(this.card);
|
|
@@ -59,19 +59,21 @@ var import_workflow = require("../workflow/workflow.js");
|
|
|
59
59
|
* Copyright 2026 Google LLC
|
|
60
60
|
* SPDX-License-Identifier: Apache-2.0
|
|
61
61
|
*/
|
|
62
|
-
|
|
63
|
-
async function resolveAgentCard(agentCard) {
|
|
62
|
+
async function resolveAgentCard(agentCard, options = {}) {
|
|
64
63
|
if (typeof agentCard === "object") {
|
|
65
64
|
return agentCard;
|
|
66
65
|
}
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
await
|
|
66
|
+
const source = agentCard;
|
|
67
|
+
if (source.startsWith("http://") || source.startsWith("https://")) {
|
|
68
|
+
await refuseLinkLocalHost(source);
|
|
70
69
|
const resolver = new import_client.DefaultAgentCardResolver({
|
|
71
|
-
fetchImpl:
|
|
70
|
+
fetchImpl: refuseRedirectFetch
|
|
72
71
|
});
|
|
73
|
-
|
|
72
|
+
const card = await resolver.resolve(source);
|
|
73
|
+
validateCardRpcTargets(card, source, options);
|
|
74
|
+
return card;
|
|
74
75
|
}
|
|
76
|
+
const url = parseCardUrl(source);
|
|
75
77
|
if (url && url.protocol !== "file:") {
|
|
76
78
|
throw new Error(
|
|
77
79
|
`Unsupported agent card URL scheme "${url.protocol}": ${agentCard}. Use http://, https:// or file://, or pass a filesystem path with no scheme.`
|
|
@@ -80,6 +82,31 @@ async function resolveAgentCard(agentCard) {
|
|
|
80
82
|
return readAgentCardFile(agentCard, url);
|
|
81
83
|
}
|
|
82
84
|
__name(resolveAgentCard, "resolveAgentCard");
|
|
85
|
+
const WINDOWS_DRIVE_PROTOCOL = /^[a-z]:$/i;
|
|
86
|
+
async function refuseLinkLocalHost(source) {
|
|
87
|
+
const hostname = (0, import_ssrf_guard.normalizeHost)(new URL(source).hostname);
|
|
88
|
+
if ((0, import_ssrf_guard.isLocalhostHostname)(hostname)) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const addresses = await (0, import_ssrf_guard.resolveHostAddresses)(hostname);
|
|
92
|
+
if (addresses.some((address) => (0, import_ssrf_guard.isLinkLocalAddress)(address))) {
|
|
93
|
+
throw new Error(
|
|
94
|
+
`Refusing to fetch agent card from a link-local address: ${hostname}`
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
__name(refuseLinkLocalHost, "refuseLinkLocalHost");
|
|
99
|
+
async function refuseRedirectFetch(url, init) {
|
|
100
|
+
const response = await fetch(url, { ...init, redirect: "manual" });
|
|
101
|
+
if (response.status === 0 || response.status >= 300 && response.status < 400) {
|
|
102
|
+
const location = response.headers.get("location");
|
|
103
|
+
throw new Error(
|
|
104
|
+
`Refusing to follow a redirect from the agent card endpoint (status ${response.status}, location ${location}): ${url}`
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
return response;
|
|
108
|
+
}
|
|
109
|
+
__name(refuseRedirectFetch, "refuseRedirectFetch");
|
|
83
110
|
function parseCardUrl(source) {
|
|
84
111
|
let url;
|
|
85
112
|
try {
|
|
@@ -102,32 +129,81 @@ async function readAgentCardFile(source, url) {
|
|
|
102
129
|
}
|
|
103
130
|
}
|
|
104
131
|
__name(readAgentCardFile, "readAgentCardFile");
|
|
105
|
-
function
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
132
|
+
function validateCardRpcTargets(card, source, options) {
|
|
133
|
+
var _a;
|
|
134
|
+
let parsedSource;
|
|
135
|
+
try {
|
|
136
|
+
parsedSource = new URL(source);
|
|
137
|
+
} catch (err) {
|
|
138
|
+
throw new Error(
|
|
139
|
+
`Invalid agent card source URL: ${source}: ${err.message}`
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
const rpcUrls = [
|
|
143
|
+
card.url,
|
|
144
|
+
...((_a = card.additionalInterfaces) != null ? _a : []).map((i) => i.url)
|
|
145
|
+
];
|
|
146
|
+
for (const rpcUrl of rpcUrls) {
|
|
147
|
+
let parsed;
|
|
148
|
+
try {
|
|
149
|
+
parsed = new URL(rpcUrl);
|
|
150
|
+
} catch (err) {
|
|
109
151
|
throw new Error(
|
|
110
|
-
`
|
|
152
|
+
`Invalid RPC URL in agent card: ${rpcUrl}: ${err.message}`
|
|
111
153
|
);
|
|
112
154
|
}
|
|
113
|
-
|
|
114
|
-
|
|
155
|
+
if (parsed.protocol !== "https:" && !isLoopbackHost(parsed.hostname)) {
|
|
156
|
+
if (options.allowInsecureRpc === true) {
|
|
157
|
+
import_logger.logger.warn(
|
|
158
|
+
`SECURITY WARNING: accepting a plaintext http RPC URL on a non-loopback host because \`allowInsecureRpc: true\` was set: ${rpcUrl}. This connection can be intercepted or altered by anything on the network path.`
|
|
159
|
+
);
|
|
160
|
+
} else {
|
|
161
|
+
throw new Error(
|
|
162
|
+
`Agent card RPC URL must use https, or http on a loopback host: ${rpcUrl}`
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (!sameOriginForRpc(parsedSource, parsed)) {
|
|
167
|
+
if (options.allowCrossOriginRpc === true) {
|
|
168
|
+
import_logger.logger.warn(
|
|
169
|
+
`SECURITY WARNING: accepting an agent card RPC URL whose origin differs from the location the card was fetched from because \`allowCrossOriginRpc: true\` was set (fetched from ${source}): ${rpcUrl}.`
|
|
170
|
+
);
|
|
171
|
+
} else {
|
|
172
|
+
throw new Error(
|
|
173
|
+
`Agent card RPC URL must have the same origin as the location the card was fetched from (${source}): ${rpcUrl}`
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
115
178
|
}
|
|
116
|
-
__name(
|
|
117
|
-
function
|
|
118
|
-
|
|
179
|
+
__name(validateCardRpcTargets, "validateCardRpcTargets");
|
|
180
|
+
function sameOriginForRpc(source, rpc) {
|
|
181
|
+
const sourceIsLoopback = isLoopbackHost(source.hostname);
|
|
182
|
+
const rpcIsLoopback = isLoopbackHost(rpc.hostname);
|
|
183
|
+
if (sourceIsLoopback && rpcIsLoopback) {
|
|
184
|
+
return source.protocol === rpc.protocol && effectivePort(source) === effectivePort(rpc);
|
|
185
|
+
}
|
|
186
|
+
return source.origin === rpc.origin;
|
|
119
187
|
}
|
|
120
|
-
__name(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
);
|
|
188
|
+
__name(sameOriginForRpc, "sameOriginForRpc");
|
|
189
|
+
function effectivePort(url) {
|
|
190
|
+
if (url.port) {
|
|
191
|
+
return url.port;
|
|
192
|
+
}
|
|
193
|
+
if (url.protocol === "https:") {
|
|
194
|
+
return "443";
|
|
128
195
|
}
|
|
196
|
+
if (url.protocol === "http:") {
|
|
197
|
+
return "80";
|
|
198
|
+
}
|
|
199
|
+
return url.port;
|
|
200
|
+
}
|
|
201
|
+
__name(effectivePort, "effectivePort");
|
|
202
|
+
function isLoopbackHost(hostname) {
|
|
203
|
+
const bare = hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
204
|
+
return bare === "localhost" || bare === "127.0.0.1" || bare === "::1" || bare === "0.0.0.0" || bare === "::" || /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(bare);
|
|
129
205
|
}
|
|
130
|
-
__name(
|
|
206
|
+
__name(isLoopbackHost, "isLoopbackHost");
|
|
131
207
|
async function getA2AAgentCard(agent, transports) {
|
|
132
208
|
return {
|
|
133
209
|
name: agent.name,
|
|
@@ -87,7 +87,7 @@ async function toA2a(agent, options = {}) {
|
|
|
87
87
|
const protocol = (_c = options.protocol) != null ? _c : "http";
|
|
88
88
|
const basePath = options.basePath || "";
|
|
89
89
|
const rpcUrl = `${protocol}://${host}:${port}${basePath}`;
|
|
90
|
-
const agentCard = options.agentCard ? await (0, import_agent_card.resolveAgentCard)(options.agentCard) : await (0, import_agent_card.getA2AAgentCard)(agent, [
|
|
90
|
+
const agentCard = options.agentCard ? await (0, import_agent_card.resolveAgentCard)(options.agentCard, options.resolveAgentCardOptions) : await (0, import_agent_card.getA2AAgentCard)(agent, [
|
|
91
91
|
{
|
|
92
92
|
url: `${rpcUrl}/jsonrpc`,
|
|
93
93
|
transport: "JSONRPC"
|
|
@@ -0,0 +1,172 @@
|
|
|
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 agent_engine_client_exports = {};
|
|
27
|
+
__export(agent_engine_client_exports, {
|
|
28
|
+
AgentEngineClient: () => AgentEngineClient,
|
|
29
|
+
AgentExecutionError: () => AgentExecutionError
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(agent_engine_client_exports);
|
|
32
|
+
var import_aiplatform = require("@google-cloud/aiplatform");
|
|
33
|
+
/**
|
|
34
|
+
* @license
|
|
35
|
+
* Copyright 2026 Google LLC
|
|
36
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
37
|
+
*/
|
|
38
|
+
const _AgentExecutionError = class _AgentExecutionError extends Error {
|
|
39
|
+
constructor(message, cause) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.cause = cause;
|
|
42
|
+
this.name = "AgentExecutionError";
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
__name(_AgentExecutionError, "AgentExecutionError");
|
|
46
|
+
let AgentExecutionError = _AgentExecutionError;
|
|
47
|
+
function buildInputStruct(config) {
|
|
48
|
+
var _a;
|
|
49
|
+
const value = import_aiplatform.helpers.toValue(config);
|
|
50
|
+
return (_a = value == null ? void 0 : value.structValue) != null ? _a : void 0;
|
|
51
|
+
}
|
|
52
|
+
__name(buildInputStruct, "buildInputStruct");
|
|
53
|
+
function parseOutput(output) {
|
|
54
|
+
return import_aiplatform.helpers.fromValue(output);
|
|
55
|
+
}
|
|
56
|
+
__name(parseOutput, "parseOutput");
|
|
57
|
+
function parseFragment(line) {
|
|
58
|
+
const trimmed = line.trim();
|
|
59
|
+
if (!trimmed) return void 0;
|
|
60
|
+
const payload = trimmed.startsWith("data:") ? trimmed.slice(5).trim() : trimmed;
|
|
61
|
+
if (payload === "[DONE]") return void 0;
|
|
62
|
+
try {
|
|
63
|
+
return JSON.parse(payload);
|
|
64
|
+
} catch (e) {
|
|
65
|
+
throw new AgentExecutionError(
|
|
66
|
+
`Failed to parse stream fragment: ${payload}`,
|
|
67
|
+
e
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
__name(parseFragment, "parseFragment");
|
|
72
|
+
async function* parseStream(stream) {
|
|
73
|
+
let buffer = "";
|
|
74
|
+
for await (const chunk of stream) {
|
|
75
|
+
const chunkData = chunk == null ? void 0 : chunk.data;
|
|
76
|
+
if (chunkData === void 0) {
|
|
77
|
+
if (typeof chunk === "object" && chunk !== null) {
|
|
78
|
+
yield chunk;
|
|
79
|
+
}
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const dataStr = chunkData instanceof Uint8Array ? new TextDecoder().decode(chunkData) : String(chunkData);
|
|
83
|
+
buffer += dataStr;
|
|
84
|
+
const lines = buffer.split("\n");
|
|
85
|
+
buffer = lines.pop() || "";
|
|
86
|
+
for (const line of lines) {
|
|
87
|
+
const fragment = parseFragment(line);
|
|
88
|
+
if (fragment !== void 0) {
|
|
89
|
+
yield fragment;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const last = parseFragment(buffer);
|
|
94
|
+
if (last !== void 0) {
|
|
95
|
+
yield last;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
__name(parseStream, "parseStream");
|
|
99
|
+
const _AgentEngineClient = class _AgentEngineClient {
|
|
100
|
+
constructor(config) {
|
|
101
|
+
this.client = new import_aiplatform.v1.ReasoningEngineExecutionServiceClient({
|
|
102
|
+
apiEndpoint: `${config.location}-aiplatform.googleapis.com`
|
|
103
|
+
});
|
|
104
|
+
this.reasoningEnginePath = this.client.reasoningEnginePath(
|
|
105
|
+
config.project,
|
|
106
|
+
config.location,
|
|
107
|
+
config.reasoningEngineId
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Creates a remote session.
|
|
112
|
+
*
|
|
113
|
+
* @returns The `create_session` payload returned by the Agent Engine. When
|
|
114
|
+
* `config.sessionId` is omitted the engine generates one, and this is the
|
|
115
|
+
* only place the caller can read it back from.
|
|
116
|
+
*/
|
|
117
|
+
async createSession(config) {
|
|
118
|
+
try {
|
|
119
|
+
const [response] = await this.client.queryReasoningEngine({
|
|
120
|
+
name: this.reasoningEnginePath,
|
|
121
|
+
classMethod: "create_session",
|
|
122
|
+
input: buildInputStruct(config)
|
|
123
|
+
});
|
|
124
|
+
return response.output ? parseOutput(response.output) : void 0;
|
|
125
|
+
} catch (err) {
|
|
126
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
127
|
+
throw new AgentExecutionError(
|
|
128
|
+
`Failed to create session: ${message}`,
|
|
129
|
+
err
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
async query(config) {
|
|
134
|
+
try {
|
|
135
|
+
const [response] = await this.client.queryReasoningEngine({
|
|
136
|
+
name: this.reasoningEnginePath,
|
|
137
|
+
classMethod: "query",
|
|
138
|
+
input: buildInputStruct(config)
|
|
139
|
+
});
|
|
140
|
+
return response.output ? parseOutput(response.output) : void 0;
|
|
141
|
+
} catch (err) {
|
|
142
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
143
|
+
throw new AgentExecutionError(`Failed to execute query: ${message}`, err);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async *streamQuery(config) {
|
|
147
|
+
try {
|
|
148
|
+
const stream = this.client.streamQueryReasoningEngine({
|
|
149
|
+
name: this.reasoningEnginePath,
|
|
150
|
+
classMethod: "query",
|
|
151
|
+
input: buildInputStruct(config)
|
|
152
|
+
});
|
|
153
|
+
yield* parseStream(stream);
|
|
154
|
+
} catch (err) {
|
|
155
|
+
if (err instanceof AgentExecutionError) {
|
|
156
|
+
throw err;
|
|
157
|
+
}
|
|
158
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
159
|
+
throw new AgentExecutionError(
|
|
160
|
+
`Failed to execute stream query: ${message}`,
|
|
161
|
+
err
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
__name(_AgentEngineClient, "AgentEngineClient");
|
|
167
|
+
let AgentEngineClient = _AgentEngineClient;
|
|
168
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
169
|
+
0 && (module.exports = {
|
|
170
|
+
AgentEngineClient,
|
|
171
|
+
AgentExecutionError
|
|
172
|
+
});
|
|
@@ -259,6 +259,22 @@ const _BaseAgent = class _BaseAgent extends (_b = import_base_node.BaseNode, _a
|
|
|
259
259
|
agent: this
|
|
260
260
|
});
|
|
261
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* The resolved beforeAgentCallback field as a list of SingleAgentCallback.
|
|
264
|
+
*
|
|
265
|
+
* This method is only for use by Agent Development Kit.
|
|
266
|
+
*/
|
|
267
|
+
get canonicalBeforeAgentCallbacks() {
|
|
268
|
+
return this.beforeAgentCallback;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* The resolved afterAgentCallback field as a list of SingleAgentCallback.
|
|
272
|
+
*
|
|
273
|
+
* This method is only for use by Agent Development Kit.
|
|
274
|
+
*/
|
|
275
|
+
get canonicalAfterAgentCallbacks() {
|
|
276
|
+
return this.afterAgentCallback;
|
|
277
|
+
}
|
|
262
278
|
/**
|
|
263
279
|
* Runs the before agent callback if it exists.
|
|
264
280
|
*
|
|
@@ -268,11 +284,11 @@ const _BaseAgent = class _BaseAgent extends (_b = import_base_node.BaseNode, _a
|
|
|
268
284
|
*/
|
|
269
285
|
async handleBeforeAgentCallback(invocationContext) {
|
|
270
286
|
var _a2;
|
|
271
|
-
if (this.
|
|
287
|
+
if (this.canonicalBeforeAgentCallbacks.length === 0) {
|
|
272
288
|
return void 0;
|
|
273
289
|
}
|
|
274
290
|
const callbackContext = new import_context.Context({ invocationContext });
|
|
275
|
-
for (const callback of this.
|
|
291
|
+
for (const callback of this.canonicalBeforeAgentCallbacks) {
|
|
276
292
|
const content = await callback(callbackContext);
|
|
277
293
|
if ((_a2 = invocationContext.abortSignal) == null ? void 0 : _a2.aborted) {
|
|
278
294
|
return;
|
|
@@ -307,11 +323,11 @@ const _BaseAgent = class _BaseAgent extends (_b = import_base_node.BaseNode, _a
|
|
|
307
323
|
*/
|
|
308
324
|
async handleAfterAgentCallback(invocationContext) {
|
|
309
325
|
var _a2;
|
|
310
|
-
if (this.
|
|
326
|
+
if (this.canonicalAfterAgentCallbacks.length === 0) {
|
|
311
327
|
return void 0;
|
|
312
328
|
}
|
|
313
329
|
const callbackContext = new import_context.Context({ invocationContext });
|
|
314
|
-
for (const callback of this.
|
|
330
|
+
for (const callback of this.canonicalAfterAgentCallbacks) {
|
|
315
331
|
const content = await callback(callbackContext);
|
|
316
332
|
if ((_a2 = invocationContext.abortSignal) == null ? void 0 : _a2.aborted) {
|
|
317
333
|
return;
|