@google/adk 2.4.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 +282 -55
- package/dist/cjs/agents/base_agent.js +111 -68
- package/dist/cjs/agents/functions.js +62 -85
- package/dist/cjs/agents/instructions.js +7 -6
- package/dist/cjs/agents/invocation_context.js +2 -2
- package/dist/cjs/agents/llm_agent.js +105 -95
- package/dist/cjs/agents/processors/content_processor_utils.js +42 -15
- package/dist/cjs/agents/processors/content_request_processor.js +28 -11
- 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 +2 -1
- 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 +128 -9
- package/dist/cjs/cli/utils/path_validation.js +83 -0
- package/dist/cjs/code_executors/container_code_executor.js +158 -36
- package/dist/cjs/common.js +50 -12
- package/dist/cjs/context/compaction_utils.js +19 -0
- package/dist/cjs/events/event.js +7 -3
- package/dist/cjs/features/feature_registry.js +5 -0
- package/dist/cjs/index.js +29 -14
- 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 +45 -21
- 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 +1 -4
- package/dist/cjs/sessions/database_session_service.js +191 -19
- 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/vertex_ai_session_service.js +11 -3
- package/dist/cjs/skills/loader.js +29 -28
- 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 -5
- package/dist/cjs/tools/agent_tool.js +9 -1
- package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +22 -34
- package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +60 -20
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +26 -10
- package/dist/cjs/tools/application_integration_tool/integration_connector_tool.js +14 -23
- 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_toolset.js +3 -2
- package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +3 -1
- package/dist/cjs/tools/load_artifacts_tool.js +15 -5
- package/dist/cjs/tools/load_memory_tool.js +2 -5
- 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 +18 -6
- package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +30 -29
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -2
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +45 -14
- 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 +47 -28
- package/dist/cjs/utils/async_queue.js +37 -3
- package/dist/cjs/utils/client_labels.js +9 -11
- 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 +10 -9
- package/dist/cjs/utils/gemini_schema_util.js +125 -12
- package/dist/cjs/utils/id_provider.js +63 -0
- package/dist/cjs/utils/model_name.js +15 -0
- package/dist/cjs/utils/simple_zod_to_json.js +13 -31
- package/dist/cjs/utils/ssrf_guard.js +46 -16
- 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 +293 -55
- package/dist/esm/agents/base_agent.js +111 -72
- package/dist/esm/agents/functions.js +67 -89
- package/dist/esm/agents/instructions.js +7 -6
- package/dist/esm/agents/invocation_context.js +2 -2
- package/dist/esm/agents/llm_agent.js +111 -100
- package/dist/esm/agents/processors/content_processor_utils.js +42 -15
- package/dist/esm/agents/processors/content_request_processor.js +28 -11
- 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 +2 -1
- 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 +128 -9
- package/dist/esm/cli/utils/path_validation.js +45 -0
- package/dist/esm/code_executors/container_code_executor.js +158 -36
- package/dist/esm/common.js +49 -6
- package/dist/esm/context/compaction_utils.js +19 -0
- package/dist/esm/events/event.js +7 -3
- package/dist/esm/features/feature_registry.js +5 -0
- package/dist/esm/index.js +27 -15
- 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 +45 -21
- 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 +1 -4
- package/dist/esm/sessions/database_session_service.js +191 -19
- 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/vertex_ai_session_service.js +11 -3
- package/dist/esm/skills/loader.js +29 -28
- 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/application_integration_tool/application_integration_toolset.js +23 -35
- package/dist/esm/tools/application_integration_tool/clients/connections_client.js +64 -21
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +26 -10
- package/dist/esm/tools/application_integration_tool/integration_connector_tool.js +14 -23
- 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_toolset.js +3 -2
- package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +3 -1
- package/dist/esm/tools/load_artifacts_tool.js +15 -5
- package/dist/esm/tools/load_memory_tool.js +2 -5
- 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 +18 -6
- package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +27 -26
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -2
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +45 -14
- 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 +47 -28
- package/dist/esm/utils/async_queue.js +37 -3
- package/dist/esm/utils/client_labels.js +9 -11
- 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 +10 -9
- package/dist/esm/utils/gemini_schema_util.js +124 -11
- package/dist/esm/utils/id_provider.js +33 -0
- package/dist/esm/utils/model_name.js +14 -0
- package/dist/esm/utils/simple_zod_to_json.js +13 -31
- package/dist/esm/utils/ssrf_guard.js +55 -15
- 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 +121 -3
- package/dist/types/agents/base_agent.d.ts +2 -0
- package/dist/types/agents/processors/content_processor_utils.d.ts +9 -9
- 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 +19 -2
- package/dist/types/cli/utils/path_validation.d.ts +30 -0
- package/dist/types/code_executors/container_code_executor.d.ts +49 -8
- package/dist/types/common.d.ts +16 -9
- package/dist/types/context/compaction_utils.d.ts +13 -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 +9 -6
- package/dist/types/plugins/base_plugin.d.ts +50 -21
- 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 +0 -2
- package/dist/types/sessions/db/operations.d.ts +2 -1
- package/dist/types/sessions/db/schema.d.ts +5 -3
- 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/application_integration_tool/clients/connections_client.d.ts +13 -4
- package/dist/types/tools/base_toolset.d.ts +1 -1
- 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_toolset.d.ts +2 -0
- package/dist/types/tools/load_artifacts_tool.d.ts +5 -1
- package/dist/types/tools/load_memory_tool.d.ts +13 -7
- 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/operation_parser.d.ts +7 -3
- package/dist/types/tools/toolbox_toolset.d.ts +15 -20
- package/dist/types/utils/async_queue.d.ts +14 -0
- 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 +27 -6
- package/dist/types/utils/id_provider.d.ts +43 -0
- package/dist/types/utils/model_name.d.ts +8 -0
- 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 +86 -88
- package/dist/web/index_web.js.map +4 -4
- package/package.json +13 -15
- package/dist/cjs/telemetry/google_cloud.js +0 -116
- package/dist/cjs/telemetry/tracing.js +0 -393
- package/dist/esm/telemetry/google_cloud.js +0 -99
- package/dist/esm/telemetry/setup.js +0 -88
- package/dist/esm/telemetry/tracing.js +0 -361
- package/dist/types/telemetry/google_cloud.d.ts +0 -9
- package/dist/types/telemetry/tracing.d.ts +0 -143
|
@@ -17,10 +17,14 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
17
17
|
* SPDX-License-Identifier: Apache-2.0
|
|
18
18
|
*/
|
|
19
19
|
import { experimental } from "../../../utils/experimental.js";
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
isJsonObject,
|
|
22
|
+
toJsonObject
|
|
23
|
+
} from "../../../utils/json_utils.js";
|
|
21
24
|
import { CloudPlatformTokenSource, sendCloudRequest } from "./cloud_request.js";
|
|
22
25
|
const CONNECTOR_URL = "https://connectors.googleapis.com";
|
|
23
26
|
const OPERATION_POLL_INTERVAL_MS = 1e3;
|
|
27
|
+
const MAX_OPERATION_POLL_ATTEMPTS = 60;
|
|
24
28
|
function toStringValue(value) {
|
|
25
29
|
return typeof value === "string" ? value : "";
|
|
26
30
|
}
|
|
@@ -29,6 +33,16 @@ function sleep(ms) {
|
|
|
29
33
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
30
34
|
}
|
|
31
35
|
__name(sleep, "sleep");
|
|
36
|
+
function formatOperationError(error) {
|
|
37
|
+
if (typeof error === "string" && error.length > 0) {
|
|
38
|
+
return error;
|
|
39
|
+
}
|
|
40
|
+
if (isJsonObject(error) && typeof error["message"] === "string" && error["message"].length > 0) {
|
|
41
|
+
return error["message"];
|
|
42
|
+
}
|
|
43
|
+
return JSON.stringify(error);
|
|
44
|
+
}
|
|
45
|
+
__name(formatOperationError, "formatOperationError");
|
|
32
46
|
function schemaRef(name) {
|
|
33
47
|
return { $ref: `#/components/schemas/${name}` };
|
|
34
48
|
}
|
|
@@ -110,6 +124,12 @@ const CONNECTOR_BASE_SPEC = {
|
|
|
110
124
|
default: 120,
|
|
111
125
|
description: "Timeout in seconds for execution of custom query"
|
|
112
126
|
},
|
|
127
|
+
sortByColumns: {
|
|
128
|
+
type: "array",
|
|
129
|
+
items: { type: "string" },
|
|
130
|
+
default: [],
|
|
131
|
+
description: "Column to sort the results by"
|
|
132
|
+
},
|
|
113
133
|
connectorOutputPayload: { type: "object" },
|
|
114
134
|
nextPageToken: { type: "string" },
|
|
115
135
|
"execute-connector_Response": {
|
|
@@ -436,7 +456,8 @@ function listOperationRequest(options) {
|
|
|
436
456
|
connectionName: schemaRef("connectionName"),
|
|
437
457
|
serviceName: schemaRef("serviceName"),
|
|
438
458
|
host: schemaRef("host"),
|
|
439
|
-
entity: schemaRef("entity")
|
|
459
|
+
entity: schemaRef("entity"),
|
|
460
|
+
sortByColumns: schemaRef("sortByColumns")
|
|
440
461
|
};
|
|
441
462
|
if (options == null ? void 0 : options.includeDynamicAuthConfig) {
|
|
442
463
|
properties["dynamicAuthConfig"] = schemaRef("dynamicAuthConfig");
|
|
@@ -483,7 +504,20 @@ function actionResponse(action) {
|
|
|
483
504
|
};
|
|
484
505
|
}
|
|
485
506
|
__name(actionResponse, "actionResponse");
|
|
486
|
-
function executeCustomQueryRequest() {
|
|
507
|
+
function executeCustomQueryRequest(options) {
|
|
508
|
+
const properties = {
|
|
509
|
+
operation: schemaRef("operation"),
|
|
510
|
+
connectionName: schemaRef("connectionName"),
|
|
511
|
+
serviceName: schemaRef("serviceName"),
|
|
512
|
+
host: schemaRef("host"),
|
|
513
|
+
action: schemaRef("action"),
|
|
514
|
+
query: schemaRef("query"),
|
|
515
|
+
timeout: schemaRef("timeout"),
|
|
516
|
+
pageSize: schemaRef("pageSize")
|
|
517
|
+
};
|
|
518
|
+
if (options == null ? void 0 : options.includeDynamicAuthConfig) {
|
|
519
|
+
properties["dynamicAuthConfig"] = schemaRef("dynamicAuthConfig");
|
|
520
|
+
}
|
|
487
521
|
return {
|
|
488
522
|
type: "object",
|
|
489
523
|
required: [
|
|
@@ -496,16 +530,7 @@ function executeCustomQueryRequest() {
|
|
|
496
530
|
"timeout",
|
|
497
531
|
"pageSize"
|
|
498
532
|
],
|
|
499
|
-
properties
|
|
500
|
-
operation: schemaRef("operation"),
|
|
501
|
-
connectionName: schemaRef("connectionName"),
|
|
502
|
-
serviceName: schemaRef("serviceName"),
|
|
503
|
-
host: schemaRef("host"),
|
|
504
|
-
action: schemaRef("action"),
|
|
505
|
-
query: schemaRef("query"),
|
|
506
|
-
timeout: schemaRef("timeout"),
|
|
507
|
-
pageSize: schemaRef("pageSize")
|
|
508
|
-
}
|
|
533
|
+
properties
|
|
509
534
|
};
|
|
510
535
|
}
|
|
511
536
|
__name(executeCustomQueryRequest, "executeCustomQueryRequest");
|
|
@@ -533,7 +558,8 @@ let ConnectionsClient = class {
|
|
|
533
558
|
* Reads the JSON schema of an entity and the operations it supports.
|
|
534
559
|
*
|
|
535
560
|
* @param entity The entity name.
|
|
536
|
-
* @throws Error When the API starts no operation for the entity
|
|
561
|
+
* @throws Error When the API starts no operation for the entity, or the
|
|
562
|
+
* operation fails or times out.
|
|
537
563
|
*/
|
|
538
564
|
async getEntitySchemaAndOperations(entity) {
|
|
539
565
|
const url = `${CONNECTOR_URL}/v1/projects/${this.project}/locations/${this.location}/connections/${this.connection}/connectionSchemaMetadata:getEntityType?entityId=${entity}`;
|
|
@@ -558,7 +584,8 @@ let ConnectionsClient = class {
|
|
|
558
584
|
* Reads the input and output JSON schemas of an action.
|
|
559
585
|
*
|
|
560
586
|
* @param action The action name.
|
|
561
|
-
* @throws Error When the API starts no operation for the action
|
|
587
|
+
* @throws Error When the API starts no operation for the action, or the
|
|
588
|
+
* operation fails or times out.
|
|
562
589
|
*/
|
|
563
590
|
async getActionSchema(action) {
|
|
564
591
|
const url = `${CONNECTOR_URL}/v1/projects/${this.project}/locations/${this.location}/connections/${this.connection}/connectionSchemaMetadata:getAction?actionId=${action}`;
|
|
@@ -593,15 +620,31 @@ let ConnectionsClient = class {
|
|
|
593
620
|
invalidRequestMessage: `Invalid request. Please check the provided values of project(${this.project}), location(${this.location}), connection(${this.connection}).`
|
|
594
621
|
});
|
|
595
622
|
}
|
|
596
|
-
/**
|
|
623
|
+
/**
|
|
624
|
+
* Polls a long-running operation until it reports `done`.
|
|
625
|
+
*
|
|
626
|
+
* @throws Error When the operation reports an `error` or does not finish
|
|
627
|
+
* within `MAX_OPERATION_POLL_ATTEMPTS` polls.
|
|
628
|
+
*/
|
|
597
629
|
async pollOperation(operationId) {
|
|
598
630
|
const url = `${CONNECTOR_URL}/v1/${operationId}`;
|
|
599
|
-
let
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
631
|
+
for (let attempt = 0; attempt < MAX_OPERATION_POLL_ATTEMPTS; attempt++) {
|
|
632
|
+
if (attempt > 0) {
|
|
633
|
+
await sleep(OPERATION_POLL_INTERVAL_MS);
|
|
634
|
+
}
|
|
635
|
+
const operation = toJsonObject(await this.executeApiCall(url));
|
|
636
|
+
if (operation["error"]) {
|
|
637
|
+
throw new Error(
|
|
638
|
+
`Operation ${operationId} failed: ${formatOperationError(operation["error"])}`
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
if (operation["done"] === true) {
|
|
642
|
+
return operation;
|
|
643
|
+
}
|
|
603
644
|
}
|
|
604
|
-
|
|
645
|
+
throw new Error(
|
|
646
|
+
`Operation ${operationId} timed out after ${MAX_OPERATION_POLL_ATTEMPTS} poll attempts.`
|
|
647
|
+
);
|
|
605
648
|
}
|
|
606
649
|
};
|
|
607
650
|
__name(ConnectionsClient, "ConnectionsClient");
|
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
} from "./connections_client.js";
|
|
45
45
|
const EXECUTE_CONNECTION_INTEGRATION = "ExecuteConnection";
|
|
46
46
|
const EXECUTE_CUSTOM_QUERY_ACTION = "ExecuteCustomQuery";
|
|
47
|
+
const REQUEST_SCHEMA_OPTIONS = Object.freeze({ includeDynamicAuthConfig: true });
|
|
47
48
|
let IntegrationClient = class {
|
|
48
49
|
constructor(options) {
|
|
49
50
|
var _a, _b;
|
|
@@ -65,9 +66,7 @@ let IntegrationClient = class {
|
|
|
65
66
|
* that carries no parseable spec.
|
|
66
67
|
*/
|
|
67
68
|
async getOpenApiSpecForIntegration() {
|
|
68
|
-
var _a;
|
|
69
69
|
const url = `https://${this.location}-integrations.googleapis.com/v1/projects/${this.project}/locations/${this.location}:generateOpenApiSpec`;
|
|
70
|
-
const triggerId = (_a = this.triggers) != null ? _a : null;
|
|
71
70
|
const invalidRequestMessage = `Invalid request. Please check the provided values of project(${this.project}), location(${this.location}), integration(${this.integration}).`;
|
|
72
71
|
const body = await sendCloudRequest({
|
|
73
72
|
url,
|
|
@@ -76,7 +75,7 @@ let IntegrationClient = class {
|
|
|
76
75
|
apiTriggerResources: [
|
|
77
76
|
{
|
|
78
77
|
integrationResource: this.integration,
|
|
79
|
-
triggerId
|
|
78
|
+
triggerId: this.triggers
|
|
80
79
|
}
|
|
81
80
|
],
|
|
82
81
|
fileFormat: "JSON"
|
|
@@ -143,7 +142,10 @@ let IntegrationClient = class {
|
|
|
143
142
|
toolName,
|
|
144
143
|
toolInstructions
|
|
145
144
|
});
|
|
146
|
-
schemas[`create_${entity}_Request`] = createOperationRequest(
|
|
145
|
+
schemas[`create_${entity}_Request`] = createOperationRequest(
|
|
146
|
+
entity,
|
|
147
|
+
REQUEST_SCHEMA_OPTIONS
|
|
148
|
+
);
|
|
147
149
|
break;
|
|
148
150
|
case "update":
|
|
149
151
|
connectorSpec.paths[path] = updateOperation({
|
|
@@ -151,7 +153,10 @@ let IntegrationClient = class {
|
|
|
151
153
|
toolName,
|
|
152
154
|
toolInstructions
|
|
153
155
|
});
|
|
154
|
-
schemas[`update_${entity}_Request`] = updateOperationRequest(
|
|
156
|
+
schemas[`update_${entity}_Request`] = updateOperationRequest(
|
|
157
|
+
entity,
|
|
158
|
+
REQUEST_SCHEMA_OPTIONS
|
|
159
|
+
);
|
|
155
160
|
break;
|
|
156
161
|
case "delete":
|
|
157
162
|
connectorSpec.paths[path] = deleteOperation({
|
|
@@ -159,7 +164,9 @@ let IntegrationClient = class {
|
|
|
159
164
|
toolName,
|
|
160
165
|
toolInstructions
|
|
161
166
|
});
|
|
162
|
-
schemas[`delete_${entity}_Request`] = deleteOperationRequest(
|
|
167
|
+
schemas[`delete_${entity}_Request`] = deleteOperationRequest(
|
|
168
|
+
REQUEST_SCHEMA_OPTIONS
|
|
169
|
+
);
|
|
163
170
|
break;
|
|
164
171
|
case "list":
|
|
165
172
|
connectorSpec.paths[path] = listOperation({
|
|
@@ -168,7 +175,9 @@ let IntegrationClient = class {
|
|
|
168
175
|
toolName,
|
|
169
176
|
toolInstructions
|
|
170
177
|
});
|
|
171
|
-
schemas[`list_${entity}_Request`] = listOperationRequest(
|
|
178
|
+
schemas[`list_${entity}_Request`] = listOperationRequest(
|
|
179
|
+
REQUEST_SCHEMA_OPTIONS
|
|
180
|
+
);
|
|
172
181
|
break;
|
|
173
182
|
case "get":
|
|
174
183
|
connectorSpec.paths[path] = getOperation({
|
|
@@ -177,7 +186,9 @@ let IntegrationClient = class {
|
|
|
177
186
|
toolName,
|
|
178
187
|
toolInstructions
|
|
179
188
|
});
|
|
180
|
-
schemas[`get_${entity}_Request`] = getOperationRequest(
|
|
189
|
+
schemas[`get_${entity}_Request`] = getOperationRequest(
|
|
190
|
+
REQUEST_SCHEMA_OPTIONS
|
|
191
|
+
);
|
|
181
192
|
break;
|
|
182
193
|
default:
|
|
183
194
|
throw new Error(
|
|
@@ -191,10 +202,15 @@ let IntegrationClient = class {
|
|
|
191
202
|
const actionDisplayName = displayName.replace(/ /g, "");
|
|
192
203
|
let operation = "EXECUTE_ACTION";
|
|
193
204
|
if (action === EXECUTE_CUSTOM_QUERY_ACTION) {
|
|
194
|
-
schemas[`${actionDisplayName}_Request`] = executeCustomQueryRequest(
|
|
205
|
+
schemas[`${actionDisplayName}_Request`] = executeCustomQueryRequest(
|
|
206
|
+
REQUEST_SCHEMA_OPTIONS
|
|
207
|
+
);
|
|
195
208
|
operation = "EXECUTE_QUERY";
|
|
196
209
|
} else {
|
|
197
|
-
schemas[`${actionDisplayName}_Request`] = actionRequest(
|
|
210
|
+
schemas[`${actionDisplayName}_Request`] = actionRequest(
|
|
211
|
+
actionDisplayName,
|
|
212
|
+
REQUEST_SCHEMA_OPTIONS
|
|
213
|
+
);
|
|
198
214
|
schemas[`connectorInputPayload_${actionDisplayName}`] = connectorPayload(inputSchema);
|
|
199
215
|
}
|
|
200
216
|
schemas[`connectorOutputPayload_${actionDisplayName}`] = connectorPayload(outputSchema);
|
|
@@ -20,10 +20,7 @@ import { experimental } from "../../utils/experimental.js";
|
|
|
20
20
|
import { logger } from "../../utils/logger.js";
|
|
21
21
|
import { BaseTool } from "../base_tool.js";
|
|
22
22
|
import { ToolAuthHandler } from "../openapi_tool/openapi_spec_parser/tool_auth_handler.js";
|
|
23
|
-
const
|
|
24
|
-
"dynamic_auth_config",
|
|
25
|
-
"dynamicAuthConfig"
|
|
26
|
-
]);
|
|
23
|
+
const DYNAMIC_AUTH_CONFIG_FIELD = "dynamicAuthConfig";
|
|
27
24
|
let IntegrationConnectorTool = class extends BaseTool {
|
|
28
25
|
constructor(options) {
|
|
29
26
|
var _a, _b, _c;
|
|
@@ -46,17 +43,15 @@ let IntegrationConnectorTool = class extends BaseTool {
|
|
|
46
43
|
parameters = { ...rawParameters };
|
|
47
44
|
if (rawParameters.properties) {
|
|
48
45
|
const properties = { ...rawParameters.properties };
|
|
49
|
-
for (const field of
|
|
50
|
-
...IntegrationConnectorTool.EXCLUDE_FIELDS,
|
|
51
|
-
...DYNAMIC_AUTH_EXCLUDE_FIELDS
|
|
52
|
-
]) {
|
|
46
|
+
for (const field of IntegrationConnectorTool.EXCLUDE_FIELDS) {
|
|
53
47
|
delete properties[field];
|
|
54
48
|
}
|
|
49
|
+
delete properties[DYNAMIC_AUTH_CONFIG_FIELD];
|
|
55
50
|
parameters.properties = properties;
|
|
56
51
|
}
|
|
57
52
|
if (rawParameters.required) {
|
|
58
53
|
parameters.required = rawParameters.required.filter(
|
|
59
|
-
(field) => !IntegrationConnectorTool.EXCLUDE_FIELDS.includes(field) &&
|
|
54
|
+
(field) => !IntegrationConnectorTool.EXCLUDE_FIELDS.includes(field) && field !== DYNAMIC_AUTH_CONFIG_FIELD && !IntegrationConnectorTool.OPTIONAL_FIELDS.includes(field)
|
|
60
55
|
);
|
|
61
56
|
}
|
|
62
57
|
}
|
|
@@ -81,9 +76,7 @@ let IntegrationConnectorTool = class extends BaseTool {
|
|
|
81
76
|
}
|
|
82
77
|
const updatedArgs = {
|
|
83
78
|
...request.args,
|
|
84
|
-
connection_name: this.connectionName,
|
|
85
79
|
connectionName: this.connectionName,
|
|
86
|
-
service_name: this.connectionServiceName,
|
|
87
80
|
serviceName: this.connectionServiceName,
|
|
88
81
|
host: this.connectionHost
|
|
89
82
|
};
|
|
@@ -98,11 +91,14 @@ let IntegrationConnectorTool = class extends BaseTool {
|
|
|
98
91
|
}
|
|
99
92
|
if (authResult.authCredential) {
|
|
100
93
|
const token = prepareDynamicEuc(authResult.authCredential);
|
|
101
|
-
|
|
102
|
-
|
|
94
|
+
if (!token) {
|
|
95
|
+
return {
|
|
96
|
+
error: "The resolved end-user credential has no access token."
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
updatedArgs[DYNAMIC_AUTH_CONFIG_FIELD] = {
|
|
100
|
+
"oauth2_auth_code_flow.access_token": token
|
|
103
101
|
};
|
|
104
|
-
updatedArgs["dynamic_auth_config"] = dynamicAuthPayload;
|
|
105
|
-
updatedArgs["dynamicAuthConfig"] = dynamicAuthPayload;
|
|
106
102
|
}
|
|
107
103
|
logger.debug(`Running tool: ${this.name}`);
|
|
108
104
|
return this.restApiTool.runAsync({
|
|
@@ -117,9 +113,7 @@ __name(IntegrationConnectorTool, "IntegrationConnectorTool");
|
|
|
117
113
|
* excludes from the function declaration shown to the model.
|
|
118
114
|
*/
|
|
119
115
|
IntegrationConnectorTool.EXCLUDE_FIELDS = Object.freeze([
|
|
120
|
-
"connection_name",
|
|
121
116
|
"connectionName",
|
|
122
|
-
"service_name",
|
|
123
117
|
"serviceName",
|
|
124
118
|
"host",
|
|
125
119
|
"entity",
|
|
@@ -131,13 +125,10 @@ IntegrationConnectorTool.EXCLUDE_FIELDS = Object.freeze([
|
|
|
131
125
|
* `required` list in the function declaration shown to the model.
|
|
132
126
|
*/
|
|
133
127
|
IntegrationConnectorTool.OPTIONAL_FIELDS = Object.freeze([
|
|
134
|
-
"page_size",
|
|
135
128
|
"pageSize",
|
|
136
|
-
"page_token",
|
|
137
129
|
"pageToken",
|
|
138
|
-
"
|
|
139
|
-
"
|
|
140
|
-
"filterClause"
|
|
130
|
+
"filterClause",
|
|
131
|
+
"sortByColumns"
|
|
141
132
|
]);
|
|
142
133
|
__decorateClass([
|
|
143
134
|
experimental
|
|
@@ -150,7 +141,7 @@ IntegrationConnectorTool = __decorateClass([
|
|
|
150
141
|
], IntegrationConnectorTool);
|
|
151
142
|
function prepareDynamicEuc(authCredential) {
|
|
152
143
|
var _a, _b;
|
|
153
|
-
return (
|
|
144
|
+
return (_b = (_a = authCredential.http) == null ? void 0 : _a.credentials) == null ? void 0 : _b.token;
|
|
154
145
|
}
|
|
155
146
|
__name(prepareDynamicEuc, "prepareDynamicEuc");
|
|
156
147
|
export {
|
|
@@ -15,7 +15,7 @@ function isBaseToolset(obj) {
|
|
|
15
15
|
__name(isBaseToolset, "isBaseToolset");
|
|
16
16
|
_a = BASE_TOOLSET_SIGNATURE_SYMBOL;
|
|
17
17
|
const _BaseToolset = class _BaseToolset {
|
|
18
|
-
constructor(toolFilter, prefix) {
|
|
18
|
+
constructor(toolFilter = [], prefix) {
|
|
19
19
|
this.toolFilter = toolFilter;
|
|
20
20
|
this.prefix = prefix;
|
|
21
21
|
this[_a] = true;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
7
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
8
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
9
|
+
if (decorator = decorators[i])
|
|
10
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
11
|
+
if (kind && result) __defProp(target, key, result);
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @license
|
|
16
|
+
* Copyright 2026 Google LLC
|
|
17
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
18
|
+
*/
|
|
19
|
+
var _a;
|
|
20
|
+
import {
|
|
21
|
+
FeatureName,
|
|
22
|
+
isFeatureEnabled
|
|
23
|
+
} from "../../features/feature_registry.js";
|
|
24
|
+
import { experimental } from "../../utils/experimental.js";
|
|
25
|
+
var ComputerEnvironment = /* @__PURE__ */ ((ComputerEnvironment2) => {
|
|
26
|
+
ComputerEnvironment2["ENVIRONMENT_UNSPECIFIED"] = "ENVIRONMENT_UNSPECIFIED";
|
|
27
|
+
ComputerEnvironment2["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
|
|
28
|
+
return ComputerEnvironment2;
|
|
29
|
+
})(ComputerEnvironment || {});
|
|
30
|
+
function checkComputerUseEnabled() {
|
|
31
|
+
if (!isFeatureEnabled(FeatureName.COMPUTER_USE)) {
|
|
32
|
+
throw new Error(`Feature ${FeatureName.COMPUTER_USE} is not enabled.`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
__name(checkComputerUseEnabled, "checkComputerUseEnabled");
|
|
36
|
+
const BASE_COMPUTER_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for("google.adk.baseComputer");
|
|
37
|
+
function isBaseComputer(obj) {
|
|
38
|
+
return typeof obj === "object" && obj !== null && BASE_COMPUTER_SIGNATURE_SYMBOL in obj && obj[BASE_COMPUTER_SIGNATURE_SYMBOL] === true;
|
|
39
|
+
}
|
|
40
|
+
__name(isBaseComputer, "isBaseComputer");
|
|
41
|
+
_a = BASE_COMPUTER_SIGNATURE_SYMBOL;
|
|
42
|
+
let BaseComputer = class {
|
|
43
|
+
constructor() {
|
|
44
|
+
/** A unique symbol to identify ADK base computer class. */
|
|
45
|
+
this[_a] = true;
|
|
46
|
+
checkComputerUseEnabled();
|
|
47
|
+
}
|
|
48
|
+
/** Initializes the computer. */
|
|
49
|
+
async initialize() {
|
|
50
|
+
}
|
|
51
|
+
/** Cleans up the resources of the computer. */
|
|
52
|
+
async close() {
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Called before each tool invocation to prepare resources.
|
|
56
|
+
*
|
|
57
|
+
* Override this to set up session-level resources (a sandbox, tokens, and so
|
|
58
|
+
* on), using the state of `toolContext` for persistence across invocations.
|
|
59
|
+
*
|
|
60
|
+
* @param _toolContext The tool context with session state access.
|
|
61
|
+
*/
|
|
62
|
+
async prepare(_toolContext) {
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Types text into the currently focused element.
|
|
66
|
+
*
|
|
67
|
+
* By default, this calls {@link keyCombination} once per character in `text`
|
|
68
|
+
* (and once for `"Enter"` when `pressEnter` is true). Because
|
|
69
|
+
* `keyCombination` is designed for key names and typically captures a new
|
|
70
|
+
* screenshot on every call, this fallback costs one round trip and screenshot
|
|
71
|
+
* per character, and relies on the backend accepting single characters in
|
|
72
|
+
* `keyCombination`. Subclasses should override this method to use native
|
|
73
|
+
* bulk text input.
|
|
74
|
+
*
|
|
75
|
+
* @param text The text to type.
|
|
76
|
+
* @param pressEnter Whether to press ENTER after typing.
|
|
77
|
+
* @returns The current state after typing.
|
|
78
|
+
*/
|
|
79
|
+
async typeText(text, pressEnter = false) {
|
|
80
|
+
let state;
|
|
81
|
+
for (const char of text) {
|
|
82
|
+
state = await this.keyCombination([char]);
|
|
83
|
+
}
|
|
84
|
+
if (pressEnter) {
|
|
85
|
+
state = await this.keyCombination(["Enter"]);
|
|
86
|
+
}
|
|
87
|
+
return state != null ? state : this.currentState();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
__name(BaseComputer, "BaseComputer");
|
|
91
|
+
BaseComputer = __decorateClass([
|
|
92
|
+
experimental
|
|
93
|
+
], BaseComputer);
|
|
94
|
+
export {
|
|
95
|
+
BaseComputer,
|
|
96
|
+
ComputerEnvironment,
|
|
97
|
+
checkComputerUseEnabled,
|
|
98
|
+
isBaseComputer
|
|
99
|
+
};
|