@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
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
createPartFromText,
|
|
13
13
|
GoogleGenAI
|
|
14
14
|
} from "@google/genai";
|
|
15
|
+
import { adaptComputerUseTool } from "../tools/computer_use/computer_use_toolset.js";
|
|
15
16
|
import { isBrowser, isEnterpriseModeEnabled } from "../utils/env_aware_utils.js";
|
|
16
17
|
import { logger } from "../utils/logger.js";
|
|
17
18
|
import { GoogleLLMVariant } from "../utils/variant_utils.js";
|
|
@@ -77,6 +78,7 @@ const _Gemini = class _Gemini extends (_b = BaseLlm, _a = GEMINI_MODEL_SYMBOL, _
|
|
|
77
78
|
*/
|
|
78
79
|
async *generateContentAsync(llmRequest, stream = false, abortSignal) {
|
|
79
80
|
var _a2, _b2;
|
|
81
|
+
await adaptComputerUseRequest(llmRequest);
|
|
80
82
|
if (this.useInteractionsApi) {
|
|
81
83
|
yield* generateContentViaInteractions(this.apiClient, llmRequest, stream);
|
|
82
84
|
return;
|
|
@@ -240,8 +242,14 @@ const _Gemini = class _Gemini extends (_b = BaseLlm, _a = GEMINI_MODEL_SYMBOL, _
|
|
|
240
242
|
for (const content of llmRequest.contents) {
|
|
241
243
|
if (!content.parts) continue;
|
|
242
244
|
for (const part of content.parts) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
+
if (part.inlineData) {
|
|
246
|
+
part.inlineData = { ...part.inlineData };
|
|
247
|
+
removeDisplayNameIfPresent(part.inlineData);
|
|
248
|
+
}
|
|
249
|
+
if (part.fileData) {
|
|
250
|
+
part.fileData = { ...part.fileData };
|
|
251
|
+
removeDisplayNameIfPresent(part.fileData);
|
|
252
|
+
}
|
|
245
253
|
}
|
|
246
254
|
}
|
|
247
255
|
}
|
|
@@ -262,6 +270,29 @@ _Gemini.supportedModels = [
|
|
|
262
270
|
/projects\/.+\/locations\/.+\/publishers\/google\/models\/gemini.+/
|
|
263
271
|
];
|
|
264
272
|
let Gemini = _Gemini;
|
|
273
|
+
async function adaptComputerUseRequest(llmRequest) {
|
|
274
|
+
var _a2, _b2;
|
|
275
|
+
if (!((_b2 = (_a2 = llmRequest.config) == null ? void 0 : _a2.tools) == null ? void 0 : _b2.some(
|
|
276
|
+
(tool) => "computerUse" in tool && tool.computerUse
|
|
277
|
+
))) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
llmRequest.config.systemInstruction = void 0;
|
|
281
|
+
const waitTool = Object.hasOwn(llmRequest.toolsDict, "wait") ? llmRequest.toolsDict["wait"] : void 0;
|
|
282
|
+
await adaptComputerUseTool({
|
|
283
|
+
methodName: "wait",
|
|
284
|
+
adapter: /* @__PURE__ */ __name((waitFunc) => ({
|
|
285
|
+
name: "wait_5_seconds",
|
|
286
|
+
description: "Waits for 5 seconds.",
|
|
287
|
+
execute: /* @__PURE__ */ __name((_args, toolContext) => waitFunc({ seconds: 5 }, toolContext), "execute")
|
|
288
|
+
}), "adapter"),
|
|
289
|
+
llmRequest
|
|
290
|
+
});
|
|
291
|
+
if (waitTool && Object.hasOwn(llmRequest.toolsDict, "wait_5_seconds")) {
|
|
292
|
+
llmRequest.toolsDict["wait"] = waitTool;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
__name(adaptComputerUseRequest, "adaptComputerUseRequest");
|
|
265
296
|
function removeDisplayNameIfPresent(dataObj) {
|
|
266
297
|
if (dataObj && dataObj.displayName) {
|
|
267
298
|
dataObj.displayName = void 0;
|
|
@@ -342,6 +342,9 @@ function convertToolsConfigToInteractionsFormat(config) {
|
|
|
342
342
|
if (t.urlContext) {
|
|
343
343
|
interactionTools.push({ type: "url_context" });
|
|
344
344
|
}
|
|
345
|
+
if (t.computerUse) {
|
|
346
|
+
interactionTools.push({ type: "computer_use" });
|
|
347
|
+
}
|
|
345
348
|
}
|
|
346
349
|
return interactionTools;
|
|
347
350
|
}
|
|
@@ -56,9 +56,9 @@ const _BasePlugin = class _BasePlugin {
|
|
|
56
56
|
*
|
|
57
57
|
* @param _params.invocationContext The context for the entire invocation, containing
|
|
58
58
|
* session information, the root agent, etc.
|
|
59
|
-
* @returns An optional `
|
|
60
|
-
*
|
|
61
|
-
* Return `undefined` to proceed normally.
|
|
59
|
+
* @returns An optional `Content` to be returned to the ADK. Returning a value
|
|
60
|
+
* halts execution of the runner and ends the run with an event containing
|
|
61
|
+
* that content. Return `undefined` to proceed normally.
|
|
62
62
|
*/
|
|
63
63
|
async beforeRunCallback(_params) {
|
|
64
64
|
return;
|
|
@@ -81,10 +81,12 @@ const _BasePlugin = class _BasePlugin {
|
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
|
-
* Callback executed after
|
|
84
|
+
* Callback executed after successful completion, abort, or early iterator close.
|
|
85
85
|
*
|
|
86
86
|
* This is the final callback in the ADK lifecycle, suitable for cleanup,
|
|
87
|
-
* final logging, or reporting tasks.
|
|
87
|
+
* final logging, or reporting tasks. It is skipped when execution fails;
|
|
88
|
+
* {@link onRunErrorCallback} is called instead. Receiving this callback does
|
|
89
|
+
* not imply success: recognized cancellation still propagates to the caller.
|
|
88
90
|
*
|
|
89
91
|
* @param _params.invocationContext The context for the entire invocation.
|
|
90
92
|
* @returns undefined
|
|
@@ -92,6 +94,23 @@ const _BasePlugin = class _BasePlugin {
|
|
|
92
94
|
async afterRunCallback(_params) {
|
|
93
95
|
return;
|
|
94
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Observes an error escaping an agent's execution or lifecycle callbacks.
|
|
99
|
+
*
|
|
100
|
+
* Notification-only: return values are ignored and callback failures are
|
|
101
|
+
* logged. The original execution error always propagates.
|
|
102
|
+
*/
|
|
103
|
+
async onAgentErrorCallback(_params) {
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Observes an error in the run lifecycle, including before/after-run callbacks.
|
|
107
|
+
*
|
|
108
|
+
* Notification-only: return values are ignored and callback failures are
|
|
109
|
+
* logged. The original execution error always propagates. A completion-hook
|
|
110
|
+
* failure during early iterator close is reported but does not prevent closing.
|
|
111
|
+
*/
|
|
112
|
+
async onRunErrorCallback(_params) {
|
|
113
|
+
}
|
|
95
114
|
/**
|
|
96
115
|
* Callback executed before an agent's primary logic is invoked.
|
|
97
116
|
*
|
|
@@ -110,14 +129,14 @@ const _BasePlugin = class _BasePlugin {
|
|
|
110
129
|
/**
|
|
111
130
|
* Callback executed after an agent's primary logic has completed.
|
|
112
131
|
*
|
|
113
|
-
* This callback can be used to inspect, log, or
|
|
114
|
-
*
|
|
132
|
+
* This callback can be used to inspect, log, or append an additional event
|
|
133
|
+
* after the agent's execution completes.
|
|
115
134
|
*
|
|
116
135
|
* @param _params.agent The agent that has just run.
|
|
117
136
|
* @param _params.callbackContext The context for the agent invocation.
|
|
118
|
-
* @returns An optional `Content` object. If a value is returned, it will
|
|
119
|
-
*
|
|
120
|
-
*
|
|
137
|
+
* @returns An optional `Content` object. If a value is returned, it will be
|
|
138
|
+
* emitted as an additional event appended after the agent's execution.
|
|
139
|
+
* Returning `undefined` emits no additional content event.
|
|
121
140
|
*/
|
|
122
141
|
async afterAgentCallback(_params) {
|
|
123
142
|
return;
|
|
@@ -162,8 +181,8 @@ const _BasePlugin = class _BasePlugin {
|
|
|
162
181
|
*
|
|
163
182
|
* @param _params.callbackContext The context for the current agent call.
|
|
164
183
|
* @param _params.llmRequest The prepared request object to be sent to the model.
|
|
165
|
-
* @returns An optional
|
|
166
|
-
*
|
|
184
|
+
* @returns An optional `LlmResponse`. Returning a non-`undefined` value
|
|
185
|
+
* triggers an early exit and returns that response immediately. Returning
|
|
167
186
|
* `undefined` allows the LLM request to proceed normally.
|
|
168
187
|
*/
|
|
169
188
|
async beforeModelCallback(_params) {
|
|
@@ -185,7 +204,7 @@ const _BasePlugin = class _BasePlugin {
|
|
|
185
204
|
return;
|
|
186
205
|
}
|
|
187
206
|
/**
|
|
188
|
-
* Callback executed when a model call encounters an
|
|
207
|
+
* Callback executed when a model call encounters an `Error`.
|
|
189
208
|
*
|
|
190
209
|
* This callback provides an opportunity to handle model errors gracefully,
|
|
191
210
|
* potentially providing alternative responses or recovery mechanisms.
|
|
@@ -193,10 +212,11 @@ const _BasePlugin = class _BasePlugin {
|
|
|
193
212
|
* @param _params.callbackContext The context for the current agent call.
|
|
194
213
|
* @param _params.llmRequest The request that was sent to the model when the error
|
|
195
214
|
* occurred.
|
|
196
|
-
* @param _params.error The
|
|
197
|
-
* @returns An optional LlmResponse
|
|
198
|
-
* used instead of
|
|
199
|
-
*
|
|
215
|
+
* @param _params.error The `Error` instance thrown during model execution.
|
|
216
|
+
* @returns An optional `LlmResponse`. If an `LlmResponse` is returned, it
|
|
217
|
+
* will be used instead of the default error response. Returning
|
|
218
|
+
* `undefined` causes an error response/event with `errorCode` and
|
|
219
|
+
* `errorMessage` derived from `error` to be yielded.
|
|
200
220
|
*/
|
|
201
221
|
async onModelErrorCallback(_params) {
|
|
202
222
|
return;
|
|
@@ -246,7 +266,8 @@ const _BasePlugin = class _BasePlugin {
|
|
|
246
266
|
return;
|
|
247
267
|
}
|
|
248
268
|
/**
|
|
249
|
-
* Callback executed when a tool call encounters an
|
|
269
|
+
* Callback executed when a tool call encounters an `Error` or cannot be
|
|
270
|
+
* resolved.
|
|
250
271
|
*
|
|
251
272
|
* This callback provides an opportunity to handle tool errors gracefully,
|
|
252
273
|
* potentially providing alternative responses or recovery mechanisms.
|
|
@@ -254,10 +275,13 @@ const _BasePlugin = class _BasePlugin {
|
|
|
254
275
|
* @param _params.tool The tool instance that encountered an error.
|
|
255
276
|
* @param _params.toolArgs The arguments that were passed to the tool.
|
|
256
277
|
* @param _params.toolContext The context specific to the tool execution.
|
|
257
|
-
* @param _params.error The
|
|
278
|
+
* @param _params.error The `Error` that was raised during tool resolution or
|
|
279
|
+
* execution.
|
|
258
280
|
* @returns An optional dictionary. If a dictionary is returned, it will be
|
|
259
|
-
* used as the tool response instead of
|
|
260
|
-
* `undefined`
|
|
281
|
+
* used as the tool response instead of the default error response.
|
|
282
|
+
* Returning `undefined` causes `{error: error.message}` to be returned as
|
|
283
|
+
* the tool response (unlike adk-python, which re-raises). Non-`Error`
|
|
284
|
+
* throwables bypass this callback and become `{error: thrownValue}`.
|
|
261
285
|
*/
|
|
262
286
|
async onToolErrorCallback(_params) {
|
|
263
287
|
return;
|
|
@@ -83,6 +83,33 @@ const _PluginManager = class _PluginManager {
|
|
|
83
83
|
}
|
|
84
84
|
return void 0;
|
|
85
85
|
}
|
|
86
|
+
/** Notifies every plugin without allowing one failure to hide another. */
|
|
87
|
+
async runNotificationCallbacks(callback, callbackName) {
|
|
88
|
+
for (const plugin of this.plugins) {
|
|
89
|
+
try {
|
|
90
|
+
await callback(plugin);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
logger.error(
|
|
93
|
+
`Error in plugin '${plugin.name}' during '${callbackName}' callback:`,
|
|
94
|
+
error
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** Runs the notification-only agent error callback for every plugin. */
|
|
100
|
+
async runOnAgentErrorCallback(params) {
|
|
101
|
+
await this.runNotificationCallbacks(
|
|
102
|
+
(plugin) => plugin.onAgentErrorCallback(params),
|
|
103
|
+
"onAgentErrorCallback"
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
/** Runs the notification-only run error callback for every plugin. */
|
|
107
|
+
async runOnRunErrorCallback(params) {
|
|
108
|
+
await this.runNotificationCallbacks(
|
|
109
|
+
(plugin) => plugin.onRunErrorCallback(params),
|
|
110
|
+
"onRunErrorCallback"
|
|
111
|
+
);
|
|
112
|
+
}
|
|
86
113
|
/**
|
|
87
114
|
* Runs the `onUserMessageCallback` for all plugins.
|
|
88
115
|
*/
|