@google/adk 2.3.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/a2a/a2a_remote_agent.js +17 -2
- package/dist/cjs/a2a/a2a_remote_agent_utils.js +8 -4
- package/dist/cjs/a2a/agent_card.js +5 -81
- package/dist/cjs/a2a/agent_to_a2a.js +7 -0
- package/dist/cjs/a2a/event_converter_utils.js +10 -3
- package/dist/cjs/agents/agent_engine_client.js +399 -0
- package/dist/cjs/agents/base_agent.js +127 -68
- package/dist/cjs/agents/functions.js +64 -59
- package/dist/cjs/agents/instructions.js +8 -6
- package/dist/cjs/agents/invocation_context.js +2 -2
- package/dist/cjs/agents/llm_agent.js +124 -101
- package/dist/cjs/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/code_execution_request_processor.js +8 -0
- package/dist/cjs/agents/processors/content_processor_utils.js +72 -17
- package/dist/cjs/agents/processors/content_request_processor.js +51 -2
- package/dist/cjs/agents/processors/context_compactor_request_processor.js +5 -1
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/nl_planning_processor.js +13 -3
- package/dist/cjs/artifacts/file_artifact_service.js +1 -1
- package/dist/cjs/cli/cli_eval.js +884 -17
- package/dist/cjs/cli/utils/cleanup.js +84 -0
- package/dist/cjs/cli/utils/envs.js +33 -2
- package/dist/cjs/cli/utils/evals.js +75 -8
- package/dist/cjs/cli/utils/logs.js +134 -15
- package/dist/cjs/cli/utils/path_validation.js +83 -0
- package/dist/cjs/code_executors/container_code_executor.js +171 -38
- package/dist/cjs/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/cjs/common.js +59 -32
- package/dist/cjs/context/compaction_utils.js +19 -0
- package/dist/cjs/errors/input_validation_error.js +3 -2
- package/dist/cjs/events/event.js +7 -3
- package/dist/cjs/features/feature_registry.js +5 -0
- package/dist/cjs/index.js +34 -12
- package/dist/cjs/models/google_llm.js +33 -2
- package/dist/cjs/models/interactions_utils.js +3 -0
- package/dist/cjs/plugins/base_plugin.js +54 -40
- package/dist/cjs/plugins/plugin_manager.js +27 -0
- package/dist/cjs/runner/runner.js +306 -189
- package/dist/cjs/sessions/base_session_service.js +15 -12
- package/dist/cjs/sessions/database_session_service.js +232 -38
- package/dist/cjs/sessions/db/operations.js +70 -1
- package/dist/cjs/sessions/db/schema.js +4 -0
- package/dist/cjs/sessions/in_memory_session_service.js +2 -2
- package/dist/cjs/sessions/stale_session_error.js +59 -0
- package/dist/cjs/sessions/vertex_ai_session_service.js +11 -3
- package/dist/cjs/skills/loader.js +76 -41
- package/dist/cjs/telemetry/api/instrumentation.js +632 -0
- package/dist/cjs/telemetry/api/internal/common/accumulators.js +169 -0
- package/dist/cjs/telemetry/api/internal/common/attributes.js +131 -0
- package/dist/cjs/telemetry/api/internal/common/config.js +159 -0
- package/dist/cjs/telemetry/api/internal/common/error.js +98 -0
- package/dist/cjs/telemetry/api/internal/common/finish_reason.js +63 -0
- package/dist/cjs/telemetry/api/internal/common/genai_messages.js +217 -0
- package/dist/cjs/telemetry/api/internal/common/http_exchange.js +169 -0
- package/dist/cjs/telemetry/api/internal/common/provider_name.js +87 -0
- package/dist/cjs/telemetry/api/internal/common/redaction.js +148 -0
- package/dist/cjs/telemetry/api/internal/common/serialization.js +58 -0
- package/dist/cjs/telemetry/api/internal/common/token_usage.js +118 -0
- package/dist/cjs/telemetry/api/internal/logs/inference.js +50 -0
- package/dist/cjs/telemetry/api/internal/logs/logger.js +46 -0
- package/dist/cjs/telemetry/api/internal/logs/mcp.js +141 -0
- package/dist/cjs/telemetry/api/internal/metrics/agent.js +128 -0
- package/dist/cjs/telemetry/api/internal/metrics/inference_start_hook.js +56 -0
- package/dist/cjs/telemetry/api/internal/metrics/meters.js +189 -0
- package/dist/cjs/telemetry/api/internal/metrics/tool.js +147 -0
- package/dist/cjs/telemetry/api/internal/metrics/workflow.js +132 -0
- package/dist/cjs/telemetry/api/internal/trace/agent.js +52 -0
- package/dist/cjs/telemetry/api/internal/trace/compaction.js +78 -0
- package/dist/cjs/telemetry/api/internal/trace/inference.js +132 -0
- package/dist/cjs/telemetry/api/internal/trace/live.js +52 -0
- package/dist/cjs/telemetry/api/internal/trace/node.js +73 -0
- package/dist/cjs/telemetry/api/internal/trace/propagation.js +67 -0
- package/dist/cjs/telemetry/api/internal/trace/tool.js +122 -0
- package/dist/cjs/telemetry/api/internal/trace/tracer.js +77 -0
- package/dist/cjs/telemetry/api/internal/trace/workflow.js +77 -0
- package/dist/cjs/telemetry/export/agent_engine.js +90 -0
- package/dist/cjs/telemetry/export/agent_runtime.js +73 -0
- package/dist/cjs/telemetry/export/google_cloud.js +763 -0
- package/dist/cjs/telemetry/export/request_driven_metric_reader.js +303 -0
- package/dist/cjs/telemetry/{setup.js → export/setup.js} +72 -6
- package/dist/cjs/tools/agent_tool.js +9 -1
- package/dist/cjs/tools/apihub_tool/apihub_toolset.js +18 -23
- package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +109 -43
- package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +222 -114
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +34 -14
- package/dist/cjs/tools/application_integration_tool/integration_connector_tool.js +175 -0
- package/dist/cjs/tools/base_toolset.js +1 -1
- package/dist/cjs/tools/computer_use/base_computer.js +125 -0
- package/dist/cjs/tools/computer_use/computer_use_actions.js +502 -0
- package/dist/cjs/tools/computer_use/computer_use_tool.js +244 -0
- package/dist/cjs/tools/computer_use/computer_use_toolset.js +360 -0
- package/dist/cjs/tools/function_tool.js +15 -5
- package/dist/cjs/tools/google_api_tool/google_api_tool.js +4 -1
- package/dist/cjs/tools/google_api_tool/google_api_toolset.js +174 -0
- package/dist/cjs/tools/google_api_tool/google_api_toolsets.js +124 -0
- package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +5 -3
- package/dist/cjs/tools/google_api_tool/index.js +20 -23
- package/dist/cjs/tools/load_artifacts_tool.js +27 -11
- package/dist/cjs/tools/load_memory_tool.js +14 -15
- package/dist/cjs/tools/mcp/mcp_session_manager.js +23 -3
- package/dist/cjs/tools/mcp/mcp_tool.js +7 -3
- package/dist/cjs/tools/mcp/mcp_toolset.js +19 -20
- package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +30 -29
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +4 -4
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
- package/dist/cjs/tools/openapi_tool/openapi_toolset.js +7 -13
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +57 -10
- package/dist/cjs/tools/skill/load_skill_resource_tool.js +7 -0
- package/dist/cjs/tools/skill/load_skill_tool.js +3 -0
- package/dist/cjs/tools/skill/run_skill_script_tool.js +12 -2
- package/dist/cjs/tools/toolbox_toolset.js +193 -0
- package/dist/cjs/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/cjs/utils/async_queue.js +37 -3
- package/dist/cjs/utils/client_labels.js +17 -2
- package/dist/cjs/utils/env_aware_utils.js +13 -7
- package/dist/cjs/utils/error_utils.js +40 -2
- package/dist/cjs/utils/failover_utils.js +11 -10
- package/dist/cjs/utils/gemini_schema_util.js +145 -14
- package/dist/cjs/utils/id_provider.js +63 -0
- package/dist/cjs/utils/logger_node.js +4 -0
- package/dist/cjs/utils/model_name.js +15 -0
- package/dist/cjs/utils/output_schema_utils.js +5 -2
- package/dist/cjs/utils/simple_zod_to_json.js +13 -31
- package/dist/cjs/utils/ssrf_guard.js +46 -16
- package/dist/cjs/utils/task.js +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/workflow/index.js +2 -0
- package/dist/cjs/workflow/node_runner.js +24 -80
- package/dist/cjs/workflow/nodes/parallel_worker.js +18 -7
- package/dist/cjs/workflow/run_llm_agent_as_node.js +19 -14
- package/dist/cjs/workflow/utils/retry_utils.js +2 -2
- package/dist/cjs/workflow/workflow.js +12 -12
- package/dist/esm/a2a/a2a_remote_agent.js +23 -3
- package/dist/esm/a2a/a2a_remote_agent_utils.js +8 -4
- package/dist/esm/a2a/agent_card.js +5 -83
- package/dist/esm/a2a/agent_to_a2a.js +7 -0
- package/dist/esm/a2a/event_converter_utils.js +10 -3
- package/dist/esm/agents/agent_engine_client.js +382 -0
- package/dist/esm/agents/base_agent.js +127 -72
- package/dist/esm/agents/functions.js +69 -63
- package/dist/esm/agents/instructions.js +8 -6
- package/dist/esm/agents/invocation_context.js +2 -2
- package/dist/esm/agents/llm_agent.js +130 -106
- package/dist/esm/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/code_execution_request_processor.js +8 -0
- package/dist/esm/agents/processors/content_processor_utils.js +72 -17
- package/dist/esm/agents/processors/content_request_processor.js +51 -2
- package/dist/esm/agents/processors/context_compactor_request_processor.js +5 -1
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/nl_planning_processor.js +13 -3
- package/dist/esm/artifacts/file_artifact_service.js +1 -1
- package/dist/esm/cli/cli_eval.js +880 -17
- package/dist/esm/cli/utils/cleanup.js +56 -0
- package/dist/esm/cli/utils/envs.js +33 -2
- package/dist/esm/cli/utils/evals.js +74 -8
- package/dist/esm/cli/utils/logs.js +132 -13
- package/dist/esm/cli/utils/path_validation.js +45 -0
- package/dist/esm/code_executors/container_code_executor.js +171 -38
- package/dist/esm/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/esm/common.js +59 -19
- package/dist/esm/context/compaction_utils.js +19 -0
- package/dist/esm/errors/input_validation_error.js +3 -2
- package/dist/esm/events/event.js +7 -3
- package/dist/esm/features/feature_registry.js +5 -0
- package/dist/esm/index.js +36 -10
- package/dist/esm/models/google_llm.js +33 -2
- package/dist/esm/models/interactions_utils.js +3 -0
- package/dist/esm/plugins/base_plugin.js +54 -40
- package/dist/esm/plugins/plugin_manager.js +27 -0
- package/dist/esm/runner/runner.js +310 -192
- package/dist/esm/sessions/base_session_service.js +13 -11
- package/dist/esm/sessions/database_session_service.js +231 -38
- package/dist/esm/sessions/db/operations.js +70 -1
- package/dist/esm/sessions/db/schema.js +4 -0
- package/dist/esm/sessions/in_memory_session_service.js +2 -2
- package/dist/esm/sessions/stale_session_error.js +31 -0
- package/dist/esm/sessions/vertex_ai_session_service.js +11 -3
- package/dist/esm/skills/loader.js +76 -41
- package/dist/esm/telemetry/api/instrumentation.js +655 -0
- package/dist/esm/telemetry/api/internal/common/accumulators.js +139 -0
- package/dist/esm/telemetry/api/internal/common/attributes.js +94 -0
- package/dist/esm/telemetry/api/internal/common/config.js +128 -0
- package/dist/esm/telemetry/api/internal/common/error.js +69 -0
- package/dist/esm/telemetry/api/internal/common/finish_reason.js +35 -0
- package/dist/esm/telemetry/api/internal/common/genai_messages.js +188 -0
- package/dist/esm/telemetry/api/internal/common/http_exchange.js +142 -0
- package/dist/esm/telemetry/api/internal/common/provider_name.js +59 -0
- package/dist/esm/telemetry/api/internal/common/redaction.js +121 -0
- package/dist/esm/telemetry/api/internal/common/serialization.js +30 -0
- package/dist/esm/telemetry/api/internal/common/token_usage.js +85 -0
- package/dist/esm/telemetry/api/internal/logs/inference.js +23 -0
- package/dist/esm/telemetry/api/internal/logs/logger.js +19 -0
- package/dist/esm/telemetry/api/internal/logs/mcp.js +113 -0
- package/dist/esm/telemetry/api/internal/metrics/agent.js +107 -0
- package/dist/esm/telemetry/api/internal/metrics/inference_start_hook.js +29 -0
- package/dist/esm/telemetry/api/internal/metrics/meters.js +165 -0
- package/dist/esm/telemetry/api/internal/metrics/tool.js +119 -0
- package/dist/esm/telemetry/api/internal/metrics/workflow.js +112 -0
- package/dist/esm/telemetry/api/internal/trace/agent.js +25 -0
- package/dist/esm/telemetry/api/internal/trace/compaction.js +50 -0
- package/dist/esm/telemetry/api/internal/trace/inference.js +107 -0
- package/dist/esm/telemetry/api/internal/trace/live.js +28 -0
- package/dist/esm/telemetry/api/internal/trace/node.js +44 -0
- package/dist/esm/telemetry/api/internal/trace/propagation.js +39 -0
- package/dist/esm/telemetry/api/internal/trace/tool.js +96 -0
- package/dist/esm/telemetry/api/internal/trace/tracer.js +52 -0
- package/dist/esm/telemetry/api/internal/trace/workflow.js +54 -0
- package/dist/esm/telemetry/export/agent_engine.js +67 -0
- package/dist/esm/telemetry/export/agent_runtime.js +46 -0
- package/dist/esm/telemetry/export/google_cloud.js +733 -0
- package/dist/esm/telemetry/export/request_driven_metric_reader.js +276 -0
- package/dist/esm/telemetry/export/setup.js +160 -0
- package/dist/esm/tools/agent_tool.js +9 -1
- package/dist/esm/tools/apihub_tool/apihub_toolset.js +17 -22
- package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +114 -44
- package/dist/esm/tools/application_integration_tool/clients/connections_client.js +226 -115
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +34 -14
- package/dist/esm/tools/application_integration_tool/integration_connector_tool.js +149 -0
- package/dist/esm/tools/base_toolset.js +1 -1
- package/dist/esm/tools/computer_use/base_computer.js +99 -0
- package/dist/esm/tools/computer_use/computer_use_actions.js +477 -0
- package/dist/esm/tools/computer_use/computer_use_tool.js +217 -0
- package/dist/esm/tools/computer_use/computer_use_toolset.js +344 -0
- package/dist/esm/tools/function_tool.js +15 -5
- package/dist/esm/tools/google_api_tool/google_api_tool.js +4 -1
- package/dist/esm/tools/google_api_tool/google_api_toolset.js +147 -0
- package/dist/esm/tools/google_api_tool/google_api_toolsets.js +94 -0
- package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +5 -3
- package/dist/esm/tools/google_api_tool/index.js +18 -20
- package/dist/esm/tools/load_artifacts_tool.js +25 -10
- package/dist/esm/tools/load_memory_tool.js +14 -15
- package/dist/esm/tools/mcp/mcp_session_manager.js +23 -3
- package/dist/esm/tools/mcp/mcp_tool.js +7 -3
- package/dist/esm/tools/mcp/mcp_toolset.js +19 -20
- package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +27 -26
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +4 -4
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
- package/dist/esm/tools/openapi_tool/openapi_toolset.js +6 -12
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +57 -10
- package/dist/esm/tools/skill/load_skill_resource_tool.js +7 -0
- package/dist/esm/tools/skill/load_skill_tool.js +3 -0
- package/dist/esm/tools/skill/run_skill_script_tool.js +12 -2
- package/dist/esm/tools/toolbox_toolset.js +167 -0
- package/dist/esm/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/esm/utils/async_queue.js +37 -3
- package/dist/esm/utils/client_labels.js +17 -2
- package/dist/esm/utils/env_aware_utils.js +12 -7
- package/dist/esm/utils/error_utils.js +37 -1
- package/dist/esm/utils/failover_utils.js +11 -10
- package/dist/esm/utils/gemini_schema_util.js +144 -14
- package/dist/esm/utils/id_provider.js +33 -0
- package/dist/esm/utils/logger_node.js +4 -0
- package/dist/esm/utils/model_name.js +14 -0
- package/dist/esm/utils/output_schema_utils.js +5 -2
- package/dist/esm/utils/simple_zod_to_json.js +13 -31
- package/dist/esm/utils/ssrf_guard.js +55 -15
- package/dist/esm/utils/task.js +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/workflow/index.js +2 -1
- package/dist/esm/workflow/node_runner.js +26 -80
- package/dist/esm/workflow/nodes/parallel_worker.js +16 -6
- package/dist/esm/workflow/run_llm_agent_as_node.js +19 -14
- package/dist/esm/workflow/utils/retry_utils.js +2 -2
- package/dist/esm/workflow/workflow.js +12 -12
- package/dist/types/a2a/a2a_remote_agent.d.ts +6 -0
- package/dist/types/a2a/a2a_remote_agent_utils.d.ts +3 -2
- package/dist/types/agents/agent_engine_client.d.ts +155 -0
- package/dist/types/agents/base_agent.d.ts +14 -0
- package/dist/types/agents/llm_agent.d.ts +5 -1
- package/dist/types/agents/processors/content_processor_utils.d.ts +12 -10
- package/dist/types/agents/processors/nl_planning_processor.d.ts +2 -1
- package/dist/types/agents/run_config.d.ts +14 -0
- package/dist/types/cli/cli_eval.d.ts +172 -9
- package/dist/types/cli/utils/cleanup.d.ts +18 -0
- package/dist/types/cli/utils/envs.d.ts +13 -3
- package/dist/types/cli/utils/evals.d.ts +64 -1
- package/dist/types/cli/utils/logs.d.ts +20 -3
- package/dist/types/cli/utils/path_validation.d.ts +30 -0
- package/dist/types/code_executors/container_code_executor.d.ts +62 -9
- package/dist/types/common.d.ts +21 -18
- package/dist/types/context/compaction_utils.d.ts +13 -1
- package/dist/types/errors/input_validation_error.d.ts +2 -1
- package/dist/types/events/event.d.ts +3 -0
- package/dist/types/features/feature_registry.d.ts +1 -0
- package/dist/types/index.d.ts +11 -6
- package/dist/types/plugins/base_plugin.d.ts +50 -31
- package/dist/types/plugins/plugin_manager.d.ts +13 -0
- package/dist/types/runner/runner.d.ts +11 -0
- package/dist/types/sessions/base_session_service.d.ts +5 -2
- package/dist/types/sessions/database_session_service.d.ts +17 -1
- package/dist/types/sessions/db/operations.d.ts +2 -1
- package/dist/types/sessions/db/schema.d.ts +5 -3
- package/dist/types/sessions/stale_session_error.d.ts +21 -0
- package/dist/types/skills/loader.d.ts +3 -2
- package/dist/types/telemetry/api/instrumentation.d.ts +259 -0
- package/dist/types/telemetry/api/internal/common/accumulators.d.ts +91 -0
- package/dist/types/telemetry/api/internal/common/attributes.d.ts +90 -0
- package/dist/types/telemetry/api/internal/common/config.d.ts +61 -0
- package/dist/types/telemetry/api/internal/common/error.d.ts +29 -0
- package/dist/types/telemetry/api/internal/common/finish_reason.d.ts +18 -0
- package/dist/types/telemetry/api/internal/common/genai_messages.d.ts +26 -0
- package/dist/types/telemetry/api/internal/common/http_exchange.d.ts +50 -0
- package/dist/types/telemetry/api/internal/common/provider_name.d.ts +16 -0
- package/dist/types/telemetry/api/internal/common/redaction.d.ts +14 -0
- package/dist/types/telemetry/api/internal/common/serialization.d.ts +18 -0
- package/dist/types/telemetry/api/internal/common/token_usage.d.ts +47 -0
- package/dist/types/telemetry/api/internal/logs/inference.d.ts +15 -0
- package/dist/types/telemetry/api/internal/logs/logger.d.ts +13 -0
- package/dist/types/telemetry/api/internal/logs/mcp.d.ts +31 -0
- package/dist/types/telemetry/api/internal/metrics/agent.d.ts +28 -0
- package/dist/types/telemetry/api/internal/metrics/inference_start_hook.d.ts +12 -0
- package/dist/types/telemetry/api/internal/metrics/meters.d.ts +57 -0
- package/dist/types/telemetry/api/internal/metrics/tool.d.ts +44 -0
- package/dist/types/telemetry/api/internal/metrics/workflow.d.ts +32 -0
- package/dist/types/telemetry/api/internal/trace/agent.d.ts +14 -0
- package/dist/types/telemetry/api/internal/trace/compaction.d.ts +20 -0
- package/dist/types/telemetry/api/internal/trace/inference.d.ts +31 -0
- package/dist/types/telemetry/api/internal/trace/live.d.ts +21 -0
- package/dist/types/telemetry/api/internal/trace/node.d.ts +22 -0
- package/dist/types/telemetry/api/internal/trace/propagation.d.ts +22 -0
- package/dist/types/telemetry/api/internal/trace/tool.d.ts +57 -0
- package/dist/types/telemetry/api/internal/trace/tracer.d.ts +31 -0
- package/dist/types/telemetry/api/internal/trace/workflow.d.ts +21 -0
- package/dist/types/telemetry/export/agent_engine.d.ts +23 -0
- package/dist/types/telemetry/export/agent_runtime.d.ts +40 -0
- package/dist/types/telemetry/export/google_cloud.d.ts +189 -0
- package/dist/types/telemetry/export/request_driven_metric_reader.d.ts +144 -0
- package/dist/types/telemetry/{setup.d.ts → export/setup.d.ts} +3 -0
- package/dist/types/tools/agent_tool.d.ts +1 -1
- package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +14 -21
- package/dist/types/tools/application_integration_tool/application_integration_toolset.d.ts +32 -9
- package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +35 -12
- package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +3 -3
- package/dist/types/tools/application_integration_tool/integration_connector_tool.d.ts +70 -0
- package/dist/types/tools/base_toolset.d.ts +7 -6
- package/dist/types/tools/computer_use/base_computer.d.ts +281 -0
- package/dist/types/tools/computer_use/computer_use_actions.d.ts +53 -0
- package/dist/types/tools/computer_use/computer_use_tool.d.ts +108 -0
- package/dist/types/tools/computer_use/computer_use_toolset.d.ts +132 -0
- package/dist/types/tools/google_api_tool/google_api_tool.d.ts +10 -3
- package/dist/types/tools/google_api_tool/google_api_toolset.d.ts +57 -0
- package/dist/types/tools/google_api_tool/google_api_toolsets.d.ts +48 -0
- package/dist/types/tools/google_api_tool/googleapi_to_openapi_converter.d.ts +5 -4
- package/dist/types/tools/google_api_tool/index.d.ts +4 -5
- package/dist/types/tools/load_artifacts_tool.d.ts +18 -1
- package/dist/types/tools/load_memory_tool.d.ts +32 -4
- package/dist/types/tools/mcp/mcp_session_manager.d.ts +16 -0
- package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +8 -8
- package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +12 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +15 -3
- package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +5 -0
- package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +10 -0
- package/dist/types/tools/toolbox_toolset.d.ts +154 -0
- package/dist/types/utils/async_queue.d.ts +14 -0
- package/dist/types/utils/client_labels.d.ts +2 -1
- package/dist/types/utils/env_aware_utils.d.ts +11 -0
- package/dist/types/utils/error_utils.d.ts +4 -0
- package/dist/types/utils/gemini_schema_util.d.ts +29 -0
- package/dist/types/utils/id_provider.d.ts +43 -0
- package/dist/types/utils/model_name.d.ts +8 -0
- package/dist/types/utils/output_schema_utils.d.ts +3 -2
- package/dist/types/utils/simple_zod_to_json.d.ts +1 -2
- package/dist/types/utils/ssrf_guard.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types/workflow/index.d.ts +1 -1
- package/dist/types/workflow/nodes/parallel_worker.d.ts +8 -1
- package/dist/web/index_web.js +94 -88
- package/dist/web/index_web.js.map +4 -4
- package/package.json +43 -38
- package/dist/cjs/agents/remote_agent.js +0 -187
- package/dist/cjs/telemetry/google_cloud.js +0 -116
- package/dist/cjs/telemetry/tracing.js +0 -350
- package/dist/cjs/tools/crewai_tool.js +0 -132
- package/dist/cjs/tools/google_api_tool/google_api_tool_set.js +0 -226
- package/dist/cjs/tools/google_api_tool/google_api_tool_sets.js +0 -58
- package/dist/cjs/tools/langchain_tool.js +0 -172
- package/dist/cjs/tools/toolbox_tool.js +0 -108
- package/dist/esm/agents/remote_agent.js +0 -164
- package/dist/esm/telemetry/google_cloud.js +0 -99
- package/dist/esm/telemetry/setup.js +0 -89
- package/dist/esm/telemetry/tracing.js +0 -315
- package/dist/esm/tools/crewai_tool.js +0 -107
- package/dist/esm/tools/google_api_tool/google_api_tool_set.js +0 -188
- package/dist/esm/tools/google_api_tool/google_api_tool_sets.js +0 -24
- package/dist/esm/tools/langchain_tool.js +0 -148
- package/dist/esm/tools/toolbox_tool.js +0 -80
- package/dist/types/agents/remote_agent.d.ts +0 -68
- package/dist/types/telemetry/google_cloud.d.ts +0 -9
- package/dist/types/telemetry/tracing.d.ts +0 -129
- package/dist/types/tools/crewai_tool.d.ts +0 -85
- package/dist/types/tools/google_api_tool/google_api_tool_set.d.ts +0 -78
- package/dist/types/tools/google_api_tool/google_api_tool_sets.d.ts +0 -33
- package/dist/types/tools/langchain_tool.d.ts +0 -103
- package/dist/types/tools/toolbox_tool.d.ts +0 -73
|
@@ -30,9 +30,10 @@ __export(base_agent_exports, {
|
|
|
30
30
|
isBaseAgent: () => isBaseAgent
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(base_agent_exports);
|
|
33
|
-
var import_api = require("@opentelemetry/api");
|
|
34
33
|
var import_event = require("../events/event.js");
|
|
35
|
-
var
|
|
34
|
+
var import_instrumentation = require("../telemetry/api/instrumentation.js");
|
|
35
|
+
var import_error_utils = require("../utils/error_utils.js");
|
|
36
|
+
var import_logger = require("../utils/logger.js");
|
|
36
37
|
var import_base_node = require("../workflow/base_node.js");
|
|
37
38
|
var import_context = require("./context.js");
|
|
38
39
|
var import_invocation_context = require("./invocation_context.js");
|
|
@@ -122,38 +123,38 @@ const _BaseAgent = class _BaseAgent extends (_b = import_base_node.BaseNode, _a
|
|
|
122
123
|
* @returns An AsyncGenerator that yields the events generated by the agent.
|
|
123
124
|
*/
|
|
124
125
|
async *runAsync(parentContext) {
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const context2 = this.createInvocationContext(parentContext);
|
|
134
|
-
const beforeAgentCallbackEvent = await this.handleBeforeAgentCallback(context2);
|
|
126
|
+
const agentCtx = this;
|
|
127
|
+
yield* (0, import_instrumentation.recordAgentInvocation)(
|
|
128
|
+
{ agent: this, invocationContext: parentContext },
|
|
129
|
+
async function* () {
|
|
130
|
+
var _a2, _b2;
|
|
131
|
+
const context = agentCtx.createInvocationContext(parentContext);
|
|
132
|
+
try {
|
|
133
|
+
const beforeAgentCallbackEvent = await agentCtx.handleBeforeAgentCallback(context);
|
|
135
134
|
if (beforeAgentCallbackEvent) {
|
|
136
135
|
yield beforeAgentCallbackEvent;
|
|
137
136
|
}
|
|
138
|
-
if (
|
|
137
|
+
if (context.endInvocation || ((_a2 = parentContext.abortSignal) == null ? void 0 : _a2.aborted)) {
|
|
139
138
|
return;
|
|
140
139
|
}
|
|
141
|
-
|
|
142
|
-
for await (const event of this.runAsyncImpl(context2)) {
|
|
140
|
+
for await (const event of agentCtx.runAsyncImpl(context)) {
|
|
143
141
|
yield event;
|
|
144
142
|
}
|
|
145
|
-
if (
|
|
143
|
+
if (context.endInvocation || ((_b2 = parentContext.abortSignal) == null ? void 0 : _b2.aborted)) {
|
|
146
144
|
return;
|
|
147
145
|
}
|
|
148
|
-
const afterAgentCallbackEvent = await
|
|
146
|
+
const afterAgentCallbackEvent = await agentCtx.handleAfterAgentCallback(context);
|
|
149
147
|
if (afterAgentCallbackEvent) {
|
|
150
148
|
yield afterAgentCallbackEvent;
|
|
151
149
|
}
|
|
150
|
+
} catch (error) {
|
|
151
|
+
if (!(0, import_error_utils.isInvocationCancellation)(error, context.abortSignal)) {
|
|
152
|
+
await agentCtx.handleAgentErrorCallback(context, error);
|
|
153
|
+
}
|
|
154
|
+
throw error;
|
|
152
155
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
span.end();
|
|
156
|
-
}
|
|
156
|
+
}
|
|
157
|
+
);
|
|
157
158
|
}
|
|
158
159
|
/**
|
|
159
160
|
* Runs this agent as a workflow node.
|
|
@@ -188,36 +189,52 @@ const _BaseAgent = class _BaseAgent extends (_b = import_base_node.BaseNode, _a
|
|
|
188
189
|
* @returns An AsyncGenerator that yields the events generated by the agent.
|
|
189
190
|
*/
|
|
190
191
|
async *runLive(parentContext) {
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const context2 = this.createInvocationContext(parentContext);
|
|
200
|
-
const beforeAgentCallbackEvent = await this.handleBeforeAgentCallback(context2);
|
|
192
|
+
const agentCtx = this;
|
|
193
|
+
yield* (0, import_instrumentation.recordAgentInvocation)(
|
|
194
|
+
{ agent: this, invocationContext: parentContext },
|
|
195
|
+
async function* () {
|
|
196
|
+
var _a2, _b2;
|
|
197
|
+
const context = agentCtx.createInvocationContext(parentContext);
|
|
198
|
+
try {
|
|
199
|
+
const beforeAgentCallbackEvent = await agentCtx.handleBeforeAgentCallback(context);
|
|
201
200
|
if (beforeAgentCallbackEvent) {
|
|
202
201
|
yield beforeAgentCallbackEvent;
|
|
203
202
|
}
|
|
204
|
-
if (
|
|
203
|
+
if (context.endInvocation || ((_a2 = parentContext.abortSignal) == null ? void 0 : _a2.aborted)) {
|
|
205
204
|
return;
|
|
206
205
|
}
|
|
207
|
-
for await (const event of
|
|
206
|
+
for await (const event of agentCtx.runLiveImpl(context)) {
|
|
208
207
|
yield event;
|
|
209
208
|
}
|
|
210
|
-
if (
|
|
209
|
+
if (context.endInvocation || ((_b2 = parentContext.abortSignal) == null ? void 0 : _b2.aborted)) {
|
|
211
210
|
return;
|
|
212
211
|
}
|
|
213
|
-
const afterAgentCallbackEvent = await
|
|
212
|
+
const afterAgentCallbackEvent = await agentCtx.handleAfterAgentCallback(context);
|
|
214
213
|
if (afterAgentCallbackEvent) {
|
|
215
214
|
yield afterAgentCallbackEvent;
|
|
216
215
|
}
|
|
216
|
+
} catch (error) {
|
|
217
|
+
if (!(0, import_error_utils.isInvocationCancellation)(error, context.abortSignal)) {
|
|
218
|
+
await agentCtx.handleAgentErrorCallback(context, error);
|
|
219
|
+
}
|
|
220
|
+
throw error;
|
|
217
221
|
}
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
/** Reports execution failures without replacing the original thrown value. */
|
|
226
|
+
async handleAgentErrorCallback(invocationContext, error) {
|
|
227
|
+
try {
|
|
228
|
+
await invocationContext.pluginManager.runOnAgentErrorCallback({
|
|
229
|
+
agent: this,
|
|
230
|
+
callbackContext: new import_context.Context({ invocationContext }),
|
|
231
|
+
error: (0, import_error_utils.toError)(error)
|
|
232
|
+
});
|
|
233
|
+
} catch (callbackError) {
|
|
234
|
+
import_logger.logger.error(
|
|
235
|
+
"Agent error notification failed; preserving the original error.",
|
|
236
|
+
callbackError
|
|
218
237
|
);
|
|
219
|
-
} finally {
|
|
220
|
-
span.end();
|
|
221
238
|
}
|
|
222
239
|
}
|
|
223
240
|
/**
|
|
@@ -259,6 +276,22 @@ const _BaseAgent = class _BaseAgent extends (_b = import_base_node.BaseNode, _a
|
|
|
259
276
|
agent: this
|
|
260
277
|
});
|
|
261
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* The resolved beforeAgentCallback field as a list of SingleAgentCallback.
|
|
281
|
+
*
|
|
282
|
+
* This method is only for use by Agent Development Kit.
|
|
283
|
+
*/
|
|
284
|
+
get canonicalBeforeAgentCallbacks() {
|
|
285
|
+
return this.beforeAgentCallback;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* The resolved afterAgentCallback field as a list of SingleAgentCallback.
|
|
289
|
+
*
|
|
290
|
+
* This method is only for use by Agent Development Kit.
|
|
291
|
+
*/
|
|
292
|
+
get canonicalAfterAgentCallbacks() {
|
|
293
|
+
return this.afterAgentCallback;
|
|
294
|
+
}
|
|
262
295
|
/**
|
|
263
296
|
* Runs the before agent callback if it exists.
|
|
264
297
|
*
|
|
@@ -267,27 +300,40 @@ const _BaseAgent = class _BaseAgent extends (_b = import_base_node.BaseNode, _a
|
|
|
267
300
|
* generated.
|
|
268
301
|
*/
|
|
269
302
|
async handleBeforeAgentCallback(invocationContext) {
|
|
270
|
-
var _a2;
|
|
271
|
-
|
|
303
|
+
var _a2, _b2, _c;
|
|
304
|
+
const hasPlugins = Boolean((_a2 = invocationContext.pluginManager) == null ? void 0 : _a2.hasPlugins);
|
|
305
|
+
if (!hasPlugins && this.canonicalBeforeAgentCallbacks.length === 0) {
|
|
272
306
|
return void 0;
|
|
273
307
|
}
|
|
274
308
|
const callbackContext = new import_context.Context({ invocationContext });
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
309
|
+
let content = hasPlugins ? await invocationContext.pluginManager.runBeforeAgentCallback({
|
|
310
|
+
agent: this,
|
|
311
|
+
callbackContext
|
|
312
|
+
}) : void 0;
|
|
313
|
+
if ((_b2 = invocationContext.abortSignal) == null ? void 0 : _b2.aborted) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
if (!content) {
|
|
317
|
+
for (const callback of this.canonicalBeforeAgentCallbacks) {
|
|
318
|
+
content = await callback(callbackContext);
|
|
319
|
+
if ((_c = invocationContext.abortSignal) == null ? void 0 : _c.aborted) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if (content) {
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
289
325
|
}
|
|
290
326
|
}
|
|
327
|
+
if (content) {
|
|
328
|
+
invocationContext.endInvocation = true;
|
|
329
|
+
return (0, import_event.createEvent)({
|
|
330
|
+
invocationId: invocationContext.invocationId,
|
|
331
|
+
author: this.name,
|
|
332
|
+
branch: invocationContext.branch,
|
|
333
|
+
content,
|
|
334
|
+
actions: callbackContext.eventActions
|
|
335
|
+
});
|
|
336
|
+
}
|
|
291
337
|
if (callbackContext.state.hasDelta()) {
|
|
292
338
|
return (0, import_event.createEvent)({
|
|
293
339
|
invocationId: invocationContext.invocationId,
|
|
@@ -306,26 +352,39 @@ const _BaseAgent = class _BaseAgent extends (_b = import_base_node.BaseNode, _a
|
|
|
306
352
|
* generated.
|
|
307
353
|
*/
|
|
308
354
|
async handleAfterAgentCallback(invocationContext) {
|
|
309
|
-
var _a2;
|
|
310
|
-
|
|
355
|
+
var _a2, _b2, _c;
|
|
356
|
+
const hasPlugins = Boolean((_a2 = invocationContext.pluginManager) == null ? void 0 : _a2.hasPlugins);
|
|
357
|
+
if (!hasPlugins && this.canonicalAfterAgentCallbacks.length === 0) {
|
|
311
358
|
return void 0;
|
|
312
359
|
}
|
|
313
360
|
const callbackContext = new import_context.Context({ invocationContext });
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
361
|
+
let content = hasPlugins ? await invocationContext.pluginManager.runAfterAgentCallback({
|
|
362
|
+
agent: this,
|
|
363
|
+
callbackContext
|
|
364
|
+
}) : void 0;
|
|
365
|
+
if ((_b2 = invocationContext.abortSignal) == null ? void 0 : _b2.aborted) {
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
if (!content) {
|
|
369
|
+
for (const callback of this.canonicalAfterAgentCallbacks) {
|
|
370
|
+
content = await callback(callbackContext);
|
|
371
|
+
if ((_c = invocationContext.abortSignal) == null ? void 0 : _c.aborted) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (content) {
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
327
377
|
}
|
|
328
378
|
}
|
|
379
|
+
if (content) {
|
|
380
|
+
return (0, import_event.createEvent)({
|
|
381
|
+
invocationId: invocationContext.invocationId,
|
|
382
|
+
author: this.name,
|
|
383
|
+
branch: invocationContext.branch,
|
|
384
|
+
content,
|
|
385
|
+
actions: callbackContext.eventActions
|
|
386
|
+
});
|
|
387
|
+
}
|
|
329
388
|
if (callbackContext.state.hasDelta()) {
|
|
330
389
|
return (0, import_event.createEvent)({
|
|
331
390
|
invocationId: invocationContext.invocationId,
|
|
@@ -51,13 +51,14 @@ var import_lodash_es = require("lodash-es");
|
|
|
51
51
|
var import_event = require("../events/event.js");
|
|
52
52
|
var import_event_actions = require("../events/event_actions.js");
|
|
53
53
|
var import_base_tool = require("../tools/base_tool.js");
|
|
54
|
+
var import_computer_use_tool = require("../tools/computer_use/computer_use_tool.js");
|
|
54
55
|
var import_function_tool = require("../tools/function_tool.js");
|
|
55
56
|
var import_logger = require("../utils/logger.js");
|
|
56
57
|
var import_task = require("../utils/task.js");
|
|
57
58
|
var import_active_streaming_tool = require("./active_streaming_tool.js");
|
|
58
59
|
var import_context = require("./context.js");
|
|
59
60
|
var import_framework_function_calls = require("./framework_function_calls.js");
|
|
60
|
-
var
|
|
61
|
+
var import_instrumentation = require("../telemetry/api/instrumentation.js");
|
|
61
62
|
var import_event2 = require("../events/event.js");
|
|
62
63
|
var import_framework_function_calls2 = require("./framework_function_calls.js");
|
|
63
64
|
/**
|
|
@@ -165,28 +166,45 @@ function generateRequestConfirmationEvent({
|
|
|
165
166
|
}
|
|
166
167
|
__name(generateRequestConfirmationEvent, "generateRequestConfirmationEvent");
|
|
167
168
|
async function callToolAsync(tool, args, toolContext) {
|
|
168
|
-
return
|
|
169
|
-
|
|
169
|
+
return (0, import_instrumentation.recordToolExecution)(
|
|
170
|
+
{ tool, args, invocationContext: toolContext.invocationContext },
|
|
171
|
+
async (scope) => {
|
|
170
172
|
import_logger.logger.debug(`callToolAsync ${tool.name}`);
|
|
171
173
|
const result = await tool.runAsync({ args, toolContext });
|
|
172
|
-
|
|
173
|
-
tool,
|
|
174
|
-
args,
|
|
174
|
+
scope.recordSuccess({
|
|
175
175
|
functionResponseEvent: buildResponseEvent(
|
|
176
176
|
tool,
|
|
177
177
|
result,
|
|
178
178
|
toolContext,
|
|
179
179
|
toolContext.invocationContext
|
|
180
180
|
),
|
|
181
|
-
|
|
181
|
+
rawResult: result
|
|
182
182
|
});
|
|
183
183
|
return result;
|
|
184
|
-
} finally {
|
|
185
|
-
span.end();
|
|
186
184
|
}
|
|
187
|
-
|
|
185
|
+
);
|
|
188
186
|
}
|
|
189
187
|
__name(callToolAsync, "callToolAsync");
|
|
188
|
+
const BASE64 = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
189
|
+
function buildFunctionResponse({
|
|
190
|
+
tool,
|
|
191
|
+
id,
|
|
192
|
+
response
|
|
193
|
+
}) {
|
|
194
|
+
const image = (0, import_computer_use_tool.isComputerUseTool)(tool) ? response == null ? void 0 : response["image"] : void 0;
|
|
195
|
+
if (typeof image !== "object" || image === null || !("data" in image) || !("mimetype" in image) || typeof image.data !== "string" || typeof image.mimetype !== "string" || !BASE64.test(image.data)) {
|
|
196
|
+
return { id, name: tool.name, response };
|
|
197
|
+
}
|
|
198
|
+
const rest = { ...response };
|
|
199
|
+
delete rest["image"];
|
|
200
|
+
return {
|
|
201
|
+
id,
|
|
202
|
+
name: tool.name,
|
|
203
|
+
response: rest,
|
|
204
|
+
parts: [{ inlineData: { data: image.data, mimeType: image.mimetype } }]
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
__name(buildFunctionResponse, "buildFunctionResponse");
|
|
190
208
|
function buildResponseEvent(tool, functionResult, toolContext, invocationContext) {
|
|
191
209
|
let responseResult;
|
|
192
210
|
if (typeof functionResult !== "object" || functionResult == null) {
|
|
@@ -197,11 +215,11 @@ function buildResponseEvent(tool, functionResult, toolContext, invocationContext
|
|
|
197
215
|
responseResult = functionResult;
|
|
198
216
|
}
|
|
199
217
|
const partFunctionResponse = {
|
|
200
|
-
functionResponse: {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
218
|
+
functionResponse: buildFunctionResponse({
|
|
219
|
+
tool,
|
|
220
|
+
id: toolContext.functionCallId,
|
|
221
|
+
response: responseResult
|
|
222
|
+
})
|
|
205
223
|
};
|
|
206
224
|
const content = {
|
|
207
225
|
role: "user",
|
|
@@ -304,38 +322,35 @@ async function answerUnresolvableCall({
|
|
|
304
322
|
toolsDict,
|
|
305
323
|
toolContext
|
|
306
324
|
}) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
325
|
+
var _a2;
|
|
326
|
+
const toolName = functionCall.name || "<unnamed>";
|
|
327
|
+
const error = new Error(
|
|
328
|
+
`Function ${toolName} is not found in the toolsDict.`
|
|
329
|
+
);
|
|
330
|
+
const tool = new ToolNotFoundPlaceholder(toolName, error);
|
|
331
|
+
return (0, import_instrumentation.recordToolExecution)(
|
|
332
|
+
{ tool, args: (_a2 = functionCall.args) != null ? _a2 : {}, invocationContext },
|
|
333
|
+
async () => {
|
|
334
|
+
var _a3, _b2;
|
|
335
|
+
const onToolErrorResponse = await invocationContext.pluginManager.runOnToolErrorCallback({
|
|
336
|
+
tool,
|
|
337
|
+
toolArgs: (_a3 = functionCall.args) != null ? _a3 : {},
|
|
338
|
+
toolContext,
|
|
339
|
+
error
|
|
340
|
+
});
|
|
341
|
+
if (onToolErrorResponse == null) {
|
|
342
|
+
const callableTools = Object.keys(toolsDict);
|
|
343
|
+
import_logger.logger.warn(
|
|
344
|
+
`Could not resolve tool '${toolName}' for function call '${(_b2 = functionCall.id) != null ? _b2 : ""}'. Callable tools: ${callableTools.length ? callableTools.join(", ") : "(none)"}.
|
|
327
345
|
` + RESOLUTION_FAILURE_CAUSES
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
return buildResponseEvent(
|
|
331
|
-
tool,
|
|
332
|
-
onToolErrorResponse != null ? onToolErrorResponse : { error: error.message },
|
|
333
|
-
toolContext,
|
|
334
|
-
invocationContext
|
|
335
346
|
);
|
|
336
|
-
} finally {
|
|
337
|
-
span.end();
|
|
338
347
|
}
|
|
348
|
+
return buildResponseEvent(
|
|
349
|
+
tool,
|
|
350
|
+
onToolErrorResponse != null ? onToolErrorResponse : { error: error.message },
|
|
351
|
+
toolContext,
|
|
352
|
+
invocationContext
|
|
353
|
+
);
|
|
339
354
|
}
|
|
340
355
|
);
|
|
341
356
|
}
|
|
@@ -476,11 +491,11 @@ async function handleFunctionCallList({
|
|
|
476
491
|
invocationId: invocationContext.invocationId,
|
|
477
492
|
author: toolEventAuthor(invocationContext),
|
|
478
493
|
content: (0, import_genai.createUserContent)({
|
|
479
|
-
functionResponse: {
|
|
494
|
+
functionResponse: buildFunctionResponse({
|
|
495
|
+
tool,
|
|
480
496
|
id: toolContext.functionCallId,
|
|
481
|
-
name: tool.name,
|
|
482
497
|
response: functionResponse
|
|
483
|
-
}
|
|
498
|
+
})
|
|
484
499
|
}),
|
|
485
500
|
actions: toolContext.actions,
|
|
486
501
|
branch: invocationContext.branch
|
|
@@ -494,18 +509,8 @@ async function handleFunctionCallList({
|
|
|
494
509
|
functionResponseEvents
|
|
495
510
|
);
|
|
496
511
|
if (functionResponseEvents.length > 1) {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
import_logger.logger.debug("execute_tool (merged)");
|
|
500
|
-
(0, import_tracing.traceMergedToolCalls)({
|
|
501
|
-
responseEventId: mergedEvent.id,
|
|
502
|
-
functionResponseEvent: mergedEvent,
|
|
503
|
-
invocationContext
|
|
504
|
-
});
|
|
505
|
-
} finally {
|
|
506
|
-
span.end();
|
|
507
|
-
}
|
|
508
|
-
});
|
|
512
|
+
import_logger.logger.debug("execute_tool (merged)");
|
|
513
|
+
(0, import_instrumentation.recordMergedToolCalls)({ responseEventId: mergedEvent.id });
|
|
509
514
|
}
|
|
510
515
|
return mergedEvent;
|
|
511
516
|
}
|
|
@@ -29,6 +29,7 @@ __export(instructions_exports, {
|
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(instructions_exports);
|
|
31
31
|
var import_state = require("../sessions/state.js");
|
|
32
|
+
var import_load_artifacts_tool = require("../tools/load_artifacts_tool.js");
|
|
32
33
|
/**
|
|
33
34
|
* @license
|
|
34
35
|
* Copyright 2025 Google LLC
|
|
@@ -62,10 +63,13 @@ async function resolveKey(key, isOptional, rawMatch, readonlyContext) {
|
|
|
62
63
|
}
|
|
63
64
|
throw new Error(`Artifact ${fileName} not found.`);
|
|
64
65
|
}
|
|
65
|
-
return formatValue(
|
|
66
|
+
return formatValue(
|
|
67
|
+
(0, import_load_artifacts_tool.asSafePartForLlm)(artifact, fileName, { inlineMediaAsPlaceholder: true }),
|
|
68
|
+
true
|
|
69
|
+
);
|
|
66
70
|
}
|
|
67
71
|
if (isValidStateName(key)) {
|
|
68
|
-
if (
|
|
72
|
+
if (Object.hasOwn(invocationContext.session.state, key)) {
|
|
69
73
|
return formatValue(invocationContext.session.state[key], false);
|
|
70
74
|
}
|
|
71
75
|
if (isOptional) {
|
|
@@ -187,14 +191,12 @@ async function injectSessionState(template, readonlyContext) {
|
|
|
187
191
|
return result.join("");
|
|
188
192
|
}
|
|
189
193
|
__name(injectSessionState, "injectSessionState");
|
|
190
|
-
const
|
|
191
|
-
return /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
192
|
-
})();
|
|
194
|
+
const IDENTIFIER_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
193
195
|
function isIdentifier(s) {
|
|
194
196
|
if (s === "" || s === void 0) {
|
|
195
197
|
return false;
|
|
196
198
|
}
|
|
197
|
-
return
|
|
199
|
+
return IDENTIFIER_PATTERN.test(s);
|
|
198
200
|
}
|
|
199
201
|
__name(isIdentifier, "isIdentifier");
|
|
200
202
|
const VALID_PREFIXES = [import_state.State.APP_PREFIX, import_state.State.USER_PREFIX, import_state.State.TEMP_PREFIX];
|
|
@@ -32,7 +32,7 @@ __export(invocation_context_exports, {
|
|
|
32
32
|
requireAgent: () => requireAgent
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(invocation_context_exports);
|
|
35
|
-
var
|
|
35
|
+
var import_id_provider = require("../utils/id_provider.js");
|
|
36
36
|
/**
|
|
37
37
|
* @license
|
|
38
38
|
* Copyright 2025 Google LLC
|
|
@@ -141,7 +141,7 @@ const _InvocationContext = class _InvocationContext {
|
|
|
141
141
|
__name(_InvocationContext, "InvocationContext");
|
|
142
142
|
let InvocationContext = _InvocationContext;
|
|
143
143
|
function newInvocationContextId() {
|
|
144
|
-
return `e-${(0,
|
|
144
|
+
return `e-${(0, import_id_provider.newId)()}`;
|
|
145
145
|
}
|
|
146
146
|
__name(newInvocationContextId, "newInvocationContextId");
|
|
147
147
|
function requireAgent(ctx) {
|