@google/adk 2.3.0 → 2.5.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 +17 -2
- package/dist/cjs/a2a/a2a_remote_agent_utils.js +8 -4
- package/dist/cjs/a2a/agent_card.js +5 -81
- package/dist/cjs/a2a/agent_to_a2a.js +7 -0
- package/dist/cjs/a2a/event_converter_utils.js +10 -3
- package/dist/cjs/agents/agent_engine_client.js +399 -0
- package/dist/cjs/agents/base_agent.js +127 -68
- package/dist/cjs/agents/functions.js +64 -59
- package/dist/cjs/agents/instructions.js +8 -6
- package/dist/cjs/agents/invocation_context.js +2 -2
- package/dist/cjs/agents/llm_agent.js +124 -101
- package/dist/cjs/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/code_execution_request_processor.js +8 -0
- package/dist/cjs/agents/processors/content_processor_utils.js +72 -17
- package/dist/cjs/agents/processors/content_request_processor.js +51 -2
- package/dist/cjs/agents/processors/context_compactor_request_processor.js +5 -1
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/nl_planning_processor.js +13 -3
- package/dist/cjs/artifacts/file_artifact_service.js +1 -1
- package/dist/cjs/cli/cli_eval.js +884 -17
- package/dist/cjs/cli/utils/cleanup.js +84 -0
- package/dist/cjs/cli/utils/envs.js +33 -2
- package/dist/cjs/cli/utils/evals.js +75 -8
- package/dist/cjs/cli/utils/logs.js +134 -15
- package/dist/cjs/cli/utils/path_validation.js +83 -0
- package/dist/cjs/code_executors/container_code_executor.js +171 -38
- package/dist/cjs/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/cjs/common.js +59 -32
- package/dist/cjs/context/compaction_utils.js +19 -0
- package/dist/cjs/errors/input_validation_error.js +3 -2
- package/dist/cjs/events/event.js +7 -3
- package/dist/cjs/features/feature_registry.js +5 -0
- package/dist/cjs/index.js +34 -12
- package/dist/cjs/models/google_llm.js +33 -2
- package/dist/cjs/models/interactions_utils.js +3 -0
- package/dist/cjs/plugins/base_plugin.js +54 -40
- package/dist/cjs/plugins/plugin_manager.js +27 -0
- package/dist/cjs/runner/runner.js +306 -189
- package/dist/cjs/sessions/base_session_service.js +15 -12
- package/dist/cjs/sessions/database_session_service.js +232 -38
- package/dist/cjs/sessions/db/operations.js +70 -1
- package/dist/cjs/sessions/db/schema.js +4 -0
- package/dist/cjs/sessions/in_memory_session_service.js +2 -2
- package/dist/cjs/sessions/stale_session_error.js +59 -0
- package/dist/cjs/sessions/vertex_ai_session_service.js +11 -3
- package/dist/cjs/skills/loader.js +76 -41
- package/dist/cjs/telemetry/api/instrumentation.js +632 -0
- package/dist/cjs/telemetry/api/internal/common/accumulators.js +169 -0
- package/dist/cjs/telemetry/api/internal/common/attributes.js +131 -0
- package/dist/cjs/telemetry/api/internal/common/config.js +159 -0
- package/dist/cjs/telemetry/api/internal/common/error.js +98 -0
- package/dist/cjs/telemetry/api/internal/common/finish_reason.js +63 -0
- package/dist/cjs/telemetry/api/internal/common/genai_messages.js +217 -0
- package/dist/cjs/telemetry/api/internal/common/http_exchange.js +169 -0
- package/dist/cjs/telemetry/api/internal/common/provider_name.js +87 -0
- package/dist/cjs/telemetry/api/internal/common/redaction.js +148 -0
- package/dist/cjs/telemetry/api/internal/common/serialization.js +58 -0
- package/dist/cjs/telemetry/api/internal/common/token_usage.js +118 -0
- package/dist/cjs/telemetry/api/internal/logs/inference.js +50 -0
- package/dist/cjs/telemetry/api/internal/logs/logger.js +46 -0
- package/dist/cjs/telemetry/api/internal/logs/mcp.js +141 -0
- package/dist/cjs/telemetry/api/internal/metrics/agent.js +128 -0
- package/dist/cjs/telemetry/api/internal/metrics/inference_start_hook.js +56 -0
- package/dist/cjs/telemetry/api/internal/metrics/meters.js +189 -0
- package/dist/cjs/telemetry/api/internal/metrics/tool.js +147 -0
- package/dist/cjs/telemetry/api/internal/metrics/workflow.js +132 -0
- package/dist/cjs/telemetry/api/internal/trace/agent.js +52 -0
- package/dist/cjs/telemetry/api/internal/trace/compaction.js +78 -0
- package/dist/cjs/telemetry/api/internal/trace/inference.js +132 -0
- package/dist/cjs/telemetry/api/internal/trace/live.js +52 -0
- package/dist/cjs/telemetry/api/internal/trace/node.js +73 -0
- package/dist/cjs/telemetry/api/internal/trace/propagation.js +67 -0
- package/dist/cjs/telemetry/api/internal/trace/tool.js +122 -0
- package/dist/cjs/telemetry/api/internal/trace/tracer.js +77 -0
- package/dist/cjs/telemetry/api/internal/trace/workflow.js +77 -0
- package/dist/cjs/telemetry/export/agent_engine.js +90 -0
- package/dist/cjs/telemetry/export/agent_runtime.js +73 -0
- package/dist/cjs/telemetry/export/google_cloud.js +763 -0
- package/dist/cjs/telemetry/export/request_driven_metric_reader.js +303 -0
- package/dist/cjs/telemetry/{setup.js → export/setup.js} +72 -6
- package/dist/cjs/tools/agent_tool.js +9 -1
- package/dist/cjs/tools/apihub_tool/apihub_toolset.js +18 -23
- package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +109 -43
- package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +222 -114
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +34 -14
- package/dist/cjs/tools/application_integration_tool/integration_connector_tool.js +175 -0
- package/dist/cjs/tools/base_toolset.js +1 -1
- package/dist/cjs/tools/computer_use/base_computer.js +125 -0
- package/dist/cjs/tools/computer_use/computer_use_actions.js +502 -0
- package/dist/cjs/tools/computer_use/computer_use_tool.js +244 -0
- package/dist/cjs/tools/computer_use/computer_use_toolset.js +360 -0
- package/dist/cjs/tools/function_tool.js +15 -5
- package/dist/cjs/tools/google_api_tool/google_api_tool.js +4 -1
- package/dist/cjs/tools/google_api_tool/google_api_toolset.js +174 -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 +5 -3
- package/dist/cjs/tools/google_api_tool/index.js +20 -23
- package/dist/cjs/tools/load_artifacts_tool.js +27 -11
- package/dist/cjs/tools/load_memory_tool.js +14 -15
- package/dist/cjs/tools/mcp/mcp_session_manager.js +23 -3
- package/dist/cjs/tools/mcp/mcp_tool.js +7 -3
- package/dist/cjs/tools/mcp/mcp_toolset.js +19 -20
- package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +30 -29
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +4 -4
- 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_toolset.js +7 -13
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +57 -10
- package/dist/cjs/tools/skill/load_skill_resource_tool.js +7 -0
- package/dist/cjs/tools/skill/load_skill_tool.js +3 -0
- package/dist/cjs/tools/skill/run_skill_script_tool.js +12 -2
- package/dist/cjs/tools/toolbox_toolset.js +193 -0
- package/dist/cjs/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/cjs/utils/async_queue.js +37 -3
- package/dist/cjs/utils/client_labels.js +17 -2
- package/dist/cjs/utils/env_aware_utils.js +13 -7
- package/dist/cjs/utils/error_utils.js +40 -2
- package/dist/cjs/utils/failover_utils.js +11 -10
- package/dist/cjs/utils/gemini_schema_util.js +145 -14
- package/dist/cjs/utils/id_provider.js +63 -0
- package/dist/cjs/utils/logger_node.js +4 -0
- package/dist/cjs/utils/model_name.js +15 -0
- package/dist/cjs/utils/output_schema_utils.js +5 -2
- package/dist/cjs/utils/simple_zod_to_json.js +13 -31
- package/dist/cjs/utils/ssrf_guard.js +46 -16
- package/dist/cjs/utils/task.js +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/workflow/index.js +2 -0
- package/dist/cjs/workflow/node_runner.js +24 -80
- package/dist/cjs/workflow/nodes/parallel_worker.js +18 -7
- package/dist/cjs/workflow/run_llm_agent_as_node.js +19 -14
- package/dist/cjs/workflow/utils/retry_utils.js +2 -2
- package/dist/cjs/workflow/workflow.js +12 -12
- package/dist/esm/a2a/a2a_remote_agent.js +23 -3
- package/dist/esm/a2a/a2a_remote_agent_utils.js +8 -4
- package/dist/esm/a2a/agent_card.js +5 -83
- package/dist/esm/a2a/agent_to_a2a.js +7 -0
- package/dist/esm/a2a/event_converter_utils.js +10 -3
- package/dist/esm/agents/agent_engine_client.js +382 -0
- package/dist/esm/agents/base_agent.js +127 -72
- package/dist/esm/agents/functions.js +69 -63
- package/dist/esm/agents/instructions.js +8 -6
- package/dist/esm/agents/invocation_context.js +2 -2
- package/dist/esm/agents/llm_agent.js +130 -106
- package/dist/esm/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/code_execution_request_processor.js +8 -0
- package/dist/esm/agents/processors/content_processor_utils.js +72 -17
- package/dist/esm/agents/processors/content_request_processor.js +51 -2
- package/dist/esm/agents/processors/context_compactor_request_processor.js +5 -1
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/nl_planning_processor.js +13 -3
- package/dist/esm/artifacts/file_artifact_service.js +1 -1
- package/dist/esm/cli/cli_eval.js +880 -17
- package/dist/esm/cli/utils/cleanup.js +56 -0
- package/dist/esm/cli/utils/envs.js +33 -2
- package/dist/esm/cli/utils/evals.js +74 -8
- package/dist/esm/cli/utils/logs.js +132 -13
- package/dist/esm/cli/utils/path_validation.js +45 -0
- package/dist/esm/code_executors/container_code_executor.js +171 -38
- package/dist/esm/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/esm/common.js +59 -19
- package/dist/esm/context/compaction_utils.js +19 -0
- package/dist/esm/errors/input_validation_error.js +3 -2
- package/dist/esm/events/event.js +7 -3
- package/dist/esm/features/feature_registry.js +5 -0
- package/dist/esm/index.js +36 -10
- package/dist/esm/models/google_llm.js +33 -2
- package/dist/esm/models/interactions_utils.js +3 -0
- package/dist/esm/plugins/base_plugin.js +54 -40
- package/dist/esm/plugins/plugin_manager.js +27 -0
- package/dist/esm/runner/runner.js +310 -192
- package/dist/esm/sessions/base_session_service.js +13 -11
- package/dist/esm/sessions/database_session_service.js +231 -38
- package/dist/esm/sessions/db/operations.js +70 -1
- package/dist/esm/sessions/db/schema.js +4 -0
- package/dist/esm/sessions/in_memory_session_service.js +2 -2
- package/dist/esm/sessions/stale_session_error.js +31 -0
- package/dist/esm/sessions/vertex_ai_session_service.js +11 -3
- package/dist/esm/skills/loader.js +76 -41
- package/dist/esm/telemetry/api/instrumentation.js +655 -0
- package/dist/esm/telemetry/api/internal/common/accumulators.js +139 -0
- package/dist/esm/telemetry/api/internal/common/attributes.js +94 -0
- package/dist/esm/telemetry/api/internal/common/config.js +128 -0
- package/dist/esm/telemetry/api/internal/common/error.js +69 -0
- package/dist/esm/telemetry/api/internal/common/finish_reason.js +35 -0
- package/dist/esm/telemetry/api/internal/common/genai_messages.js +188 -0
- package/dist/esm/telemetry/api/internal/common/http_exchange.js +142 -0
- package/dist/esm/telemetry/api/internal/common/provider_name.js +59 -0
- package/dist/esm/telemetry/api/internal/common/redaction.js +121 -0
- package/dist/esm/telemetry/api/internal/common/serialization.js +30 -0
- package/dist/esm/telemetry/api/internal/common/token_usage.js +85 -0
- package/dist/esm/telemetry/api/internal/logs/inference.js +23 -0
- package/dist/esm/telemetry/api/internal/logs/logger.js +19 -0
- package/dist/esm/telemetry/api/internal/logs/mcp.js +113 -0
- package/dist/esm/telemetry/api/internal/metrics/agent.js +107 -0
- package/dist/esm/telemetry/api/internal/metrics/inference_start_hook.js +29 -0
- package/dist/esm/telemetry/api/internal/metrics/meters.js +165 -0
- package/dist/esm/telemetry/api/internal/metrics/tool.js +119 -0
- package/dist/esm/telemetry/api/internal/metrics/workflow.js +112 -0
- package/dist/esm/telemetry/api/internal/trace/agent.js +25 -0
- package/dist/esm/telemetry/api/internal/trace/compaction.js +50 -0
- package/dist/esm/telemetry/api/internal/trace/inference.js +107 -0
- package/dist/esm/telemetry/api/internal/trace/live.js +28 -0
- package/dist/esm/telemetry/api/internal/trace/node.js +44 -0
- package/dist/esm/telemetry/api/internal/trace/propagation.js +39 -0
- package/dist/esm/telemetry/api/internal/trace/tool.js +96 -0
- package/dist/esm/telemetry/api/internal/trace/tracer.js +52 -0
- package/dist/esm/telemetry/api/internal/trace/workflow.js +54 -0
- package/dist/esm/telemetry/export/agent_engine.js +67 -0
- package/dist/esm/telemetry/export/agent_runtime.js +46 -0
- package/dist/esm/telemetry/export/google_cloud.js +733 -0
- package/dist/esm/telemetry/export/request_driven_metric_reader.js +276 -0
- package/dist/esm/telemetry/export/setup.js +160 -0
- package/dist/esm/tools/agent_tool.js +9 -1
- package/dist/esm/tools/apihub_tool/apihub_toolset.js +17 -22
- package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +114 -44
- package/dist/esm/tools/application_integration_tool/clients/connections_client.js +226 -115
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +34 -14
- package/dist/esm/tools/application_integration_tool/integration_connector_tool.js +149 -0
- package/dist/esm/tools/base_toolset.js +1 -1
- package/dist/esm/tools/computer_use/base_computer.js +99 -0
- package/dist/esm/tools/computer_use/computer_use_actions.js +477 -0
- package/dist/esm/tools/computer_use/computer_use_tool.js +217 -0
- package/dist/esm/tools/computer_use/computer_use_toolset.js +344 -0
- package/dist/esm/tools/function_tool.js +15 -5
- package/dist/esm/tools/google_api_tool/google_api_tool.js +4 -1
- package/dist/esm/tools/google_api_tool/google_api_toolset.js +147 -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 +5 -3
- package/dist/esm/tools/google_api_tool/index.js +18 -20
- package/dist/esm/tools/load_artifacts_tool.js +25 -10
- package/dist/esm/tools/load_memory_tool.js +14 -15
- package/dist/esm/tools/mcp/mcp_session_manager.js +23 -3
- package/dist/esm/tools/mcp/mcp_tool.js +7 -3
- package/dist/esm/tools/mcp/mcp_toolset.js +19 -20
- package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +27 -26
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +4 -4
- 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_toolset.js +6 -12
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +57 -10
- package/dist/esm/tools/skill/load_skill_resource_tool.js +7 -0
- package/dist/esm/tools/skill/load_skill_tool.js +3 -0
- package/dist/esm/tools/skill/run_skill_script_tool.js +12 -2
- package/dist/esm/tools/toolbox_toolset.js +167 -0
- package/dist/esm/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/esm/utils/async_queue.js +37 -3
- package/dist/esm/utils/client_labels.js +17 -2
- package/dist/esm/utils/env_aware_utils.js +12 -7
- package/dist/esm/utils/error_utils.js +37 -1
- package/dist/esm/utils/failover_utils.js +11 -10
- package/dist/esm/utils/gemini_schema_util.js +144 -14
- package/dist/esm/utils/id_provider.js +33 -0
- package/dist/esm/utils/logger_node.js +4 -0
- package/dist/esm/utils/model_name.js +14 -0
- package/dist/esm/utils/output_schema_utils.js +5 -2
- package/dist/esm/utils/simple_zod_to_json.js +13 -31
- package/dist/esm/utils/ssrf_guard.js +55 -15
- package/dist/esm/utils/task.js +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/workflow/index.js +2 -1
- package/dist/esm/workflow/node_runner.js +26 -80
- package/dist/esm/workflow/nodes/parallel_worker.js +16 -6
- package/dist/esm/workflow/run_llm_agent_as_node.js +19 -14
- package/dist/esm/workflow/utils/retry_utils.js +2 -2
- package/dist/esm/workflow/workflow.js +12 -12
- package/dist/types/a2a/a2a_remote_agent.d.ts +6 -0
- package/dist/types/a2a/a2a_remote_agent_utils.d.ts +3 -2
- package/dist/types/agents/agent_engine_client.d.ts +155 -0
- package/dist/types/agents/base_agent.d.ts +14 -0
- package/dist/types/agents/llm_agent.d.ts +5 -1
- package/dist/types/agents/processors/content_processor_utils.d.ts +12 -10
- package/dist/types/agents/processors/nl_planning_processor.d.ts +2 -1
- package/dist/types/agents/run_config.d.ts +14 -0
- package/dist/types/cli/cli_eval.d.ts +172 -9
- package/dist/types/cli/utils/cleanup.d.ts +18 -0
- package/dist/types/cli/utils/envs.d.ts +13 -3
- package/dist/types/cli/utils/evals.d.ts +64 -1
- package/dist/types/cli/utils/logs.d.ts +20 -3
- package/dist/types/cli/utils/path_validation.d.ts +30 -0
- package/dist/types/code_executors/container_code_executor.d.ts +62 -9
- package/dist/types/common.d.ts +21 -18
- package/dist/types/context/compaction_utils.d.ts +13 -1
- package/dist/types/errors/input_validation_error.d.ts +2 -1
- package/dist/types/events/event.d.ts +3 -0
- package/dist/types/features/feature_registry.d.ts +1 -0
- package/dist/types/index.d.ts +11 -6
- package/dist/types/plugins/base_plugin.d.ts +50 -31
- package/dist/types/plugins/plugin_manager.d.ts +13 -0
- package/dist/types/runner/runner.d.ts +11 -0
- package/dist/types/sessions/base_session_service.d.ts +5 -2
- package/dist/types/sessions/database_session_service.d.ts +17 -1
- package/dist/types/sessions/db/operations.d.ts +2 -1
- package/dist/types/sessions/db/schema.d.ts +5 -3
- package/dist/types/sessions/stale_session_error.d.ts +21 -0
- package/dist/types/skills/loader.d.ts +3 -2
- package/dist/types/telemetry/api/instrumentation.d.ts +259 -0
- package/dist/types/telemetry/api/internal/common/accumulators.d.ts +91 -0
- package/dist/types/telemetry/api/internal/common/attributes.d.ts +90 -0
- package/dist/types/telemetry/api/internal/common/config.d.ts +61 -0
- package/dist/types/telemetry/api/internal/common/error.d.ts +29 -0
- package/dist/types/telemetry/api/internal/common/finish_reason.d.ts +18 -0
- package/dist/types/telemetry/api/internal/common/genai_messages.d.ts +26 -0
- package/dist/types/telemetry/api/internal/common/http_exchange.d.ts +50 -0
- package/dist/types/telemetry/api/internal/common/provider_name.d.ts +16 -0
- package/dist/types/telemetry/api/internal/common/redaction.d.ts +14 -0
- package/dist/types/telemetry/api/internal/common/serialization.d.ts +18 -0
- package/dist/types/telemetry/api/internal/common/token_usage.d.ts +47 -0
- package/dist/types/telemetry/api/internal/logs/inference.d.ts +15 -0
- package/dist/types/telemetry/api/internal/logs/logger.d.ts +13 -0
- package/dist/types/telemetry/api/internal/logs/mcp.d.ts +31 -0
- package/dist/types/telemetry/api/internal/metrics/agent.d.ts +28 -0
- package/dist/types/telemetry/api/internal/metrics/inference_start_hook.d.ts +12 -0
- package/dist/types/telemetry/api/internal/metrics/meters.d.ts +57 -0
- package/dist/types/telemetry/api/internal/metrics/tool.d.ts +44 -0
- package/dist/types/telemetry/api/internal/metrics/workflow.d.ts +32 -0
- package/dist/types/telemetry/api/internal/trace/agent.d.ts +14 -0
- package/dist/types/telemetry/api/internal/trace/compaction.d.ts +20 -0
- package/dist/types/telemetry/api/internal/trace/inference.d.ts +31 -0
- package/dist/types/telemetry/api/internal/trace/live.d.ts +21 -0
- package/dist/types/telemetry/api/internal/trace/node.d.ts +22 -0
- package/dist/types/telemetry/api/internal/trace/propagation.d.ts +22 -0
- package/dist/types/telemetry/api/internal/trace/tool.d.ts +57 -0
- package/dist/types/telemetry/api/internal/trace/tracer.d.ts +31 -0
- package/dist/types/telemetry/api/internal/trace/workflow.d.ts +21 -0
- package/dist/types/telemetry/export/agent_engine.d.ts +23 -0
- package/dist/types/telemetry/export/agent_runtime.d.ts +40 -0
- package/dist/types/telemetry/export/google_cloud.d.ts +189 -0
- package/dist/types/telemetry/export/request_driven_metric_reader.d.ts +144 -0
- package/dist/types/telemetry/{setup.d.ts → export/setup.d.ts} +3 -0
- package/dist/types/tools/agent_tool.d.ts +1 -1
- package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +14 -21
- package/dist/types/tools/application_integration_tool/application_integration_toolset.d.ts +32 -9
- package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +35 -12
- package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +3 -3
- package/dist/types/tools/application_integration_tool/integration_connector_tool.d.ts +70 -0
- package/dist/types/tools/base_toolset.d.ts +7 -6
- package/dist/types/tools/computer_use/base_computer.d.ts +281 -0
- package/dist/types/tools/computer_use/computer_use_actions.d.ts +53 -0
- package/dist/types/tools/computer_use/computer_use_tool.d.ts +108 -0
- package/dist/types/tools/computer_use/computer_use_toolset.d.ts +132 -0
- package/dist/types/tools/google_api_tool/google_api_tool.d.ts +10 -3
- package/dist/types/tools/google_api_tool/google_api_toolset.d.ts +57 -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 +5 -4
- package/dist/types/tools/google_api_tool/index.d.ts +4 -5
- package/dist/types/tools/load_artifacts_tool.d.ts +18 -1
- package/dist/types/tools/load_memory_tool.d.ts +32 -4
- package/dist/types/tools/mcp/mcp_session_manager.d.ts +16 -0
- package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +8 -8
- 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 +15 -3
- 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/toolbox_toolset.d.ts +154 -0
- package/dist/types/utils/async_queue.d.ts +14 -0
- package/dist/types/utils/client_labels.d.ts +2 -1
- package/dist/types/utils/env_aware_utils.d.ts +11 -0
- package/dist/types/utils/error_utils.d.ts +4 -0
- package/dist/types/utils/gemini_schema_util.d.ts +29 -0
- package/dist/types/utils/id_provider.d.ts +43 -0
- package/dist/types/utils/model_name.d.ts +8 -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/ssrf_guard.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types/workflow/index.d.ts +1 -1
- package/dist/types/workflow/nodes/parallel_worker.d.ts +8 -1
- package/dist/web/index_web.js +94 -88
- package/dist/web/index_web.js.map +4 -4
- package/package.json +43 -38
- package/dist/cjs/agents/remote_agent.js +0 -187
- package/dist/cjs/telemetry/google_cloud.js +0 -116
- package/dist/cjs/telemetry/tracing.js +0 -350
- package/dist/cjs/tools/crewai_tool.js +0 -132
- package/dist/cjs/tools/google_api_tool/google_api_tool_set.js +0 -226
- package/dist/cjs/tools/google_api_tool/google_api_tool_sets.js +0 -58
- package/dist/cjs/tools/langchain_tool.js +0 -172
- package/dist/cjs/tools/toolbox_tool.js +0 -108
- package/dist/esm/agents/remote_agent.js +0 -164
- package/dist/esm/telemetry/google_cloud.js +0 -99
- package/dist/esm/telemetry/setup.js +0 -89
- package/dist/esm/telemetry/tracing.js +0 -315
- package/dist/esm/tools/crewai_tool.js +0 -107
- package/dist/esm/tools/google_api_tool/google_api_tool_set.js +0 -188
- package/dist/esm/tools/google_api_tool/google_api_tool_sets.js +0 -24
- package/dist/esm/tools/langchain_tool.js +0 -148
- package/dist/esm/tools/toolbox_tool.js +0 -80
- package/dist/types/agents/remote_agent.d.ts +0 -68
- package/dist/types/telemetry/google_cloud.d.ts +0 -9
- package/dist/types/telemetry/tracing.d.ts +0 -129
- package/dist/types/tools/crewai_tool.d.ts +0 -85
- package/dist/types/tools/google_api_tool/google_api_tool_set.d.ts +0 -78
- package/dist/types/tools/google_api_tool/google_api_tool_sets.d.ts +0 -33
- package/dist/types/tools/langchain_tool.d.ts +0 -103
- package/dist/types/tools/toolbox_tool.d.ts +0 -73
|
@@ -33,6 +33,7 @@ var import_sdk = require("@a2a-js/sdk");
|
|
|
33
33
|
var import_client = require("@a2a-js/sdk/client");
|
|
34
34
|
var import_base_agent = require("../agents/base_agent.js");
|
|
35
35
|
var import_event = require("../events/event.js");
|
|
36
|
+
var import_instrumentation = require("../telemetry/api/instrumentation.js");
|
|
36
37
|
var import_env_aware_utils = require("../utils/env_aware_utils.js");
|
|
37
38
|
var import_logger = require("../utils/logger.js");
|
|
38
39
|
var import_a2a_event = require("./a2a_event.js");
|
|
@@ -46,6 +47,18 @@ var import_metadata_converter_utils = require("./metadata_converter_utils.js");
|
|
|
46
47
|
* Copyright 2026 Google LLC
|
|
47
48
|
* SPDX-License-Identifier: Apache-2.0
|
|
48
49
|
*/
|
|
50
|
+
function createTracePropagatingClientFactory() {
|
|
51
|
+
const fetchImpl = (0, import_instrumentation.propagateTraceContext)();
|
|
52
|
+
return new import_client.ClientFactory(
|
|
53
|
+
import_client.ClientFactoryOptions.createFrom(import_client.ClientFactoryOptions.default, {
|
|
54
|
+
transports: [
|
|
55
|
+
new import_client.JsonRpcTransportFactory({ fetchImpl }),
|
|
56
|
+
new import_client.RestTransportFactory({ fetchImpl })
|
|
57
|
+
]
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
__name(createTracePropagatingClientFactory, "createTracePropagatingClientFactory");
|
|
49
62
|
const _RemoteA2AAgent = class _RemoteA2AAgent extends import_base_agent.BaseAgent {
|
|
50
63
|
constructor(a2aConfig) {
|
|
51
64
|
super(a2aConfig);
|
|
@@ -56,6 +69,7 @@ const _RemoteA2AAgent = class _RemoteA2AAgent extends import_base_agent.BaseAgen
|
|
|
56
69
|
}
|
|
57
70
|
}
|
|
58
71
|
async init() {
|
|
72
|
+
var _a;
|
|
59
73
|
if (this.isInitialized) {
|
|
60
74
|
return;
|
|
61
75
|
}
|
|
@@ -68,7 +82,7 @@ const _RemoteA2AAgent = class _RemoteA2AAgent extends import_base_agent.BaseAgen
|
|
|
68
82
|
this.a2aConfig.resolveAgentCardOptions
|
|
69
83
|
);
|
|
70
84
|
if (!this.client) {
|
|
71
|
-
const factory = this.a2aConfig.clientFactory
|
|
85
|
+
const factory = (_a = this.a2aConfig.clientFactory) != null ? _a : createTracePropagatingClientFactory();
|
|
72
86
|
this.client = await factory.createFromAgentCard(this.card);
|
|
73
87
|
}
|
|
74
88
|
}
|
|
@@ -84,7 +98,8 @@ const _RemoteA2AAgent = class _RemoteA2AAgent extends import_base_agent.BaseAgen
|
|
|
84
98
|
}
|
|
85
99
|
const userFnCall = (0, import_a2a_remote_agent_utils.getUserFunctionCallAt)(
|
|
86
100
|
context.session,
|
|
87
|
-
events.length - 1
|
|
101
|
+
events.length - 1,
|
|
102
|
+
this.name
|
|
88
103
|
);
|
|
89
104
|
let parts;
|
|
90
105
|
let taskId = void 0;
|
|
@@ -46,7 +46,8 @@ var import_part_converter_utils = require("./part_converter_utils.js");
|
|
|
46
46
|
* Copyright 2026 Google LLC
|
|
47
47
|
* SPDX-License-Identifier: Apache-2.0
|
|
48
48
|
*/
|
|
49
|
-
function getUserFunctionCallAt(session, index) {
|
|
49
|
+
function getUserFunctionCallAt(session, index, agentName) {
|
|
50
|
+
var _a, _b;
|
|
50
51
|
const events = session.events;
|
|
51
52
|
if (index < 0 || index >= events.length) {
|
|
52
53
|
return void 0;
|
|
@@ -55,13 +56,16 @@ function getUserFunctionCallAt(session, index) {
|
|
|
55
56
|
if (candidate.author !== "user") {
|
|
56
57
|
return void 0;
|
|
57
58
|
}
|
|
58
|
-
const
|
|
59
|
-
|
|
59
|
+
const fnCallIds = (_b = (_a = candidate.content) == null ? void 0 : _a.parts) == null ? void 0 : _b.map((part) => {
|
|
60
|
+
var _a2;
|
|
61
|
+
return (_a2 = part.functionResponse) == null ? void 0 : _a2.id;
|
|
62
|
+
}).filter((id) => !!id);
|
|
63
|
+
if (!(fnCallIds == null ? void 0 : fnCallIds.length)) {
|
|
60
64
|
return void 0;
|
|
61
65
|
}
|
|
62
66
|
for (let i = index - 1; i >= 0; i--) {
|
|
63
67
|
const request = events[i];
|
|
64
|
-
if (!isFunctionCallEvent(request,
|
|
68
|
+
if (request.author !== agentName || !fnCallIds.some((callId) => isFunctionCallEvent(request, callId))) {
|
|
65
69
|
continue;
|
|
66
70
|
}
|
|
67
71
|
const metadata = request.customMetadata || {};
|
|
@@ -43,12 +43,11 @@ module.exports = __toCommonJS(agent_card_exports);
|
|
|
43
43
|
var import_client = require("@a2a-js/sdk/client");
|
|
44
44
|
var fs = __toESM(require("node:fs/promises"), 1);
|
|
45
45
|
var import_node_url = require("node:url");
|
|
46
|
-
var import_invocation_context = require("../agents/invocation_context.js");
|
|
47
46
|
var import_llm_agent = require("../agents/llm_agent.js");
|
|
48
47
|
var import_loop_agent = require("../agents/loop_agent.js");
|
|
49
48
|
var import_parallel_agent = require("../agents/parallel_agent.js");
|
|
50
|
-
var import_readonly_context = require("../agents/readonly_context.js");
|
|
51
49
|
var import_sequential_agent = require("../agents/sequential_agent.js");
|
|
50
|
+
var import_instrumentation = require("../telemetry/api/instrumentation.js");
|
|
52
51
|
var import_base_tool = require("../tools/base_tool.js");
|
|
53
52
|
var import_base_toolset = require("../tools/base_toolset.js");
|
|
54
53
|
var import_logger = require("../utils/logger.js");
|
|
@@ -67,7 +66,7 @@ async function resolveAgentCard(agentCard, options = {}) {
|
|
|
67
66
|
if (source.startsWith("http://") || source.startsWith("https://")) {
|
|
68
67
|
await refuseLinkLocalHost(source);
|
|
69
68
|
const resolver = new import_client.DefaultAgentCardResolver({
|
|
70
|
-
fetchImpl:
|
|
69
|
+
fetchImpl: tracePropagatingRefuseRedirectFetch
|
|
71
70
|
});
|
|
72
71
|
const card = await resolver.resolve(source);
|
|
73
72
|
validateCardRpcTargets(card, source, options);
|
|
@@ -107,6 +106,7 @@ async function refuseRedirectFetch(url, init) {
|
|
|
107
106
|
return response;
|
|
108
107
|
}
|
|
109
108
|
__name(refuseRedirectFetch, "refuseRedirectFetch");
|
|
109
|
+
const tracePropagatingRefuseRedirectFetch = (0, import_instrumentation.propagateTraceContext)(refuseRedirectFetch);
|
|
110
110
|
function parseCardUrl(source) {
|
|
111
111
|
let url;
|
|
112
112
|
try {
|
|
@@ -273,7 +273,7 @@ async function buildLLMAgentSkills(agent) {
|
|
|
273
273
|
{
|
|
274
274
|
id: agent.name,
|
|
275
275
|
name: "model",
|
|
276
|
-
description:
|
|
276
|
+
description: buildAgentDescription(agent),
|
|
277
277
|
tags: ["llm"]
|
|
278
278
|
}
|
|
279
279
|
];
|
|
@@ -342,7 +342,7 @@ function buildAgentDescription(agent) {
|
|
|
342
342
|
if (agent.description) {
|
|
343
343
|
descriptionParts.push(agent.description);
|
|
344
344
|
}
|
|
345
|
-
if (agent.subAgents.length > 0) {
|
|
345
|
+
if (!(0, import_llm_agent.isLlmAgent)(agent) && agent.subAgents.length > 0) {
|
|
346
346
|
if ((0, import_loop_agent.isLoopAgent)(agent)) {
|
|
347
347
|
descriptionParts.push(buildLoopAgentDescription(agent));
|
|
348
348
|
} else if ((0, import_parallel_agent.isParallelAgent)(agent)) {
|
|
@@ -420,82 +420,6 @@ function buildLoopAgentDescription(agent) {
|
|
|
420
420
|
return `${descriptions.join(" ")} in a loop (max ${maxIterations} iterations).`;
|
|
421
421
|
}
|
|
422
422
|
__name(buildLoopAgentDescription, "buildLoopAgentDescription");
|
|
423
|
-
async function buildDescriptionFromInstructions(agent) {
|
|
424
|
-
const descriptionParts = [];
|
|
425
|
-
if (agent.description) {
|
|
426
|
-
descriptionParts.push(agent.description);
|
|
427
|
-
}
|
|
428
|
-
if (agent.instruction) {
|
|
429
|
-
let instructionStr;
|
|
430
|
-
if (typeof agent.instruction === "function") {
|
|
431
|
-
const dummyContext = new import_readonly_context.ReadonlyContext(
|
|
432
|
-
new import_invocation_context.InvocationContext({
|
|
433
|
-
agent
|
|
434
|
-
})
|
|
435
|
-
);
|
|
436
|
-
try {
|
|
437
|
-
instructionStr = await agent.instruction(dummyContext);
|
|
438
|
-
} catch (e) {
|
|
439
|
-
import_logger.logger.warn("Failed to resolve dynamic instruction for AgentCard", e);
|
|
440
|
-
instructionStr = "";
|
|
441
|
-
}
|
|
442
|
-
} else {
|
|
443
|
-
instructionStr = agent.instruction;
|
|
444
|
-
}
|
|
445
|
-
if (instructionStr) {
|
|
446
|
-
descriptionParts.push(replacePronouns(instructionStr));
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
const root = agent.rootAgent;
|
|
450
|
-
if ((0, import_llm_agent.isLlmAgent)(root) && root.globalInstruction) {
|
|
451
|
-
let globalInstructionStr;
|
|
452
|
-
if (typeof root.globalInstruction === "function") {
|
|
453
|
-
const dummyContext = new import_readonly_context.ReadonlyContext(
|
|
454
|
-
new import_invocation_context.InvocationContext({
|
|
455
|
-
agent
|
|
456
|
-
})
|
|
457
|
-
);
|
|
458
|
-
try {
|
|
459
|
-
globalInstructionStr = await root.globalInstruction(dummyContext);
|
|
460
|
-
} catch (e) {
|
|
461
|
-
import_logger.logger.warn(
|
|
462
|
-
"Failed to resolve dynamic global instruction for AgentCard",
|
|
463
|
-
e
|
|
464
|
-
);
|
|
465
|
-
globalInstructionStr = "";
|
|
466
|
-
}
|
|
467
|
-
} else {
|
|
468
|
-
globalInstructionStr = root.globalInstruction;
|
|
469
|
-
}
|
|
470
|
-
if (globalInstructionStr) {
|
|
471
|
-
descriptionParts.push(replacePronouns(globalInstructionStr));
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
if (descriptionParts.length > 0) {
|
|
475
|
-
return descriptionParts.join(" ");
|
|
476
|
-
} else {
|
|
477
|
-
return getDefaultAgentDescription(agent);
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
__name(buildDescriptionFromInstructions, "buildDescriptionFromInstructions");
|
|
481
|
-
function replacePronouns(instruction) {
|
|
482
|
-
const substitutions = [
|
|
483
|
-
{ original: "you were", target: "I was" },
|
|
484
|
-
{ original: "you are", target: "I am" },
|
|
485
|
-
{ original: "you're", target: "I am" },
|
|
486
|
-
{ original: "you've", target: "I have" },
|
|
487
|
-
{ original: "yours", target: "mine" },
|
|
488
|
-
{ original: "your", target: "my" },
|
|
489
|
-
{ original: "you", target: "I" }
|
|
490
|
-
];
|
|
491
|
-
let result = instruction;
|
|
492
|
-
for (const sub of substitutions) {
|
|
493
|
-
const pattern = new RegExp(`\\b${sub.original}\\b`, "gi");
|
|
494
|
-
result = result.replace(pattern, sub.target);
|
|
495
|
-
}
|
|
496
|
-
return result;
|
|
497
|
-
}
|
|
498
|
-
__name(replacePronouns, "replacePronouns");
|
|
499
423
|
function getDefaultAgentDescription(agent) {
|
|
500
424
|
if ((0, import_loop_agent.isLoopAgent)(agent)) {
|
|
501
425
|
return "A loop workflow agent";
|
|
@@ -44,6 +44,7 @@ var import_sdk = require("@a2a-js/sdk");
|
|
|
44
44
|
var import_server = require("@a2a-js/sdk/server");
|
|
45
45
|
var import_run_config = require("../agents/run_config.js");
|
|
46
46
|
var import_in_memory_session_service = require("../sessions/in_memory_session_service.js");
|
|
47
|
+
var import_instrumentation = require("../telemetry/api/instrumentation.js");
|
|
47
48
|
var import_logger = require("../utils/logger.js");
|
|
48
49
|
var import_optional_peer = require("../utils/optional_peer.js");
|
|
49
50
|
var import_agent_card = require("./agent_card.js");
|
|
@@ -63,6 +64,10 @@ async function loadExpressBindings() {
|
|
|
63
64
|
return { express: expressModule.default, a2aExpress };
|
|
64
65
|
}
|
|
65
66
|
__name(loadExpressBindings, "loadExpressBindings");
|
|
67
|
+
function continueRemoteTrace(req, _res, next) {
|
|
68
|
+
(0, import_instrumentation.runWithRemoteTraceContext)(req.headers, () => next());
|
|
69
|
+
}
|
|
70
|
+
__name(continueRemoteTrace, "continueRemoteTrace");
|
|
66
71
|
function resolveA2aUserBuilder(options, a2aExpress) {
|
|
67
72
|
if (options.authentication) {
|
|
68
73
|
return options.authentication;
|
|
@@ -124,6 +129,7 @@ async function toA2a(agent, options = {}) {
|
|
|
124
129
|
);
|
|
125
130
|
app.use(
|
|
126
131
|
`${basePath}/rest`,
|
|
132
|
+
continueRemoteTrace,
|
|
127
133
|
a2aExpress.restHandler({
|
|
128
134
|
requestHandler,
|
|
129
135
|
userBuilder
|
|
@@ -131,6 +137,7 @@ async function toA2a(agent, options = {}) {
|
|
|
131
137
|
);
|
|
132
138
|
app.use(
|
|
133
139
|
`${basePath}/jsonrpc`,
|
|
140
|
+
continueRemoteTrace,
|
|
134
141
|
a2aExpress.jsonRpcHandler({
|
|
135
142
|
requestHandler,
|
|
136
143
|
userBuilder
|
|
@@ -79,7 +79,12 @@ function messageToAdkEvent(msg, invocationId, agentName, branch) {
|
|
|
79
79
|
return {
|
|
80
80
|
...createAdkEventFromMetadata(msg),
|
|
81
81
|
invocationId,
|
|
82
|
-
|
|
82
|
+
// The role on a peer's message is the peer's own claim and must not decide
|
|
83
|
+
// authorship: letting `user` through here lets a remote agent post events
|
|
84
|
+
// that read as the local user's, which is a trust anchor elsewhere (tool
|
|
85
|
+
// confirmations are approved only from user-authored events). Attribute the
|
|
86
|
+
// event to the peer, the same way the task and status converters below do.
|
|
87
|
+
author: agentName,
|
|
83
88
|
branch,
|
|
84
89
|
content,
|
|
85
90
|
turnComplete: true,
|
|
@@ -194,8 +199,10 @@ function createAdkEventFromMetadata(a2aEvent) {
|
|
|
194
199
|
// (set it to a shared ancestor branch, or omit it) to leak its content
|
|
195
200
|
// into an unrelated sibling agent's LLM context. Every caller of the
|
|
196
201
|
// `*ToAdkEvent` functions in this file force-sets `branch` from its own
|
|
197
|
-
// local `InvocationContext` instead, the same way `author` is handled
|
|
198
|
-
author
|
|
202
|
+
// local `InvocationContext` instead, the same way `author` is handled:
|
|
203
|
+
// `author` is likewise never restored from peer metadata here, since every
|
|
204
|
+
// converter sets it from the local context after the spread, so reading it
|
|
205
|
+
// from metadata would be dead and read as if a peer could set the author.
|
|
199
206
|
partial: metadata[import_metadata_converter_utils.A2AMetadataKeys.PARTIAL],
|
|
200
207
|
errorCode: metadata[import_metadata_converter_utils.A2AMetadataKeys.ERROR_CODE],
|
|
201
208
|
errorMessage: metadata[import_metadata_converter_utils.A2AMetadataKeys.ERROR_MESSAGE],
|
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
var __create = Object.create;
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
+
var __export = (target, all) => {
|
|
16
|
+
for (var name in all)
|
|
17
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
+
};
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
+
for (let key of __getOwnPropNames(from))
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
28
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
29
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
30
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
31
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
32
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
33
|
+
mod
|
|
34
|
+
));
|
|
35
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
|
+
var agent_engine_client_exports = {};
|
|
37
|
+
__export(agent_engine_client_exports, {
|
|
38
|
+
AgentEngineClient: () => AgentEngineClient,
|
|
39
|
+
AgentExecutionError: () => AgentExecutionError
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(agent_engine_client_exports);
|
|
42
|
+
var import_error_utils = require("../utils/error_utils.js");
|
|
43
|
+
var import_optional_peer = require("../utils/optional_peer.js");
|
|
44
|
+
/**
|
|
45
|
+
* @license
|
|
46
|
+
* Copyright 2026 Google LLC
|
|
47
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
48
|
+
*/
|
|
49
|
+
const _AgentExecutionError = class _AgentExecutionError extends Error {
|
|
50
|
+
constructor(message, cause) {
|
|
51
|
+
super(message);
|
|
52
|
+
this.cause = cause;
|
|
53
|
+
this.name = "AgentExecutionError";
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
__name(_AgentExecutionError, "AgentExecutionError");
|
|
57
|
+
let AgentExecutionError = _AgentExecutionError;
|
|
58
|
+
const WIRE_KEY_ALIASES = [
|
|
59
|
+
["userId", "user_id"],
|
|
60
|
+
["sessionId", "session_id"],
|
|
61
|
+
["expireTime", "expire_time"],
|
|
62
|
+
["runConfig", "run_config"],
|
|
63
|
+
["stateDelta", "state_delta"]
|
|
64
|
+
];
|
|
65
|
+
function toWireInput(config) {
|
|
66
|
+
var _a;
|
|
67
|
+
const input = { ...config };
|
|
68
|
+
delete input["classMethod"];
|
|
69
|
+
for (const [camel, snake] of WIRE_KEY_ALIASES) {
|
|
70
|
+
input[snake] = (_a = input[snake]) != null ? _a : input[camel];
|
|
71
|
+
delete input[camel];
|
|
72
|
+
}
|
|
73
|
+
for (const key of Object.keys(input)) {
|
|
74
|
+
if (input[key] === void 0) {
|
|
75
|
+
delete input[key];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return input;
|
|
79
|
+
}
|
|
80
|
+
__name(toWireInput, "toWireInput");
|
|
81
|
+
function buildInputStruct(sdkHelpers, input) {
|
|
82
|
+
var _a;
|
|
83
|
+
const value = sdkHelpers.toValue(input);
|
|
84
|
+
return (_a = value == null ? void 0 : value.structValue) != null ? _a : void 0;
|
|
85
|
+
}
|
|
86
|
+
__name(buildInputStruct, "buildInputStruct");
|
|
87
|
+
function parseOutput(sdkHelpers, output) {
|
|
88
|
+
return sdkHelpers.fromValue(output);
|
|
89
|
+
}
|
|
90
|
+
__name(parseOutput, "parseOutput");
|
|
91
|
+
const IGNORED_SSE_FIELDS = /* @__PURE__ */ new Set([
|
|
92
|
+
"event",
|
|
93
|
+
"id",
|
|
94
|
+
"retry"
|
|
95
|
+
]);
|
|
96
|
+
const DONE_SENTINEL = "[DONE]";
|
|
97
|
+
function parseFragment(payload) {
|
|
98
|
+
try {
|
|
99
|
+
return JSON.parse(payload);
|
|
100
|
+
} catch (e) {
|
|
101
|
+
throw new AgentExecutionError(
|
|
102
|
+
`Failed to parse stream fragment: ${payload}`,
|
|
103
|
+
e
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
__name(parseFragment, "parseFragment");
|
|
108
|
+
function* dispatchEvent(dataLines) {
|
|
109
|
+
if (dataLines.length === 0) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const lines = dataLines.splice(0);
|
|
113
|
+
const payload = lines.join("\n").trim();
|
|
114
|
+
if (payload === "" || payload === DONE_SENTINEL) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
let parsed;
|
|
118
|
+
try {
|
|
119
|
+
parsed = parseFragment(payload);
|
|
120
|
+
} catch (e) {
|
|
121
|
+
if (lines.length === 1) {
|
|
122
|
+
throw e;
|
|
123
|
+
}
|
|
124
|
+
const values = [];
|
|
125
|
+
try {
|
|
126
|
+
for (const line of lines) {
|
|
127
|
+
const trimmed = line.trim();
|
|
128
|
+
if (trimmed !== "" && trimmed !== DONE_SENTINEL) {
|
|
129
|
+
values.push(JSON.parse(trimmed));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
} catch {
|
|
133
|
+
throw e;
|
|
134
|
+
}
|
|
135
|
+
yield* values;
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
yield parsed;
|
|
139
|
+
}
|
|
140
|
+
__name(dispatchEvent, "dispatchEvent");
|
|
141
|
+
function* processLine(rawLine, dataLines) {
|
|
142
|
+
const line = (rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine).replace(/^[ \t]+/, "");
|
|
143
|
+
if (line === "") {
|
|
144
|
+
yield* dispatchEvent(dataLines);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (line.startsWith(":")) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const colon = line.indexOf(":");
|
|
151
|
+
const field = colon === -1 ? line : line.slice(0, colon);
|
|
152
|
+
if (IGNORED_SSE_FIELDS.has(field)) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (field === "data") {
|
|
156
|
+
if (dataLines.length === 1) {
|
|
157
|
+
const buffered = dataLines[0].trim();
|
|
158
|
+
if (buffered === DONE_SENTINEL) {
|
|
159
|
+
yield* dispatchEvent(dataLines);
|
|
160
|
+
} else if (buffered !== "") {
|
|
161
|
+
try {
|
|
162
|
+
JSON.parse(buffered);
|
|
163
|
+
yield* dispatchEvent(dataLines);
|
|
164
|
+
} catch {
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const value = colon === -1 ? "" : line.slice(colon + 1);
|
|
169
|
+
dataLines.push(value.startsWith(" ") ? value.slice(1) : value);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
yield* dispatchEvent(dataLines);
|
|
173
|
+
const trimmed = line.trim();
|
|
174
|
+
if (trimmed === "" || trimmed === DONE_SENTINEL) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
yield parseFragment(trimmed);
|
|
178
|
+
}
|
|
179
|
+
__name(processLine, "processLine");
|
|
180
|
+
async function* parseStream(stream) {
|
|
181
|
+
var _a;
|
|
182
|
+
const decoder = new TextDecoder("utf-8");
|
|
183
|
+
const dataLines = [];
|
|
184
|
+
let buffer = "";
|
|
185
|
+
for await (const chunk of stream) {
|
|
186
|
+
const chunkData = chunk == null ? void 0 : chunk.data;
|
|
187
|
+
if (chunkData === void 0) {
|
|
188
|
+
if (typeof chunk === "object" && chunk !== null) {
|
|
189
|
+
yield chunk;
|
|
190
|
+
}
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
buffer += chunkData instanceof Uint8Array ? decoder.decode(chunkData, { stream: true }) : String(chunkData);
|
|
194
|
+
const lines = buffer.split("\n");
|
|
195
|
+
buffer = (_a = lines.pop()) != null ? _a : "";
|
|
196
|
+
for (const line of lines) {
|
|
197
|
+
yield* processLine(line, dataLines);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
buffer += decoder.decode();
|
|
201
|
+
for (const line of buffer.split("\n")) {
|
|
202
|
+
yield* processLine(line, dataLines);
|
|
203
|
+
}
|
|
204
|
+
yield* dispatchEvent(dataLines);
|
|
205
|
+
}
|
|
206
|
+
__name(parseStream, "parseStream");
|
|
207
|
+
const _AgentEngineClient = class _AgentEngineClient {
|
|
208
|
+
constructor(config) {
|
|
209
|
+
var _a;
|
|
210
|
+
this.apiEndpoint = (_a = config.apiEndpoint) != null ? _a : config.location === "global" ? "aiplatform.googleapis.com" : `${config.location}-aiplatform.googleapis.com`;
|
|
211
|
+
this.reasoningEnginePath = `projects/${config.project}/locations/${config.location}/reasoningEngines/${config.reasoningEngineId}`;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Creates a remote session.
|
|
215
|
+
*
|
|
216
|
+
* Calls the `async_create_session` class method unless `config.classMethod`
|
|
217
|
+
* names another one.
|
|
218
|
+
*
|
|
219
|
+
* @returns The session payload returned by the Agent Engine. When
|
|
220
|
+
* `config.sessionId` is omitted the engine generates one, and this is the
|
|
221
|
+
* only place the caller can read it back from.
|
|
222
|
+
*/
|
|
223
|
+
async createSession(config) {
|
|
224
|
+
return this.callQueryMethod({
|
|
225
|
+
config,
|
|
226
|
+
defaultClassMethod: "async_create_session",
|
|
227
|
+
errorPrefix: "Failed to create session"
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Reads a remote session.
|
|
232
|
+
*
|
|
233
|
+
* Calls the `async_get_session` class method unless `config.classMethod`
|
|
234
|
+
* names another one.
|
|
235
|
+
*
|
|
236
|
+
* @throws {@link AgentExecutionError} if the user id or the session id is
|
|
237
|
+
* missing, or if the call fails.
|
|
238
|
+
*/
|
|
239
|
+
async getSession(config) {
|
|
240
|
+
var _a, _b;
|
|
241
|
+
const userId = (_a = config.user_id) != null ? _a : config.userId;
|
|
242
|
+
const sessionId = (_b = config.session_id) != null ? _b : config.sessionId;
|
|
243
|
+
if (!userId || !sessionId) {
|
|
244
|
+
throw new AgentExecutionError(
|
|
245
|
+
"Failed to get session: user_id and session_id are required"
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
return this.callQueryMethod({
|
|
249
|
+
config,
|
|
250
|
+
defaultClassMethod: "async_get_session",
|
|
251
|
+
errorPrefix: "Failed to get session"
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Lists the remote sessions of a user.
|
|
256
|
+
*
|
|
257
|
+
* Calls the `async_list_sessions` class method unless `config.classMethod`
|
|
258
|
+
* names another one.
|
|
259
|
+
*/
|
|
260
|
+
async listSessions(config) {
|
|
261
|
+
return this.callQueryMethod({
|
|
262
|
+
config,
|
|
263
|
+
defaultClassMethod: "async_list_sessions",
|
|
264
|
+
errorPrefix: "Failed to list sessions"
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Deletes a remote session.
|
|
269
|
+
*
|
|
270
|
+
* Calls the `async_delete_session` class method unless `config.classMethod`
|
|
271
|
+
* names another one.
|
|
272
|
+
*/
|
|
273
|
+
async deleteSession(config) {
|
|
274
|
+
await this.callQueryMethod({
|
|
275
|
+
config,
|
|
276
|
+
defaultClassMethod: "async_delete_session",
|
|
277
|
+
errorPrefix: "Failed to delete session"
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Sends a query and waits for the whole response.
|
|
282
|
+
*
|
|
283
|
+
* Calls the `query` class method unless `config.classMethod` names another
|
|
284
|
+
* one.
|
|
285
|
+
*/
|
|
286
|
+
async query(config) {
|
|
287
|
+
return this.callQueryMethod({
|
|
288
|
+
config,
|
|
289
|
+
defaultClassMethod: "query",
|
|
290
|
+
errorPrefix: "Failed to execute query"
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Sends a query and yields each streamed response value.
|
|
295
|
+
*
|
|
296
|
+
* Calls the `async_stream_query` class method unless `config.classMethod`
|
|
297
|
+
* names another one. The stream can be server-sent events or
|
|
298
|
+
* newline-delimited JSON.
|
|
299
|
+
*/
|
|
300
|
+
async *streamQuery(config) {
|
|
301
|
+
var _a;
|
|
302
|
+
try {
|
|
303
|
+
const { helpers: sdkHelpers, client } = await this.getClient();
|
|
304
|
+
const stream = client.streamQueryReasoningEngine({
|
|
305
|
+
name: this.reasoningEnginePath,
|
|
306
|
+
classMethod: (_a = config.classMethod) != null ? _a : "async_stream_query",
|
|
307
|
+
input: buildInputStruct(sdkHelpers, toWireInput(config))
|
|
308
|
+
});
|
|
309
|
+
yield* parseStream(stream);
|
|
310
|
+
} catch (err) {
|
|
311
|
+
if (err instanceof AgentExecutionError) {
|
|
312
|
+
throw err;
|
|
313
|
+
}
|
|
314
|
+
throw new AgentExecutionError(
|
|
315
|
+
`Failed to execute stream query: ${(0, import_error_utils.getErrorMessage)(err)}`,
|
|
316
|
+
err
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Closes the underlying gRPC client.
|
|
322
|
+
*
|
|
323
|
+
* Does nothing if no call has created the client yet, and is safe to call
|
|
324
|
+
* more than once. A later call creates a new client.
|
|
325
|
+
*/
|
|
326
|
+
async close() {
|
|
327
|
+
const pending = this.clientPromise;
|
|
328
|
+
if (!pending) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
this.clientPromise = void 0;
|
|
332
|
+
let loaded;
|
|
333
|
+
try {
|
|
334
|
+
loaded = await pending;
|
|
335
|
+
} catch {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
await loaded.client.close();
|
|
339
|
+
}
|
|
340
|
+
async callQueryMethod({
|
|
341
|
+
config,
|
|
342
|
+
defaultClassMethod,
|
|
343
|
+
errorPrefix
|
|
344
|
+
}) {
|
|
345
|
+
var _a;
|
|
346
|
+
try {
|
|
347
|
+
const { helpers: sdkHelpers, client } = await this.getClient();
|
|
348
|
+
const [response] = await client.queryReasoningEngine({
|
|
349
|
+
name: this.reasoningEnginePath,
|
|
350
|
+
classMethod: (_a = config.classMethod) != null ? _a : defaultClassMethod,
|
|
351
|
+
input: buildInputStruct(sdkHelpers, toWireInput(config))
|
|
352
|
+
});
|
|
353
|
+
return response.output ? parseOutput(sdkHelpers, response.output) : void 0;
|
|
354
|
+
} catch (err) {
|
|
355
|
+
throw new AgentExecutionError(
|
|
356
|
+
`${errorPrefix}: ${(0, import_error_utils.getErrorMessage)(err)}`,
|
|
357
|
+
err
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Resolves the SDK helpers and the gRPC client, loading the optional peer on
|
|
363
|
+
* first use.
|
|
364
|
+
*
|
|
365
|
+
* A created client is kept. A failure is not kept, so the next call tries
|
|
366
|
+
* again, for example once the peer is installed.
|
|
367
|
+
*/
|
|
368
|
+
getClient() {
|
|
369
|
+
if (!this.clientPromise) {
|
|
370
|
+
const promise = this.createClient();
|
|
371
|
+
this.clientPromise = promise;
|
|
372
|
+
promise.catch(() => {
|
|
373
|
+
if (this.clientPromise === promise) {
|
|
374
|
+
this.clientPromise = void 0;
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
return this.clientPromise;
|
|
379
|
+
}
|
|
380
|
+
async createClient() {
|
|
381
|
+
const aiplatform = await (0, import_optional_peer.loadOptionalPeer)(
|
|
382
|
+
{ packageName: "@google-cloud/aiplatform", feature: "AgentEngineClient" },
|
|
383
|
+
() => Promise.resolve().then(() => __toESM(require("@google-cloud/aiplatform"), 1))
|
|
384
|
+
);
|
|
385
|
+
return {
|
|
386
|
+
helpers: aiplatform.helpers,
|
|
387
|
+
client: new aiplatform.v1.ReasoningEngineExecutionServiceClient({
|
|
388
|
+
apiEndpoint: this.apiEndpoint
|
|
389
|
+
})
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
__name(_AgentEngineClient, "AgentEngineClient");
|
|
394
|
+
let AgentEngineClient = _AgentEngineClient;
|
|
395
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
396
|
+
0 && (module.exports = {
|
|
397
|
+
AgentEngineClient,
|
|
398
|
+
AgentExecutionError
|
|
399
|
+
});
|