@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
|
@@ -62,6 +62,7 @@ var import_cloud_request = require("./cloud_request.js");
|
|
|
62
62
|
*/
|
|
63
63
|
const CONNECTOR_URL = "https://connectors.googleapis.com";
|
|
64
64
|
const OPERATION_POLL_INTERVAL_MS = 1e3;
|
|
65
|
+
const MAX_OPERATION_POLL_ATTEMPTS = 60;
|
|
65
66
|
function toStringValue(value) {
|
|
66
67
|
return typeof value === "string" ? value : "";
|
|
67
68
|
}
|
|
@@ -70,6 +71,16 @@ function sleep(ms) {
|
|
|
70
71
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
71
72
|
}
|
|
72
73
|
__name(sleep, "sleep");
|
|
74
|
+
function formatOperationError(error) {
|
|
75
|
+
if (typeof error === "string" && error.length > 0) {
|
|
76
|
+
return error;
|
|
77
|
+
}
|
|
78
|
+
if ((0, import_json_utils.isJsonObject)(error) && typeof error["message"] === "string" && error["message"].length > 0) {
|
|
79
|
+
return error["message"];
|
|
80
|
+
}
|
|
81
|
+
return JSON.stringify(error);
|
|
82
|
+
}
|
|
83
|
+
__name(formatOperationError, "formatOperationError");
|
|
73
84
|
function schemaRef(name) {
|
|
74
85
|
return { $ref: `#/components/schemas/${name}` };
|
|
75
86
|
}
|
|
@@ -151,6 +162,12 @@ const CONNECTOR_BASE_SPEC = {
|
|
|
151
162
|
default: 120,
|
|
152
163
|
description: "Timeout in seconds for execution of custom query"
|
|
153
164
|
},
|
|
165
|
+
sortByColumns: {
|
|
166
|
+
type: "array",
|
|
167
|
+
items: { type: "string" },
|
|
168
|
+
default: [],
|
|
169
|
+
description: "Column to sort the results by"
|
|
170
|
+
},
|
|
154
171
|
connectorOutputPayload: { type: "object" },
|
|
155
172
|
nextPageToken: { type: "string" },
|
|
156
173
|
"execute-connector_Response": {
|
|
@@ -477,7 +494,8 @@ function listOperationRequest(options) {
|
|
|
477
494
|
connectionName: schemaRef("connectionName"),
|
|
478
495
|
serviceName: schemaRef("serviceName"),
|
|
479
496
|
host: schemaRef("host"),
|
|
480
|
-
entity: schemaRef("entity")
|
|
497
|
+
entity: schemaRef("entity"),
|
|
498
|
+
sortByColumns: schemaRef("sortByColumns")
|
|
481
499
|
};
|
|
482
500
|
if (options == null ? void 0 : options.includeDynamicAuthConfig) {
|
|
483
501
|
properties["dynamicAuthConfig"] = schemaRef("dynamicAuthConfig");
|
|
@@ -524,7 +542,20 @@ function actionResponse(action) {
|
|
|
524
542
|
};
|
|
525
543
|
}
|
|
526
544
|
__name(actionResponse, "actionResponse");
|
|
527
|
-
function executeCustomQueryRequest() {
|
|
545
|
+
function executeCustomQueryRequest(options) {
|
|
546
|
+
const properties = {
|
|
547
|
+
operation: schemaRef("operation"),
|
|
548
|
+
connectionName: schemaRef("connectionName"),
|
|
549
|
+
serviceName: schemaRef("serviceName"),
|
|
550
|
+
host: schemaRef("host"),
|
|
551
|
+
action: schemaRef("action"),
|
|
552
|
+
query: schemaRef("query"),
|
|
553
|
+
timeout: schemaRef("timeout"),
|
|
554
|
+
pageSize: schemaRef("pageSize")
|
|
555
|
+
};
|
|
556
|
+
if (options == null ? void 0 : options.includeDynamicAuthConfig) {
|
|
557
|
+
properties["dynamicAuthConfig"] = schemaRef("dynamicAuthConfig");
|
|
558
|
+
}
|
|
528
559
|
return {
|
|
529
560
|
type: "object",
|
|
530
561
|
required: [
|
|
@@ -537,16 +568,7 @@ function executeCustomQueryRequest() {
|
|
|
537
568
|
"timeout",
|
|
538
569
|
"pageSize"
|
|
539
570
|
],
|
|
540
|
-
properties
|
|
541
|
-
operation: schemaRef("operation"),
|
|
542
|
-
connectionName: schemaRef("connectionName"),
|
|
543
|
-
serviceName: schemaRef("serviceName"),
|
|
544
|
-
host: schemaRef("host"),
|
|
545
|
-
action: schemaRef("action"),
|
|
546
|
-
query: schemaRef("query"),
|
|
547
|
-
timeout: schemaRef("timeout"),
|
|
548
|
-
pageSize: schemaRef("pageSize")
|
|
549
|
-
}
|
|
571
|
+
properties
|
|
550
572
|
};
|
|
551
573
|
}
|
|
552
574
|
__name(executeCustomQueryRequest, "executeCustomQueryRequest");
|
|
@@ -574,7 +596,8 @@ let ConnectionsClient = class {
|
|
|
574
596
|
* Reads the JSON schema of an entity and the operations it supports.
|
|
575
597
|
*
|
|
576
598
|
* @param entity The entity name.
|
|
577
|
-
* @throws Error When the API starts no operation for the entity
|
|
599
|
+
* @throws Error When the API starts no operation for the entity, or the
|
|
600
|
+
* operation fails or times out.
|
|
578
601
|
*/
|
|
579
602
|
async getEntitySchemaAndOperations(entity) {
|
|
580
603
|
const url = `${CONNECTOR_URL}/v1/projects/${this.project}/locations/${this.location}/connections/${this.connection}/connectionSchemaMetadata:getEntityType?entityId=${entity}`;
|
|
@@ -599,7 +622,8 @@ let ConnectionsClient = class {
|
|
|
599
622
|
* Reads the input and output JSON schemas of an action.
|
|
600
623
|
*
|
|
601
624
|
* @param action The action name.
|
|
602
|
-
* @throws Error When the API starts no operation for the action
|
|
625
|
+
* @throws Error When the API starts no operation for the action, or the
|
|
626
|
+
* operation fails or times out.
|
|
603
627
|
*/
|
|
604
628
|
async getActionSchema(action) {
|
|
605
629
|
const url = `${CONNECTOR_URL}/v1/projects/${this.project}/locations/${this.location}/connections/${this.connection}/connectionSchemaMetadata:getAction?actionId=${action}`;
|
|
@@ -634,15 +658,31 @@ let ConnectionsClient = class {
|
|
|
634
658
|
invalidRequestMessage: `Invalid request. Please check the provided values of project(${this.project}), location(${this.location}), connection(${this.connection}).`
|
|
635
659
|
});
|
|
636
660
|
}
|
|
637
|
-
/**
|
|
661
|
+
/**
|
|
662
|
+
* Polls a long-running operation until it reports `done`.
|
|
663
|
+
*
|
|
664
|
+
* @throws Error When the operation reports an `error` or does not finish
|
|
665
|
+
* within `MAX_OPERATION_POLL_ATTEMPTS` polls.
|
|
666
|
+
*/
|
|
638
667
|
async pollOperation(operationId) {
|
|
639
668
|
const url = `${CONNECTOR_URL}/v1/${operationId}`;
|
|
640
|
-
let
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
669
|
+
for (let attempt = 0; attempt < MAX_OPERATION_POLL_ATTEMPTS; attempt++) {
|
|
670
|
+
if (attempt > 0) {
|
|
671
|
+
await sleep(OPERATION_POLL_INTERVAL_MS);
|
|
672
|
+
}
|
|
673
|
+
const operation = (0, import_json_utils.toJsonObject)(await this.executeApiCall(url));
|
|
674
|
+
if (operation["error"]) {
|
|
675
|
+
throw new Error(
|
|
676
|
+
`Operation ${operationId} failed: ${formatOperationError(operation["error"])}`
|
|
677
|
+
);
|
|
678
|
+
}
|
|
679
|
+
if (operation["done"] === true) {
|
|
680
|
+
return operation;
|
|
681
|
+
}
|
|
644
682
|
}
|
|
645
|
-
|
|
683
|
+
throw new Error(
|
|
684
|
+
`Operation ${operationId} timed out after ${MAX_OPERATION_POLL_ATTEMPTS} poll attempts.`
|
|
685
|
+
);
|
|
646
686
|
}
|
|
647
687
|
};
|
|
648
688
|
__name(ConnectionsClient, "ConnectionsClient");
|
|
@@ -47,6 +47,7 @@ var import_connections_client = require("./connections_client.js");
|
|
|
47
47
|
*/
|
|
48
48
|
const EXECUTE_CONNECTION_INTEGRATION = "ExecuteConnection";
|
|
49
49
|
const EXECUTE_CUSTOM_QUERY_ACTION = "ExecuteCustomQuery";
|
|
50
|
+
const REQUEST_SCHEMA_OPTIONS = Object.freeze({ includeDynamicAuthConfig: true });
|
|
50
51
|
let IntegrationClient = class {
|
|
51
52
|
constructor(options) {
|
|
52
53
|
var _a, _b;
|
|
@@ -68,9 +69,7 @@ let IntegrationClient = class {
|
|
|
68
69
|
* that carries no parseable spec.
|
|
69
70
|
*/
|
|
70
71
|
async getOpenApiSpecForIntegration() {
|
|
71
|
-
var _a;
|
|
72
72
|
const url = `https://${this.location}-integrations.googleapis.com/v1/projects/${this.project}/locations/${this.location}:generateOpenApiSpec`;
|
|
73
|
-
const triggerId = (_a = this.triggers) != null ? _a : null;
|
|
74
73
|
const invalidRequestMessage = `Invalid request. Please check the provided values of project(${this.project}), location(${this.location}), integration(${this.integration}).`;
|
|
75
74
|
const body = await (0, import_cloud_request.sendCloudRequest)({
|
|
76
75
|
url,
|
|
@@ -79,7 +78,7 @@ let IntegrationClient = class {
|
|
|
79
78
|
apiTriggerResources: [
|
|
80
79
|
{
|
|
81
80
|
integrationResource: this.integration,
|
|
82
|
-
triggerId
|
|
81
|
+
triggerId: this.triggers
|
|
83
82
|
}
|
|
84
83
|
],
|
|
85
84
|
fileFormat: "JSON"
|
|
@@ -146,7 +145,10 @@ let IntegrationClient = class {
|
|
|
146
145
|
toolName,
|
|
147
146
|
toolInstructions
|
|
148
147
|
});
|
|
149
|
-
schemas[`create_${entity}_Request`] = (0, import_connections_client.createOperationRequest)(
|
|
148
|
+
schemas[`create_${entity}_Request`] = (0, import_connections_client.createOperationRequest)(
|
|
149
|
+
entity,
|
|
150
|
+
REQUEST_SCHEMA_OPTIONS
|
|
151
|
+
);
|
|
150
152
|
break;
|
|
151
153
|
case "update":
|
|
152
154
|
connectorSpec.paths[path] = (0, import_connections_client.updateOperation)({
|
|
@@ -154,7 +156,10 @@ let IntegrationClient = class {
|
|
|
154
156
|
toolName,
|
|
155
157
|
toolInstructions
|
|
156
158
|
});
|
|
157
|
-
schemas[`update_${entity}_Request`] = (0, import_connections_client.updateOperationRequest)(
|
|
159
|
+
schemas[`update_${entity}_Request`] = (0, import_connections_client.updateOperationRequest)(
|
|
160
|
+
entity,
|
|
161
|
+
REQUEST_SCHEMA_OPTIONS
|
|
162
|
+
);
|
|
158
163
|
break;
|
|
159
164
|
case "delete":
|
|
160
165
|
connectorSpec.paths[path] = (0, import_connections_client.deleteOperation)({
|
|
@@ -162,7 +167,9 @@ let IntegrationClient = class {
|
|
|
162
167
|
toolName,
|
|
163
168
|
toolInstructions
|
|
164
169
|
});
|
|
165
|
-
schemas[`delete_${entity}_Request`] = (0, import_connections_client.deleteOperationRequest)(
|
|
170
|
+
schemas[`delete_${entity}_Request`] = (0, import_connections_client.deleteOperationRequest)(
|
|
171
|
+
REQUEST_SCHEMA_OPTIONS
|
|
172
|
+
);
|
|
166
173
|
break;
|
|
167
174
|
case "list":
|
|
168
175
|
connectorSpec.paths[path] = (0, import_connections_client.listOperation)({
|
|
@@ -171,7 +178,9 @@ let IntegrationClient = class {
|
|
|
171
178
|
toolName,
|
|
172
179
|
toolInstructions
|
|
173
180
|
});
|
|
174
|
-
schemas[`list_${entity}_Request`] = (0, import_connections_client.listOperationRequest)(
|
|
181
|
+
schemas[`list_${entity}_Request`] = (0, import_connections_client.listOperationRequest)(
|
|
182
|
+
REQUEST_SCHEMA_OPTIONS
|
|
183
|
+
);
|
|
175
184
|
break;
|
|
176
185
|
case "get":
|
|
177
186
|
connectorSpec.paths[path] = (0, import_connections_client.getOperation)({
|
|
@@ -180,7 +189,9 @@ let IntegrationClient = class {
|
|
|
180
189
|
toolName,
|
|
181
190
|
toolInstructions
|
|
182
191
|
});
|
|
183
|
-
schemas[`get_${entity}_Request`] = (0, import_connections_client.getOperationRequest)(
|
|
192
|
+
schemas[`get_${entity}_Request`] = (0, import_connections_client.getOperationRequest)(
|
|
193
|
+
REQUEST_SCHEMA_OPTIONS
|
|
194
|
+
);
|
|
184
195
|
break;
|
|
185
196
|
default:
|
|
186
197
|
throw new Error(
|
|
@@ -194,10 +205,15 @@ let IntegrationClient = class {
|
|
|
194
205
|
const actionDisplayName = displayName.replace(/ /g, "");
|
|
195
206
|
let operation = "EXECUTE_ACTION";
|
|
196
207
|
if (action === EXECUTE_CUSTOM_QUERY_ACTION) {
|
|
197
|
-
schemas[`${actionDisplayName}_Request`] = (0, import_connections_client.executeCustomQueryRequest)(
|
|
208
|
+
schemas[`${actionDisplayName}_Request`] = (0, import_connections_client.executeCustomQueryRequest)(
|
|
209
|
+
REQUEST_SCHEMA_OPTIONS
|
|
210
|
+
);
|
|
198
211
|
operation = "EXECUTE_QUERY";
|
|
199
212
|
} else {
|
|
200
|
-
schemas[`${actionDisplayName}_Request`] = (0, import_connections_client.actionRequest)(
|
|
213
|
+
schemas[`${actionDisplayName}_Request`] = (0, import_connections_client.actionRequest)(
|
|
214
|
+
actionDisplayName,
|
|
215
|
+
REQUEST_SCHEMA_OPTIONS
|
|
216
|
+
);
|
|
201
217
|
schemas[`connectorInputPayload_${actionDisplayName}`] = (0, import_connections_client.connectorPayload)(inputSchema);
|
|
202
218
|
}
|
|
203
219
|
schemas[`connectorOutputPayload_${actionDisplayName}`] = (0, import_connections_client.connectorPayload)(outputSchema);
|
|
@@ -45,10 +45,7 @@ var import_tool_auth_handler = require("../openapi_tool/openapi_spec_parser/tool
|
|
|
45
45
|
* Copyright 2026 Google LLC
|
|
46
46
|
* SPDX-License-Identifier: Apache-2.0
|
|
47
47
|
*/
|
|
48
|
-
const
|
|
49
|
-
"dynamic_auth_config",
|
|
50
|
-
"dynamicAuthConfig"
|
|
51
|
-
]);
|
|
48
|
+
const DYNAMIC_AUTH_CONFIG_FIELD = "dynamicAuthConfig";
|
|
52
49
|
let IntegrationConnectorTool = class extends import_base_tool.BaseTool {
|
|
53
50
|
constructor(options) {
|
|
54
51
|
var _a, _b, _c;
|
|
@@ -71,17 +68,15 @@ let IntegrationConnectorTool = class extends import_base_tool.BaseTool {
|
|
|
71
68
|
parameters = { ...rawParameters };
|
|
72
69
|
if (rawParameters.properties) {
|
|
73
70
|
const properties = { ...rawParameters.properties };
|
|
74
|
-
for (const field of
|
|
75
|
-
...IntegrationConnectorTool.EXCLUDE_FIELDS,
|
|
76
|
-
...DYNAMIC_AUTH_EXCLUDE_FIELDS
|
|
77
|
-
]) {
|
|
71
|
+
for (const field of IntegrationConnectorTool.EXCLUDE_FIELDS) {
|
|
78
72
|
delete properties[field];
|
|
79
73
|
}
|
|
74
|
+
delete properties[DYNAMIC_AUTH_CONFIG_FIELD];
|
|
80
75
|
parameters.properties = properties;
|
|
81
76
|
}
|
|
82
77
|
if (rawParameters.required) {
|
|
83
78
|
parameters.required = rawParameters.required.filter(
|
|
84
|
-
(field) => !IntegrationConnectorTool.EXCLUDE_FIELDS.includes(field) &&
|
|
79
|
+
(field) => !IntegrationConnectorTool.EXCLUDE_FIELDS.includes(field) && field !== DYNAMIC_AUTH_CONFIG_FIELD && !IntegrationConnectorTool.OPTIONAL_FIELDS.includes(field)
|
|
85
80
|
);
|
|
86
81
|
}
|
|
87
82
|
}
|
|
@@ -106,9 +101,7 @@ let IntegrationConnectorTool = class extends import_base_tool.BaseTool {
|
|
|
106
101
|
}
|
|
107
102
|
const updatedArgs = {
|
|
108
103
|
...request.args,
|
|
109
|
-
connection_name: this.connectionName,
|
|
110
104
|
connectionName: this.connectionName,
|
|
111
|
-
service_name: this.connectionServiceName,
|
|
112
105
|
serviceName: this.connectionServiceName,
|
|
113
106
|
host: this.connectionHost
|
|
114
107
|
};
|
|
@@ -123,11 +116,14 @@ let IntegrationConnectorTool = class extends import_base_tool.BaseTool {
|
|
|
123
116
|
}
|
|
124
117
|
if (authResult.authCredential) {
|
|
125
118
|
const token = prepareDynamicEuc(authResult.authCredential);
|
|
126
|
-
|
|
127
|
-
|
|
119
|
+
if (!token) {
|
|
120
|
+
return {
|
|
121
|
+
error: "The resolved end-user credential has no access token."
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
updatedArgs[DYNAMIC_AUTH_CONFIG_FIELD] = {
|
|
125
|
+
"oauth2_auth_code_flow.access_token": token
|
|
128
126
|
};
|
|
129
|
-
updatedArgs["dynamic_auth_config"] = dynamicAuthPayload;
|
|
130
|
-
updatedArgs["dynamicAuthConfig"] = dynamicAuthPayload;
|
|
131
127
|
}
|
|
132
128
|
import_logger.logger.debug(`Running tool: ${this.name}`);
|
|
133
129
|
return this.restApiTool.runAsync({
|
|
@@ -142,9 +138,7 @@ __name(IntegrationConnectorTool, "IntegrationConnectorTool");
|
|
|
142
138
|
* excludes from the function declaration shown to the model.
|
|
143
139
|
*/
|
|
144
140
|
IntegrationConnectorTool.EXCLUDE_FIELDS = Object.freeze([
|
|
145
|
-
"connection_name",
|
|
146
141
|
"connectionName",
|
|
147
|
-
"service_name",
|
|
148
142
|
"serviceName",
|
|
149
143
|
"host",
|
|
150
144
|
"entity",
|
|
@@ -156,13 +150,10 @@ IntegrationConnectorTool.EXCLUDE_FIELDS = Object.freeze([
|
|
|
156
150
|
* `required` list in the function declaration shown to the model.
|
|
157
151
|
*/
|
|
158
152
|
IntegrationConnectorTool.OPTIONAL_FIELDS = Object.freeze([
|
|
159
|
-
"page_size",
|
|
160
153
|
"pageSize",
|
|
161
|
-
"page_token",
|
|
162
154
|
"pageToken",
|
|
163
|
-
"
|
|
164
|
-
"
|
|
165
|
-
"filterClause"
|
|
155
|
+
"filterClause",
|
|
156
|
+
"sortByColumns"
|
|
166
157
|
]);
|
|
167
158
|
__decorateClass([
|
|
168
159
|
import_experimental.experimental
|
|
@@ -175,7 +166,7 @@ IntegrationConnectorTool = __decorateClass([
|
|
|
175
166
|
], IntegrationConnectorTool);
|
|
176
167
|
function prepareDynamicEuc(authCredential) {
|
|
177
168
|
var _a, _b;
|
|
178
|
-
return (
|
|
169
|
+
return (_b = (_a = authCredential.http) == null ? void 0 : _a.credentials) == null ? void 0 : _b.token;
|
|
179
170
|
}
|
|
180
171
|
__name(prepareDynamicEuc, "prepareDynamicEuc");
|
|
181
172
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -42,7 +42,7 @@ function isBaseToolset(obj) {
|
|
|
42
42
|
__name(isBaseToolset, "isBaseToolset");
|
|
43
43
|
_a = BASE_TOOLSET_SIGNATURE_SYMBOL;
|
|
44
44
|
const _BaseToolset = class _BaseToolset {
|
|
45
|
-
constructor(toolFilter, prefix) {
|
|
45
|
+
constructor(toolFilter = [], prefix) {
|
|
46
46
|
this.toolFilter = toolFilter;
|
|
47
47
|
this.prefix = prefix;
|
|
48
48
|
this[_a] = true;
|
|
@@ -0,0 +1,125 @@
|
|
|
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 base_computer_exports = {};
|
|
35
|
+
__export(base_computer_exports, {
|
|
36
|
+
BaseComputer: () => BaseComputer,
|
|
37
|
+
ComputerEnvironment: () => ComputerEnvironment,
|
|
38
|
+
checkComputerUseEnabled: () => checkComputerUseEnabled,
|
|
39
|
+
isBaseComputer: () => isBaseComputer
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(base_computer_exports);
|
|
42
|
+
var import_feature_registry = require("../../features/feature_registry.js");
|
|
43
|
+
var import_experimental = require("../../utils/experimental.js");
|
|
44
|
+
/**
|
|
45
|
+
* @license
|
|
46
|
+
* Copyright 2026 Google LLC
|
|
47
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
48
|
+
*/
|
|
49
|
+
var _a;
|
|
50
|
+
var ComputerEnvironment = /* @__PURE__ */ ((ComputerEnvironment2) => {
|
|
51
|
+
ComputerEnvironment2["ENVIRONMENT_UNSPECIFIED"] = "ENVIRONMENT_UNSPECIFIED";
|
|
52
|
+
ComputerEnvironment2["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
|
|
53
|
+
return ComputerEnvironment2;
|
|
54
|
+
})(ComputerEnvironment || {});
|
|
55
|
+
function checkComputerUseEnabled() {
|
|
56
|
+
if (!(0, import_feature_registry.isFeatureEnabled)(import_feature_registry.FeatureName.COMPUTER_USE)) {
|
|
57
|
+
throw new Error(`Feature ${import_feature_registry.FeatureName.COMPUTER_USE} is not enabled.`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
__name(checkComputerUseEnabled, "checkComputerUseEnabled");
|
|
61
|
+
const BASE_COMPUTER_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for("google.adk.baseComputer");
|
|
62
|
+
function isBaseComputer(obj) {
|
|
63
|
+
return typeof obj === "object" && obj !== null && BASE_COMPUTER_SIGNATURE_SYMBOL in obj && obj[BASE_COMPUTER_SIGNATURE_SYMBOL] === true;
|
|
64
|
+
}
|
|
65
|
+
__name(isBaseComputer, "isBaseComputer");
|
|
66
|
+
_a = BASE_COMPUTER_SIGNATURE_SYMBOL;
|
|
67
|
+
let BaseComputer = class {
|
|
68
|
+
constructor() {
|
|
69
|
+
/** A unique symbol to identify ADK base computer class. */
|
|
70
|
+
this[_a] = true;
|
|
71
|
+
checkComputerUseEnabled();
|
|
72
|
+
}
|
|
73
|
+
/** Initializes the computer. */
|
|
74
|
+
async initialize() {
|
|
75
|
+
}
|
|
76
|
+
/** Cleans up the resources of the computer. */
|
|
77
|
+
async close() {
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Called before each tool invocation to prepare resources.
|
|
81
|
+
*
|
|
82
|
+
* Override this to set up session-level resources (a sandbox, tokens, and so
|
|
83
|
+
* on), using the state of `toolContext` for persistence across invocations.
|
|
84
|
+
*
|
|
85
|
+
* @param _toolContext The tool context with session state access.
|
|
86
|
+
*/
|
|
87
|
+
async prepare(_toolContext) {
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Types text into the currently focused element.
|
|
91
|
+
*
|
|
92
|
+
* By default, this calls {@link keyCombination} once per character in `text`
|
|
93
|
+
* (and once for `"Enter"` when `pressEnter` is true). Because
|
|
94
|
+
* `keyCombination` is designed for key names and typically captures a new
|
|
95
|
+
* screenshot on every call, this fallback costs one round trip and screenshot
|
|
96
|
+
* per character, and relies on the backend accepting single characters in
|
|
97
|
+
* `keyCombination`. Subclasses should override this method to use native
|
|
98
|
+
* bulk text input.
|
|
99
|
+
*
|
|
100
|
+
* @param text The text to type.
|
|
101
|
+
* @param pressEnter Whether to press ENTER after typing.
|
|
102
|
+
* @returns The current state after typing.
|
|
103
|
+
*/
|
|
104
|
+
async typeText(text, pressEnter = false) {
|
|
105
|
+
let state;
|
|
106
|
+
for (const char of text) {
|
|
107
|
+
state = await this.keyCombination([char]);
|
|
108
|
+
}
|
|
109
|
+
if (pressEnter) {
|
|
110
|
+
state = await this.keyCombination(["Enter"]);
|
|
111
|
+
}
|
|
112
|
+
return state != null ? state : this.currentState();
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
__name(BaseComputer, "BaseComputer");
|
|
116
|
+
BaseComputer = __decorateClass([
|
|
117
|
+
import_experimental.experimental
|
|
118
|
+
], BaseComputer);
|
|
119
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
120
|
+
0 && (module.exports = {
|
|
121
|
+
BaseComputer,
|
|
122
|
+
ComputerEnvironment,
|
|
123
|
+
checkComputerUseEnabled,
|
|
124
|
+
isBaseComputer
|
|
125
|
+
});
|