@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
|
@@ -0,0 +1,244 @@
|
|
|
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 computer_use_tool_exports = {};
|
|
35
|
+
__export(computer_use_tool_exports, {
|
|
36
|
+
ComputerUseTool: () => ComputerUseTool,
|
|
37
|
+
isComputerUseTool: () => isComputerUseTool
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(computer_use_tool_exports);
|
|
40
|
+
var import_env_aware_utils = require("../../utils/env_aware_utils.js");
|
|
41
|
+
var import_experimental = require("../../utils/experimental.js");
|
|
42
|
+
var import_logger = require("../../utils/logger.js");
|
|
43
|
+
var import_function_tool = require("../function_tool.js");
|
|
44
|
+
var import_base_computer = require("./base_computer.js");
|
|
45
|
+
/**
|
|
46
|
+
* @license
|
|
47
|
+
* Copyright 2026 Google LLC
|
|
48
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
49
|
+
*/
|
|
50
|
+
var _a, _b;
|
|
51
|
+
const DEFAULT_VIRTUAL_SCREEN_SIZE = [1e3, 1e3];
|
|
52
|
+
const X_COORDINATE_FIELDS = ["x", "destination_x", "start_x", "end_x"];
|
|
53
|
+
const Y_COORDINATE_FIELDS = ["y", "destination_y", "start_y", "end_y"];
|
|
54
|
+
const INTEGER_STRING = /^-?\d+$/;
|
|
55
|
+
const REQUIRE_CONFIRMATION = "require_confirmation";
|
|
56
|
+
const COMPUTER_USE_TOOL_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for(
|
|
57
|
+
"google.adk.computerUseTool"
|
|
58
|
+
);
|
|
59
|
+
function isComputerUseTool(obj) {
|
|
60
|
+
return typeof obj === "object" && obj !== null && COMPUTER_USE_TOOL_SIGNATURE_SYMBOL in obj && obj[COMPUTER_USE_TOOL_SIGNATURE_SYMBOL] === true;
|
|
61
|
+
}
|
|
62
|
+
__name(isComputerUseTool, "isComputerUseTool");
|
|
63
|
+
let ComputerUseTool = class extends (_b = import_function_tool.FunctionTool, _a = COMPUTER_USE_TOOL_SIGNATURE_SYMBOL, _b) {
|
|
64
|
+
/**
|
|
65
|
+
* @param options The options for the tool.
|
|
66
|
+
* @throws {Error} If `screenSize` or `virtualScreenSize` is not a pair of
|
|
67
|
+
* positive numbers.
|
|
68
|
+
*/
|
|
69
|
+
constructor(options) {
|
|
70
|
+
var _a2;
|
|
71
|
+
(0, import_base_computer.checkComputerUseEnabled)();
|
|
72
|
+
const virtualScreenSize = (_a2 = options.virtualScreenSize) != null ? _a2 : DEFAULT_VIRTUAL_SCREEN_SIZE;
|
|
73
|
+
checkScreenSize("screenSize", options.screenSize);
|
|
74
|
+
checkScreenSize("virtualScreenSize", virtualScreenSize);
|
|
75
|
+
const func = options.execute;
|
|
76
|
+
super({
|
|
77
|
+
name: options.name,
|
|
78
|
+
description: options.description,
|
|
79
|
+
parameters: options.parameters,
|
|
80
|
+
execute: /* @__PURE__ */ __name((input, toolContext) => func(isRecord(input) ? input : {}, toolContext), "execute")
|
|
81
|
+
});
|
|
82
|
+
/** A unique symbol to identify ADK computer use tool class. */
|
|
83
|
+
this[_a] = true;
|
|
84
|
+
this.func = func;
|
|
85
|
+
this.screenSize = options.screenSize;
|
|
86
|
+
this.virtualScreenSize = virtualScreenSize;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Runs the computer control function with scaled coordinates.
|
|
90
|
+
*
|
|
91
|
+
* @param request The tool request containing arguments and tool context.
|
|
92
|
+
* @returns The function's result, with a {@link ComputerState} converted to
|
|
93
|
+
* a response carrying the base64-encoded screenshot.
|
|
94
|
+
* @throws {Error} If a coordinate is not numeric, or the function returns a
|
|
95
|
+
* state with no screenshot.
|
|
96
|
+
*/
|
|
97
|
+
async runAsync({
|
|
98
|
+
args,
|
|
99
|
+
toolContext
|
|
100
|
+
}) {
|
|
101
|
+
const confirmation = toolContext.toolConfirmation;
|
|
102
|
+
if (!confirmation) {
|
|
103
|
+
const safetyDecision = getSafetyDecision(args);
|
|
104
|
+
if ((safetyDecision == null ? void 0 : safetyDecision.decision) === REQUIRE_CONFIRMATION) {
|
|
105
|
+
toolContext.requestConfirmation({
|
|
106
|
+
hint: typeof safetyDecision.explanation === "string" && safetyDecision.explanation ? safetyDecision.explanation : "This computer use action requires safety confirmation."
|
|
107
|
+
});
|
|
108
|
+
toolContext.actions.skipSummarization = true;
|
|
109
|
+
return {
|
|
110
|
+
error: "This tool call requires confirmation, please approve or reject."
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
} else if (!confirmation.confirmed) {
|
|
114
|
+
return { error: "This tool call is rejected." };
|
|
115
|
+
}
|
|
116
|
+
const scaledArgs = this.scaleCoordinates(args);
|
|
117
|
+
const result = await super.runAsync({ args: scaledArgs, toolContext });
|
|
118
|
+
let response = result;
|
|
119
|
+
if (isComputerState(result)) {
|
|
120
|
+
if (!result.screenshot) {
|
|
121
|
+
throw new Error(
|
|
122
|
+
"A computer action returned a state with no screenshot"
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
response = {
|
|
126
|
+
image: { mimetype: "image/png", data: (0, import_env_aware_utils.base64Encode)(result.screenshot) },
|
|
127
|
+
url: result.url
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (confirmation == null ? void 0 : confirmation.confirmed) {
|
|
131
|
+
const acknowledged = isRecord(response) ? response : { result: response };
|
|
132
|
+
acknowledged["safety_acknowledgement"] = "true";
|
|
133
|
+
return acknowledged;
|
|
134
|
+
}
|
|
135
|
+
return response;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Whether this call needs user confirmation: when the model marked it with
|
|
139
|
+
* a `safety_decision` of `require_confirmation`, or when the base tool says
|
|
140
|
+
* so.
|
|
141
|
+
*
|
|
142
|
+
* @param args The arguments the tool would run with.
|
|
143
|
+
* @param toolContext The context of the call, when there is one.
|
|
144
|
+
* @returns Whether the call requires confirmation.
|
|
145
|
+
*/
|
|
146
|
+
async checkRequireConfirmation(args, toolContext) {
|
|
147
|
+
var _a2;
|
|
148
|
+
if (((_a2 = getSafetyDecision(args)) == null ? void 0 : _a2.decision) === REQUIRE_CONFIRMATION) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
return super.checkRequireConfirmation(args, toolContext);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Adds nothing to the request: {@link ComputerUseToolset} adds the single
|
|
155
|
+
* computer use configuration and registers its tools by name.
|
|
156
|
+
*/
|
|
157
|
+
async processLlmRequest(_request) {
|
|
158
|
+
}
|
|
159
|
+
/** Returns a copy of `args` with every coordinate scaled to the screen. */
|
|
160
|
+
scaleCoordinates(args) {
|
|
161
|
+
const scaled = { ...args };
|
|
162
|
+
delete scaled["safety_decision"];
|
|
163
|
+
for (const field of X_COORDINATE_FIELDS) {
|
|
164
|
+
if (field in scaled) {
|
|
165
|
+
scaled[field] = scaleCoordinate({
|
|
166
|
+
field,
|
|
167
|
+
value: scaled[field],
|
|
168
|
+
virtual: this.virtualScreenSize[0],
|
|
169
|
+
actual: this.screenSize[0]
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
for (const field of Y_COORDINATE_FIELDS) {
|
|
174
|
+
if (field in scaled) {
|
|
175
|
+
scaled[field] = scaleCoordinate({
|
|
176
|
+
field,
|
|
177
|
+
value: scaled[field],
|
|
178
|
+
virtual: this.virtualScreenSize[1],
|
|
179
|
+
actual: this.screenSize[1]
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return scaled;
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
__name(ComputerUseTool, "ComputerUseTool");
|
|
187
|
+
ComputerUseTool = __decorateClass([
|
|
188
|
+
import_experimental.experimental
|
|
189
|
+
], ComputerUseTool);
|
|
190
|
+
function scaleCoordinate({
|
|
191
|
+
field,
|
|
192
|
+
value,
|
|
193
|
+
virtual,
|
|
194
|
+
actual
|
|
195
|
+
}) {
|
|
196
|
+
const numeric = typeof value === "string" && INTEGER_STRING.test(value) ? Number(value) : value;
|
|
197
|
+
if (typeof numeric !== "number" || !Number.isFinite(numeric)) {
|
|
198
|
+
throw new Error(
|
|
199
|
+
`${field} coordinate must be numeric, got ${typeof value} ${JSON.stringify(value)}`
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
const scaled = Math.max(
|
|
203
|
+
0,
|
|
204
|
+
Math.min(Math.trunc(numeric / virtual * actual), actual - 1)
|
|
205
|
+
);
|
|
206
|
+
import_logger.logger.debug(`Normalized ${field}: ${numeric} -> ${scaled}`);
|
|
207
|
+
return scaled;
|
|
208
|
+
}
|
|
209
|
+
__name(scaleCoordinate, "scaleCoordinate");
|
|
210
|
+
function checkScreenSize(name, size) {
|
|
211
|
+
if (!Array.isArray(size) || size.length !== 2) {
|
|
212
|
+
throw new Error(`${name} must be a pair of (width, height)`);
|
|
213
|
+
}
|
|
214
|
+
if (!size.every((dimension) => Number.isFinite(dimension) && dimension > 0)) {
|
|
215
|
+
throw new Error(`${name} dimensions must be positive`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
__name(checkScreenSize, "checkScreenSize");
|
|
219
|
+
function getSafetyDecision(args) {
|
|
220
|
+
const decision = args["safety_decision"];
|
|
221
|
+
return isRecord(decision) ? decision : void 0;
|
|
222
|
+
}
|
|
223
|
+
__name(getSafetyDecision, "getSafetyDecision");
|
|
224
|
+
function isRecord(value) {
|
|
225
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
226
|
+
}
|
|
227
|
+
__name(isRecord, "isRecord");
|
|
228
|
+
function isComputerState(value) {
|
|
229
|
+
if (!isRecord(value)) {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
const keys = Object.keys(value);
|
|
233
|
+
if (keys.length === 0 || keys.some((k) => k !== "screenshot" && k !== "url")) {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
const { screenshot, url } = value;
|
|
237
|
+
return (screenshot === void 0 || screenshot instanceof Uint8Array) && (url === void 0 || typeof url === "string");
|
|
238
|
+
}
|
|
239
|
+
__name(isComputerState, "isComputerState");
|
|
240
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
241
|
+
0 && (module.exports = {
|
|
242
|
+
ComputerUseTool,
|
|
243
|
+
isComputerUseTool
|
|
244
|
+
});
|
|
@@ -0,0 +1,360 @@
|
|
|
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 computer_use_toolset_exports = {};
|
|
35
|
+
__export(computer_use_toolset_exports, {
|
|
36
|
+
ComputerUseToolset: () => ComputerUseToolset,
|
|
37
|
+
adaptComputerUseTool: () => adaptComputerUseTool,
|
|
38
|
+
isComputerUseToolset: () => isComputerUseToolset
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(computer_use_toolset_exports);
|
|
41
|
+
var import_genai = require("@google/genai");
|
|
42
|
+
var import_experimental = require("../../utils/experimental.js");
|
|
43
|
+
var import_logger = require("../../utils/logger.js");
|
|
44
|
+
var import_model_name = require("../../utils/model_name.js");
|
|
45
|
+
var import_base_toolset = require("../base_toolset.js");
|
|
46
|
+
var import_base_computer = require("./base_computer.js");
|
|
47
|
+
var import_computer_use_actions = require("./computer_use_actions.js");
|
|
48
|
+
var import_computer_use_tool = require("./computer_use_tool.js");
|
|
49
|
+
/**
|
|
50
|
+
* @license
|
|
51
|
+
* Copyright 2026 Google LLC
|
|
52
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
53
|
+
*/
|
|
54
|
+
var _a, _b;
|
|
55
|
+
const DIRECT_EXCLUSION_MAP = Object.freeze({
|
|
56
|
+
// Legacy -> modern.
|
|
57
|
+
click_at: ["click"],
|
|
58
|
+
hover_at: ["move"],
|
|
59
|
+
type_text_at: ["type"],
|
|
60
|
+
type_text: ["type"],
|
|
61
|
+
scroll_at: ["scroll"],
|
|
62
|
+
// Whole-page scroll has no modern counterpart.
|
|
63
|
+
scroll_document: [],
|
|
64
|
+
current_state: ["take_screenshot"],
|
|
65
|
+
key_combination: ["press_key", "hotkey"],
|
|
66
|
+
wait_5_seconds: ["wait"],
|
|
67
|
+
// Modern -> legacy.
|
|
68
|
+
click: ["click_at"],
|
|
69
|
+
move: ["hover_at"],
|
|
70
|
+
type: ["type_text_at"],
|
|
71
|
+
// Does not drop scroll_document.
|
|
72
|
+
scroll: ["scroll_at"],
|
|
73
|
+
take_screenshot: ["current_state"],
|
|
74
|
+
// key_combination is dropped only when both of these are excluded.
|
|
75
|
+
press_key: [],
|
|
76
|
+
hotkey: [],
|
|
77
|
+
wait: ["wait_5_seconds"]
|
|
78
|
+
});
|
|
79
|
+
const LEGACY_EXCLUSION_NAMES = /* @__PURE__ */ new Set([
|
|
80
|
+
"click_at",
|
|
81
|
+
"hover_at",
|
|
82
|
+
"type_text_at",
|
|
83
|
+
"type_text",
|
|
84
|
+
"scroll_at",
|
|
85
|
+
"scroll_document",
|
|
86
|
+
"current_state",
|
|
87
|
+
"key_combination",
|
|
88
|
+
"wait_5_seconds"
|
|
89
|
+
]);
|
|
90
|
+
const MODERN_EXCLUSION_NAMES = /* @__PURE__ */ new Set([
|
|
91
|
+
"click",
|
|
92
|
+
"move",
|
|
93
|
+
"type",
|
|
94
|
+
"scroll",
|
|
95
|
+
"take_screenshot",
|
|
96
|
+
"press_key",
|
|
97
|
+
"hotkey",
|
|
98
|
+
"wait",
|
|
99
|
+
...import_computer_use_actions.OPTIONAL_MOUSE_ACTIONS,
|
|
100
|
+
...import_computer_use_actions.OPTIONAL_KEY_ACTIONS
|
|
101
|
+
]);
|
|
102
|
+
const TYPING_ACTIONS = ["type", "type_text_at", "type_text"];
|
|
103
|
+
const computerQueues = /* @__PURE__ */ new WeakMap();
|
|
104
|
+
function expandLocalExclusions(excludedNames) {
|
|
105
|
+
var _a2;
|
|
106
|
+
const expanded = new Set(excludedNames);
|
|
107
|
+
for (const name of excludedNames) {
|
|
108
|
+
for (const counterpart of (_a2 = DIRECT_EXCLUSION_MAP[name]) != null ? _a2 : []) {
|
|
109
|
+
expanded.add(counterpart);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (TYPING_ACTIONS.some((name) => expanded.has(name))) {
|
|
113
|
+
TYPING_ACTIONS.forEach((name) => expanded.add(name));
|
|
114
|
+
}
|
|
115
|
+
if (expanded.has("press_key") && expanded.has("hotkey")) {
|
|
116
|
+
expanded.add("key_combination");
|
|
117
|
+
}
|
|
118
|
+
return expanded;
|
|
119
|
+
}
|
|
120
|
+
__name(expandLocalExclusions, "expandLocalExclusions");
|
|
121
|
+
function resolveExcludedPredefinedFunctions({
|
|
122
|
+
excludedNames,
|
|
123
|
+
model,
|
|
124
|
+
unimplementedActions
|
|
125
|
+
}) {
|
|
126
|
+
var _a2;
|
|
127
|
+
const major = (0, import_model_name.getGeminiMajorVersion)(model);
|
|
128
|
+
if (major !== void 0 && major < 3) {
|
|
129
|
+
if (excludedNames === void 0) {
|
|
130
|
+
return void 0;
|
|
131
|
+
}
|
|
132
|
+
const bothModernKeys = excludedNames.includes("press_key") && excludedNames.includes("hotkey");
|
|
133
|
+
const resolved2 = [];
|
|
134
|
+
for (const name of excludedNames) {
|
|
135
|
+
if (name === "press_key" || name === "hotkey") {
|
|
136
|
+
if (bothModernKeys) {
|
|
137
|
+
resolved2.push("key_combination");
|
|
138
|
+
}
|
|
139
|
+
} else if (name === "type_text") {
|
|
140
|
+
resolved2.push("type_text_at");
|
|
141
|
+
} else if (MODERN_EXCLUSION_NAMES.has(name)) {
|
|
142
|
+
resolved2.push(...(_a2 = DIRECT_EXCLUSION_MAP[name]) != null ? _a2 : []);
|
|
143
|
+
} else {
|
|
144
|
+
resolved2.push(name);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return [...new Set(resolved2)];
|
|
148
|
+
}
|
|
149
|
+
const resolved = [];
|
|
150
|
+
for (const name of excludedNames != null ? excludedNames : []) {
|
|
151
|
+
if (LEGACY_EXCLUSION_NAMES.has(name)) {
|
|
152
|
+
resolved.push(...DIRECT_EXCLUSION_MAP[name]);
|
|
153
|
+
} else {
|
|
154
|
+
resolved.push(name);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (major !== void 0 && major >= 3) {
|
|
158
|
+
resolved.push(...unimplementedActions);
|
|
159
|
+
}
|
|
160
|
+
const deduped = [...new Set(resolved)];
|
|
161
|
+
if (deduped.length === 0 && excludedNames === void 0) {
|
|
162
|
+
return void 0;
|
|
163
|
+
}
|
|
164
|
+
return deduped;
|
|
165
|
+
}
|
|
166
|
+
__name(resolveExcludedPredefinedFunctions, "resolveExcludedPredefinedFunctions");
|
|
167
|
+
async function runExclusive(computer, action) {
|
|
168
|
+
var _a2;
|
|
169
|
+
const previous = (_a2 = computerQueues.get(computer)) != null ? _a2 : Promise.resolve();
|
|
170
|
+
const result = previous.then(action);
|
|
171
|
+
computerQueues.set(
|
|
172
|
+
computer,
|
|
173
|
+
result.then(
|
|
174
|
+
() => void 0,
|
|
175
|
+
() => void 0
|
|
176
|
+
)
|
|
177
|
+
);
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
180
|
+
__name(runExclusive, "runExclusive");
|
|
181
|
+
function toGenaiEnvironment(environment) {
|
|
182
|
+
switch (environment) {
|
|
183
|
+
case import_base_computer.ComputerEnvironment.ENVIRONMENT_UNSPECIFIED:
|
|
184
|
+
return import_genai.Environment.ENVIRONMENT_UNSPECIFIED;
|
|
185
|
+
case import_base_computer.ComputerEnvironment.ENVIRONMENT_BROWSER:
|
|
186
|
+
return import_genai.Environment.ENVIRONMENT_BROWSER;
|
|
187
|
+
default: {
|
|
188
|
+
const exhaustive = environment;
|
|
189
|
+
throw new Error(`Unknown computer environment: ${exhaustive}`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
__name(toGenaiEnvironment, "toGenaiEnvironment");
|
|
194
|
+
function isComputerUseConfig(tool) {
|
|
195
|
+
return "computerUse" in tool && tool.computerUse !== void 0;
|
|
196
|
+
}
|
|
197
|
+
__name(isComputerUseConfig, "isComputerUseConfig");
|
|
198
|
+
async function adaptComputerUseTool({
|
|
199
|
+
methodName,
|
|
200
|
+
adapter,
|
|
201
|
+
llmRequest
|
|
202
|
+
}) {
|
|
203
|
+
if (!import_computer_use_actions.LEGACY_ACTION_NAMES.includes(methodName)) {
|
|
204
|
+
import_logger.logger.warn(`Method ${methodName} is not a valid BaseComputer method`);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const original = Object.hasOwn(llmRequest.toolsDict, methodName) ? llmRequest.toolsDict[methodName] : void 0;
|
|
208
|
+
if (!(0, import_computer_use_tool.isComputerUseTool)(original)) {
|
|
209
|
+
import_logger.logger.warn(`Method ${methodName} not found in toolsDict`);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const adapted = await adapter(original.func);
|
|
213
|
+
llmRequest.toolsDict[adapted.name] = new import_computer_use_tool.ComputerUseTool({
|
|
214
|
+
...adapted,
|
|
215
|
+
screenSize: original.screenSize,
|
|
216
|
+
virtualScreenSize: original.virtualScreenSize
|
|
217
|
+
});
|
|
218
|
+
if (adapted.name !== methodName) {
|
|
219
|
+
delete llmRequest.toolsDict[methodName];
|
|
220
|
+
}
|
|
221
|
+
import_logger.logger.debug(`Adapted tool ${methodName} to ${adapted.name}`);
|
|
222
|
+
}
|
|
223
|
+
__name(adaptComputerUseTool, "adaptComputerUseTool");
|
|
224
|
+
const COMPUTER_USE_TOOLSET_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for(
|
|
225
|
+
"google.adk.computerUseToolset"
|
|
226
|
+
);
|
|
227
|
+
function isComputerUseToolset(obj) {
|
|
228
|
+
return typeof obj === "object" && obj !== null && COMPUTER_USE_TOOLSET_SIGNATURE_SYMBOL in obj && obj[COMPUTER_USE_TOOLSET_SIGNATURE_SYMBOL] === true;
|
|
229
|
+
}
|
|
230
|
+
__name(isComputerUseToolset, "isComputerUseToolset");
|
|
231
|
+
let ComputerUseToolset = class extends (_b = import_base_toolset.BaseToolset, _a = COMPUTER_USE_TOOLSET_SIGNATURE_SYMBOL, _b) {
|
|
232
|
+
/**
|
|
233
|
+
* @param options The computer and its configuration.
|
|
234
|
+
*/
|
|
235
|
+
constructor(options) {
|
|
236
|
+
var _a2;
|
|
237
|
+
(0, import_base_computer.checkComputerUseEnabled)();
|
|
238
|
+
super([]);
|
|
239
|
+
/** A unique symbol to identify ADK computer use toolset class. */
|
|
240
|
+
this[_a] = true;
|
|
241
|
+
this.closed = false;
|
|
242
|
+
this.computer = options.computer;
|
|
243
|
+
this.excludedPredefinedFunctions = options.excludedPredefinedFunctions;
|
|
244
|
+
this.allowPrivateNetworkAccess = (_a2 = options.allowPrivateNetworkAccess) != null ? _a2 : false;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Returns a tool for every action the computer supports, except the
|
|
248
|
+
* excluded ones. The computer is initialized on the first call, and the
|
|
249
|
+
* tools are cached until {@link close}.
|
|
250
|
+
*/
|
|
251
|
+
async getTools() {
|
|
252
|
+
var _a2;
|
|
253
|
+
(_a2 = this.loadingTools) != null ? _a2 : this.loadingTools = this.loadTools();
|
|
254
|
+
try {
|
|
255
|
+
return await this.loadingTools;
|
|
256
|
+
} catch (error) {
|
|
257
|
+
this.loadingTools = void 0;
|
|
258
|
+
throw error;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Closes the computer and drops the cached tools. The next call to
|
|
263
|
+
* {@link getTools} initializes the computer again.
|
|
264
|
+
*/
|
|
265
|
+
async close() {
|
|
266
|
+
if (!this.closed) {
|
|
267
|
+
await this.computer.close();
|
|
268
|
+
this.closed = true;
|
|
269
|
+
}
|
|
270
|
+
this.initializing = void 0;
|
|
271
|
+
this.loadingTools = void 0;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Registers the computer use tools in the request and adds the computer use
|
|
275
|
+
* configuration, unless the request already has one.
|
|
276
|
+
*
|
|
277
|
+
* @param _toolContext The context of the tool.
|
|
278
|
+
* @param llmRequest The outgoing request.
|
|
279
|
+
*/
|
|
280
|
+
async processLlmRequest(_toolContext, llmRequest) {
|
|
281
|
+
var _a2, _b2, _c;
|
|
282
|
+
for (const tool of await this.getTools()) {
|
|
283
|
+
llmRequest.toolsDict[tool.name] = tool;
|
|
284
|
+
}
|
|
285
|
+
(_a2 = llmRequest.config) != null ? _a2 : llmRequest.config = {};
|
|
286
|
+
(_c = (_b2 = llmRequest.config).tools) != null ? _c : _b2.tools = [];
|
|
287
|
+
if (llmRequest.config.tools.some(isComputerUseConfig)) {
|
|
288
|
+
import_logger.logger.debug("Computer use already configured in LLM request");
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const environment = toGenaiEnvironment(await this.computer.environment());
|
|
292
|
+
const excludedPredefinedFunctions = resolveExcludedPredefinedFunctions({
|
|
293
|
+
excludedNames: this.excludedPredefinedFunctions,
|
|
294
|
+
model: llmRequest.model,
|
|
295
|
+
unimplementedActions: (0, import_computer_use_actions.unimplementedOptionalActions)(this.computer)
|
|
296
|
+
});
|
|
297
|
+
llmRequest.config.tools.push({
|
|
298
|
+
computerUse: excludedPredefinedFunctions === void 0 ? { environment } : { environment, excludedPredefinedFunctions }
|
|
299
|
+
});
|
|
300
|
+
import_logger.logger.debug(
|
|
301
|
+
`Added computer use tool with environment: ${environment}, excluded functions: ${excludedPredefinedFunctions}`
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
ensureInitialized() {
|
|
305
|
+
var _a2;
|
|
306
|
+
(_a2 = this.initializing) != null ? _a2 : this.initializing = this.computer.initialize().then(
|
|
307
|
+
() => {
|
|
308
|
+
this.closed = false;
|
|
309
|
+
},
|
|
310
|
+
(error) => {
|
|
311
|
+
this.initializing = void 0;
|
|
312
|
+
throw error;
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
return this.initializing;
|
|
316
|
+
}
|
|
317
|
+
async loadTools() {
|
|
318
|
+
var _a2;
|
|
319
|
+
await this.ensureInitialized();
|
|
320
|
+
const screenSize = await this.computer.screenSize();
|
|
321
|
+
const excluded = expandLocalExclusions(
|
|
322
|
+
(_a2 = this.excludedPredefinedFunctions) != null ? _a2 : []
|
|
323
|
+
);
|
|
324
|
+
return (0, import_computer_use_actions.createComputerActions)({
|
|
325
|
+
computer: this.computer,
|
|
326
|
+
allowPrivateNetworkAccess: this.allowPrivateNetworkAccess
|
|
327
|
+
}).filter((action) => !excluded.has(action.name)).map(
|
|
328
|
+
(action) => new import_computer_use_tool.ComputerUseTool({
|
|
329
|
+
name: action.name,
|
|
330
|
+
description: action.description,
|
|
331
|
+
parameters: action.parameters,
|
|
332
|
+
execute: this.bindToComputer(action),
|
|
333
|
+
screenSize
|
|
334
|
+
})
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Wraps an action so it runs exclusively on the computer, after the
|
|
339
|
+
* computer has prepared for the calling session.
|
|
340
|
+
*/
|
|
341
|
+
bindToComputer(action) {
|
|
342
|
+
const computer = this.computer;
|
|
343
|
+
return (args, toolContext) => runExclusive(computer, async () => {
|
|
344
|
+
if (toolContext) {
|
|
345
|
+
await computer.prepare(toolContext);
|
|
346
|
+
}
|
|
347
|
+
return action.execute(args);
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
__name(ComputerUseToolset, "ComputerUseToolset");
|
|
352
|
+
ComputerUseToolset = __decorateClass([
|
|
353
|
+
import_experimental.experimental
|
|
354
|
+
], ComputerUseToolset);
|
|
355
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
356
|
+
0 && (module.exports = {
|
|
357
|
+
ComputerUseToolset,
|
|
358
|
+
adaptComputerUseTool,
|
|
359
|
+
isComputerUseToolset
|
|
360
|
+
});
|
|
@@ -59,9 +59,10 @@ function toResponseSchema(response) {
|
|
|
59
59
|
return (0, import_simple_zod_to_json.zodObjectToSchema)(response);
|
|
60
60
|
}
|
|
61
61
|
if (typeof response === "object" && response !== null && "safeParse" in response && typeof response.safeParse === "function") {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
const jsonSchema = (0, import_schema.toJsonSchema)(response);
|
|
63
|
+
return (_a2 = (0, import_gemini_schema_util.toGeminiSchema)(jsonSchema)) != null ? _a2 : {
|
|
64
|
+
type: import_genai.Type.TYPE_UNSPECIFIED
|
|
65
|
+
};
|
|
65
66
|
}
|
|
66
67
|
return response;
|
|
67
68
|
}
|
|
@@ -281,6 +282,11 @@ function annotateNullableFields(schema) {
|
|
|
281
282
|
if (!isPlainRecord(propertySchema)) {
|
|
282
283
|
continue;
|
|
283
284
|
}
|
|
285
|
+
const propType = propertySchema["type"];
|
|
286
|
+
if (propType === null || propType === "null" || propType === import_genai.Type.NULL) {
|
|
287
|
+
propertySchema["type"] = import_genai.Type.OBJECT;
|
|
288
|
+
propertySchema["nullable"] = true;
|
|
289
|
+
}
|
|
284
290
|
const anyOf = propertySchema["anyOf"];
|
|
285
291
|
if (!Array.isArray(anyOf)) {
|
|
286
292
|
continue;
|
|
@@ -383,8 +389,12 @@ function processParameterSchema(vertexai, schema) {
|
|
|
383
389
|
__name(processParameterSchema, "processParameterSchema");
|
|
384
390
|
function mapPropertySchemaType(propertySchema) {
|
|
385
391
|
var _a2, _b2;
|
|
386
|
-
|
|
387
|
-
|
|
392
|
+
const rawType = propertySchema["type"];
|
|
393
|
+
if (rawType === null || rawType === "null" || rawType === import_genai.Type.NULL) {
|
|
394
|
+
propertySchema["type"] = import_genai.Type.OBJECT;
|
|
395
|
+
propertySchema["nullable"] = true;
|
|
396
|
+
} else if (typeof rawType === "string") {
|
|
397
|
+
propertySchema["type"] = (_a2 = SCHEMA_TYPE_MAP[rawType]) != null ? _a2 : import_genai.Type.TYPE_UNSPECIFIED;
|
|
388
398
|
if (propertySchema["type"] === import_genai.Type.ARRAY && isPlainRecord(propertySchema["items"])) {
|
|
389
399
|
mapPropertySchemaType(propertySchema["items"]);
|
|
390
400
|
}
|
|
@@ -52,7 +52,7 @@ function isGoogleApiTool(obj) {
|
|
|
52
52
|
}
|
|
53
53
|
__name(isGoogleApiTool, "isGoogleApiTool");
|
|
54
54
|
let GoogleApiTool = class extends (_b = import_base_tool.BaseTool, _a = GOOGLE_API_TOOL_SIGNATURE_SYMBOL, _b) {
|
|
55
|
-
constructor(restApiTool) {
|
|
55
|
+
constructor(restApiTool, options = {}) {
|
|
56
56
|
super({
|
|
57
57
|
name: restApiTool.name,
|
|
58
58
|
description: restApiTool.description,
|
|
@@ -60,6 +60,9 @@ let GoogleApiTool = class extends (_b = import_base_tool.BaseTool, _a = GOOGLE_A
|
|
|
60
60
|
});
|
|
61
61
|
this[_a] = true;
|
|
62
62
|
this.restApiTool = restApiTool;
|
|
63
|
+
if (options.clientId !== void 0 || options.clientSecret !== void 0) {
|
|
64
|
+
this.configureAuth(options.clientId, options.clientSecret);
|
|
65
|
+
}
|
|
63
66
|
}
|
|
64
67
|
_getDeclaration() {
|
|
65
68
|
return this.restApiTool._getDeclaration();
|