@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,7 +30,6 @@ __export(llm_agent_exports, {
|
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(llm_agent_exports);
|
|
32
32
|
var import_genai = require("@google/genai");
|
|
33
|
-
var import_api = require("@opentelemetry/api");
|
|
34
33
|
var import_finish_task_tool = require("../tools/finish_task_tool.js");
|
|
35
34
|
var import_function_tool = require("../tools/function_tool.js");
|
|
36
35
|
var import_async_queue = require("../utils/async_queue.js");
|
|
@@ -43,10 +42,11 @@ var import_base_llm = require("../models/base_llm.js");
|
|
|
43
42
|
var import_registry = require("../models/registry.js");
|
|
44
43
|
var import_built_in_planner = require("../planners/built_in_planner.js");
|
|
45
44
|
var import_base_tool = require("../tools/base_tool.js");
|
|
45
|
+
var import_base_toolset = require("../tools/base_toolset.js");
|
|
46
46
|
var import_logger = require("../utils/logger.js");
|
|
47
47
|
var import_output_schema_utils = require("../utils/output_schema_utils.js");
|
|
48
48
|
var import_context = require("./context.js");
|
|
49
|
-
var
|
|
49
|
+
var import_instrumentation = require("../telemetry/api/instrumentation.js");
|
|
50
50
|
var import_schema = require("../utils/schema.js");
|
|
51
51
|
var import_simple_zod_to_json = require("../utils/simple_zod_to_json.js");
|
|
52
52
|
var import_base_agent = require("./base_agent.js");
|
|
@@ -103,6 +103,13 @@ function sleep(ms) {
|
|
|
103
103
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
104
104
|
}
|
|
105
105
|
__name(sleep, "sleep");
|
|
106
|
+
function hasSettledResponses(functionResponseEvent) {
|
|
107
|
+
const awaiting = functionResponseEvent.actions.requestedToolConfirmations;
|
|
108
|
+
return (0, import_event.getFunctionResponses)(functionResponseEvent).some(
|
|
109
|
+
(response) => !response.id || !Object.hasOwn(awaiting, response.id)
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
__name(hasSettledResponses, "hasSettledResponses");
|
|
106
113
|
const LIVE_KEYS = [
|
|
107
114
|
"responseModalities",
|
|
108
115
|
"speechConfig",
|
|
@@ -128,14 +135,14 @@ function applyLiveRunConfig(runConfig, llmRequest) {
|
|
|
128
135
|
}
|
|
129
136
|
__name(applyLiveRunConfig, "applyLiveRunConfig");
|
|
130
137
|
const ADK_AGENT_NAME_LABEL_KEY = "adk_agent_name";
|
|
131
|
-
async function convertToolUnionToTools(toolUnion,
|
|
138
|
+
async function convertToolUnionToTools(toolUnion, context) {
|
|
132
139
|
if ((0, import_base_tool.isBaseTool)(toolUnion)) {
|
|
133
140
|
return [toolUnion];
|
|
134
141
|
}
|
|
135
142
|
if ((0, import_base_node.isBaseNode)(toolUnion)) {
|
|
136
143
|
return [new import_node_tool.NodeTool(toolUnion)];
|
|
137
144
|
}
|
|
138
|
-
return await toolUnion.getTools(
|
|
145
|
+
return await toolUnion.getTools(context);
|
|
139
146
|
}
|
|
140
147
|
__name(convertToolUnionToTools, "convertToolUnionToTools");
|
|
141
148
|
const LLM_AGENT_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for("google.adk.llmAgent");
|
|
@@ -226,7 +233,7 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
226
233
|
}
|
|
227
234
|
if (config.generateContentConfig.responseSchema) {
|
|
228
235
|
throw new Error(
|
|
229
|
-
"Response schema must be set via LlmAgent.
|
|
236
|
+
"Response schema must be set via LlmAgent.outputSchema."
|
|
230
237
|
);
|
|
231
238
|
}
|
|
232
239
|
if (config.generateContentConfig.thinkingConfig && (0, import_built_in_planner.isBuiltInPlanner)(this.planner) && this.planner.thinkingConfig) {
|
|
@@ -287,12 +294,12 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
287
294
|
* @param context The context to retrieve the session state.
|
|
288
295
|
* @returns The resolved instruction field.
|
|
289
296
|
*/
|
|
290
|
-
async canonicalInstruction(
|
|
297
|
+
async canonicalInstruction(context) {
|
|
291
298
|
if (typeof this.instruction === "string") {
|
|
292
299
|
return { instruction: this.instruction, requireStateInjection: true };
|
|
293
300
|
}
|
|
294
301
|
return {
|
|
295
|
-
instruction: await this.instruction(
|
|
302
|
+
instruction: await this.instruction(context),
|
|
296
303
|
requireStateInjection: false
|
|
297
304
|
};
|
|
298
305
|
}
|
|
@@ -304,7 +311,7 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
304
311
|
* @returns The resolved globalInstruction field.
|
|
305
312
|
* @deprecated Use GlobalInstructionPlugin instead.
|
|
306
313
|
*/
|
|
307
|
-
async canonicalGlobalInstruction(
|
|
314
|
+
async canonicalGlobalInstruction(context) {
|
|
308
315
|
if (typeof this.globalInstruction === "string") {
|
|
309
316
|
return {
|
|
310
317
|
instruction: this.globalInstruction,
|
|
@@ -312,7 +319,7 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
312
319
|
};
|
|
313
320
|
}
|
|
314
321
|
return {
|
|
315
|
-
instruction: await this.globalInstruction(
|
|
322
|
+
instruction: await this.globalInstruction(context),
|
|
316
323
|
requireStateInjection: false
|
|
317
324
|
};
|
|
318
325
|
}
|
|
@@ -321,10 +328,10 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
321
328
|
*
|
|
322
329
|
* This method is only for use by Agent Development Kit.
|
|
323
330
|
*/
|
|
324
|
-
async canonicalTools(
|
|
331
|
+
async canonicalTools(context) {
|
|
325
332
|
const resolvedTools = [];
|
|
326
333
|
for (const toolUnion of this.tools) {
|
|
327
|
-
const tools = await convertToolUnionToTools(toolUnion,
|
|
334
|
+
const tools = await convertToolUnionToTools(toolUnion, context);
|
|
328
335
|
resolvedTools.push(...tools);
|
|
329
336
|
}
|
|
330
337
|
return resolvedTools;
|
|
@@ -414,7 +421,15 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
414
421
|
);
|
|
415
422
|
return;
|
|
416
423
|
}
|
|
417
|
-
|
|
424
|
+
if (!event.content.parts.some(
|
|
425
|
+
(part) => part.text !== void 0 && !part.thought
|
|
426
|
+
)) {
|
|
427
|
+
import_logger.logger.debug(
|
|
428
|
+
`Skipping output save for agent ${this.name}: event has no text`
|
|
429
|
+
);
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
const resultStr = event.content.parts.filter((part) => !part.thought).map((part) => part.text ? part.text : "").join("");
|
|
418
433
|
let result = resultStr;
|
|
419
434
|
if (this.outputSchema) {
|
|
420
435
|
if (!resultStr.trim()) {
|
|
@@ -467,14 +482,14 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
467
482
|
async *runImpl(ctx, nodeInput) {
|
|
468
483
|
yield* (0, import_run_llm_agent_as_node.runLlmAgentAsNode)(this, ctx, nodeInput);
|
|
469
484
|
}
|
|
470
|
-
async *runAsyncImpl(
|
|
485
|
+
async *runAsyncImpl(context) {
|
|
471
486
|
var _a2, _b2;
|
|
472
487
|
while (true) {
|
|
473
488
|
let lastEvent = void 0;
|
|
474
489
|
let stepHadToolCalls = false;
|
|
475
490
|
let stepTransferred = false;
|
|
476
|
-
for await (const event of this.runOneStepAsync(
|
|
477
|
-
if ((_a2 =
|
|
491
|
+
for await (const event of this.runOneStepAsync(context)) {
|
|
492
|
+
if ((_a2 = context.abortSignal) == null ? void 0 : _a2.aborted) {
|
|
478
493
|
return;
|
|
479
494
|
}
|
|
480
495
|
lastEvent = event;
|
|
@@ -500,16 +515,16 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
500
515
|
}
|
|
501
516
|
}
|
|
502
517
|
}
|
|
503
|
-
async *runLiveImpl(
|
|
518
|
+
async *runLiveImpl(context) {
|
|
504
519
|
var _a2;
|
|
505
|
-
for await (const event of this.runLiveFlow(
|
|
506
|
-
if ((_a2 =
|
|
520
|
+
for await (const event of this.runLiveFlow(context)) {
|
|
521
|
+
if ((_a2 = context.abortSignal) == null ? void 0 : _a2.aborted) {
|
|
507
522
|
return;
|
|
508
523
|
}
|
|
509
524
|
this.maybeSaveOutputToState(event);
|
|
510
525
|
yield event;
|
|
511
526
|
}
|
|
512
|
-
if (
|
|
527
|
+
if (context.endInvocation) {
|
|
513
528
|
return;
|
|
514
529
|
}
|
|
515
530
|
}
|
|
@@ -586,18 +601,14 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
586
601
|
throw err;
|
|
587
602
|
}
|
|
588
603
|
if (llmRequest.contents.length > 0 && !invocationContext.liveSessionResumptionHandle) {
|
|
589
|
-
await
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
(0,
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
} finally {
|
|
598
|
-
span.end();
|
|
599
|
-
}
|
|
600
|
-
});
|
|
604
|
+
await (0, import_instrumentation.recordSendData)(
|
|
605
|
+
{
|
|
606
|
+
invocationContext,
|
|
607
|
+
eventId: (0, import_event.createNewEventId)(),
|
|
608
|
+
data: llmRequest.contents
|
|
609
|
+
},
|
|
610
|
+
() => connection.sendHistory(llmRequest.contents)
|
|
611
|
+
);
|
|
601
612
|
}
|
|
602
613
|
let sendError;
|
|
603
614
|
const sendAbort = new AbortController();
|
|
@@ -658,7 +669,7 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
658
669
|
}
|
|
659
670
|
}
|
|
660
671
|
async *runLivePreprocess(invocationContext, llmRequest) {
|
|
661
|
-
var _a2, _b2;
|
|
672
|
+
var _a2, _b2, _c;
|
|
662
673
|
for (const processor of this.requestProcessors) {
|
|
663
674
|
for await (const event of processor.runAsync(
|
|
664
675
|
invocationContext,
|
|
@@ -672,6 +683,12 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
672
683
|
}
|
|
673
684
|
for (const toolUnion of this.tools) {
|
|
674
685
|
const toolContext = new import_context.Context({ invocationContext });
|
|
686
|
+
if ((0, import_base_toolset.isBaseToolset)(toolUnion)) {
|
|
687
|
+
await toolUnion.processLlmRequest(toolContext, llmRequest);
|
|
688
|
+
if ((_b2 = invocationContext.abortSignal) == null ? void 0 : _b2.aborted) {
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
675
692
|
const tools = (await convertToolUnionToTools(
|
|
676
693
|
toolUnion,
|
|
677
694
|
new import_readonly_context.ReadonlyContext(invocationContext)
|
|
@@ -680,7 +697,7 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
680
697
|
);
|
|
681
698
|
for (const tool of tools) {
|
|
682
699
|
await tool.processLlmRequest({ toolContext, llmRequest });
|
|
683
|
-
if ((
|
|
700
|
+
if ((_c = invocationContext.abortSignal) == null ? void 0 : _c.aborted) {
|
|
684
701
|
return;
|
|
685
702
|
}
|
|
686
703
|
}
|
|
@@ -903,7 +920,7 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
903
920
|
yield functionResponseEvent;
|
|
904
921
|
}
|
|
905
922
|
async *runOneStepAsync(invocationContext) {
|
|
906
|
-
var _a2, _b2, _c;
|
|
923
|
+
var _a2, _b2, _c, _d;
|
|
907
924
|
const llmRequest = {
|
|
908
925
|
contents: [],
|
|
909
926
|
toolsDict: {},
|
|
@@ -923,7 +940,7 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
923
940
|
const allTools = [...this.tools];
|
|
924
941
|
if (this.mode === "task") {
|
|
925
942
|
allTools.push(this.finishTaskTool);
|
|
926
|
-
} else if (this.outputSchema && allTools.length > 0 && !(0, import_output_schema_utils.canUseOutputSchemaWithTools)(this.canonicalModel
|
|
943
|
+
} else if (this.outputSchema && allTools.length > 0 && !(0, import_output_schema_utils.canUseOutputSchemaWithTools)(this.canonicalModel)) {
|
|
927
944
|
const setModelResponseTool = new import_function_tool.FunctionTool({
|
|
928
945
|
name: "set_model_response",
|
|
929
946
|
description: "Call this tool to submit your final response conforming to the output schema. Use this tool only when you have collected all the information and are ready to return the final answer.",
|
|
@@ -947,6 +964,12 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
947
964
|
invocationContext,
|
|
948
965
|
eventActions: modelResponseEvent.actions
|
|
949
966
|
});
|
|
967
|
+
if ((0, import_base_toolset.isBaseToolset)(toolUnion)) {
|
|
968
|
+
await toolUnion.processLlmRequest(toolContext, llmRequest);
|
|
969
|
+
if ((_b2 = invocationContext.abortSignal) == null ? void 0 : _b2.aborted) {
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
950
973
|
const tools = (await convertToolUnionToTools(
|
|
951
974
|
toolUnion,
|
|
952
975
|
new import_readonly_context.ReadonlyContext(invocationContext)
|
|
@@ -955,65 +978,53 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
955
978
|
});
|
|
956
979
|
for (const tool of tools) {
|
|
957
980
|
await tool.processLlmRequest({ toolContext, llmRequest });
|
|
958
|
-
if ((
|
|
981
|
+
if ((_c = invocationContext.abortSignal) == null ? void 0 : _c.aborted) {
|
|
959
982
|
return;
|
|
960
983
|
}
|
|
961
984
|
}
|
|
962
985
|
}
|
|
963
|
-
if (invocationContext.endInvocation || ((
|
|
986
|
+
if (invocationContext.endInvocation || ((_d = invocationContext.abortSignal) == null ? void 0 : _d.aborted)) {
|
|
964
987
|
return;
|
|
965
988
|
}
|
|
966
|
-
const
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
for await (const llmResponse of this.callLlmAsync(
|
|
976
|
-
invocationContext,
|
|
977
|
-
llmRequest,
|
|
978
|
-
modelResponseEvent
|
|
979
|
-
)) {
|
|
980
|
-
if ((_a3 = invocationContext.abortSignal) == null ? void 0 : _a3.aborted) {
|
|
981
|
-
return;
|
|
982
|
-
}
|
|
983
|
-
if (((_b3 = invocationContext.runConfig) == null ? void 0 : _b3.supportCfc) && (0, import_event.isEvent)(llmResponse)) {
|
|
984
|
-
modelResponseEvent.id = (0, import_event.createNewEventId)();
|
|
985
|
-
modelResponseEvent.timestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
986
|
-
yield llmResponse;
|
|
987
|
-
continue;
|
|
988
|
-
}
|
|
989
|
-
for await (const event of this.postprocess(
|
|
990
|
-
invocationContext,
|
|
991
|
-
llmRequest,
|
|
992
|
-
llmResponse,
|
|
993
|
-
modelResponseEvent
|
|
994
|
-
)) {
|
|
995
|
-
if ((_c2 = invocationContext.abortSignal) == null ? void 0 : _c2.aborted) {
|
|
996
|
-
return;
|
|
997
|
-
}
|
|
998
|
-
if (!event.partial) {
|
|
999
|
-
modelResponseEvent.id = (0, import_event.createNewEventId)();
|
|
1000
|
-
modelResponseEvent.timestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
1001
|
-
}
|
|
1002
|
-
yield event;
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
}, "responsesGenerator");
|
|
1006
|
-
yield* this.runAndHandleError(
|
|
1007
|
-
responsesGenerator.call(this),
|
|
1008
|
-
invocationContext,
|
|
1009
|
-
llmRequest,
|
|
1010
|
-
modelResponseEvent
|
|
1011
|
-
);
|
|
989
|
+
const responsesGenerator = /* @__PURE__ */ __name(async function* () {
|
|
990
|
+
var _a3, _b3, _c2;
|
|
991
|
+
for await (const llmResponse of this.callLlmAsync(
|
|
992
|
+
invocationContext,
|
|
993
|
+
llmRequest,
|
|
994
|
+
modelResponseEvent
|
|
995
|
+
)) {
|
|
996
|
+
if ((_a3 = invocationContext.abortSignal) == null ? void 0 : _a3.aborted) {
|
|
997
|
+
return;
|
|
1012
998
|
}
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
999
|
+
if (((_b3 = invocationContext.runConfig) == null ? void 0 : _b3.supportCfc) && (0, import_event.isEvent)(llmResponse)) {
|
|
1000
|
+
modelResponseEvent.id = (0, import_event.createNewEventId)();
|
|
1001
|
+
modelResponseEvent.timestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
1002
|
+
yield llmResponse;
|
|
1003
|
+
continue;
|
|
1004
|
+
}
|
|
1005
|
+
for await (const event of this.postprocess(
|
|
1006
|
+
invocationContext,
|
|
1007
|
+
llmRequest,
|
|
1008
|
+
llmResponse,
|
|
1009
|
+
modelResponseEvent
|
|
1010
|
+
)) {
|
|
1011
|
+
if ((_c2 = invocationContext.abortSignal) == null ? void 0 : _c2.aborted) {
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
if (!event.partial) {
|
|
1015
|
+
modelResponseEvent.id = (0, import_event.createNewEventId)();
|
|
1016
|
+
modelResponseEvent.timestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
1017
|
+
}
|
|
1018
|
+
yield event;
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
}, "responsesGenerator");
|
|
1022
|
+
yield* this.runAndHandleError(
|
|
1023
|
+
responsesGenerator.call(this),
|
|
1024
|
+
invocationContext,
|
|
1025
|
+
llmRequest,
|
|
1026
|
+
modelResponseEvent
|
|
1027
|
+
);
|
|
1017
1028
|
}
|
|
1018
1029
|
async *postprocess(invocationContext, llmRequest, llmResponse, modelResponseEvent) {
|
|
1019
1030
|
var _a2, _b2, _c, _d, _e, _f;
|
|
@@ -1056,6 +1067,9 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
1056
1067
|
if (!((_c = (0, import_event.getFunctionCalls)(mergedEvent)) == null ? void 0 : _c.length)) {
|
|
1057
1068
|
return;
|
|
1058
1069
|
}
|
|
1070
|
+
if (mergedEvent.partial) {
|
|
1071
|
+
return;
|
|
1072
|
+
}
|
|
1059
1073
|
if ((_d = invocationContext.runConfig) == null ? void 0 : _d.pauseOnToolCalls) {
|
|
1060
1074
|
invocationContext.endInvocation = true;
|
|
1061
1075
|
return;
|
|
@@ -1102,6 +1116,15 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
1102
1116
|
functionResponseEvent
|
|
1103
1117
|
});
|
|
1104
1118
|
if (toolConfirmationEvent) {
|
|
1119
|
+
if (hasSettledResponses(functionResponseEvent)) {
|
|
1120
|
+
const { requestedToolConfirmations, skipSummarization, ...settled } = functionResponseEvent.actions;
|
|
1121
|
+
functionResponseEvent.actions = (0, import_event_actions.createEventActions)(settled);
|
|
1122
|
+
toolConfirmationEvent.actions = (0, import_event_actions.createEventActions)({
|
|
1123
|
+
requestedToolConfirmations,
|
|
1124
|
+
skipSummarization
|
|
1125
|
+
});
|
|
1126
|
+
yield functionResponseEvent;
|
|
1127
|
+
}
|
|
1105
1128
|
yield toolConfirmationEvent;
|
|
1106
1129
|
invocationContext.endInvocation = true;
|
|
1107
1130
|
return;
|
|
@@ -1139,7 +1162,7 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
1139
1162
|
return agentToRun;
|
|
1140
1163
|
}
|
|
1141
1164
|
async *callLlmAsync(invocationContext, llmRequest, modelResponseEvent) {
|
|
1142
|
-
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j
|
|
1165
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1143
1166
|
const beforeModelResponse = await this.handleBeforeModelCallback(
|
|
1144
1167
|
invocationContext,
|
|
1145
1168
|
llmRequest,
|
|
@@ -1187,20 +1210,20 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
1187
1210
|
liveRequestQueue.close();
|
|
1188
1211
|
}
|
|
1189
1212
|
} else {
|
|
1190
|
-
const responsesGenerator =
|
|
1191
|
-
llmRequest,
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1213
|
+
const responsesGenerator = (0, import_instrumentation.recordInference)(
|
|
1214
|
+
{ invocationContext, llmRequest, modelResponseEvent },
|
|
1215
|
+
() => {
|
|
1216
|
+
var _a3;
|
|
1217
|
+
return llm.generateContentAsync(
|
|
1218
|
+
llmRequest,
|
|
1219
|
+
/* stream= */
|
|
1220
|
+
((_a3 = invocationContext.runConfig) == null ? void 0 : _a3.streamingMode) === import_run_config.StreamingMode.SSE,
|
|
1221
|
+
invocationContext.abortSignal
|
|
1222
|
+
);
|
|
1223
|
+
}
|
|
1195
1224
|
);
|
|
1196
1225
|
for await (const llmResponse of responsesGenerator) {
|
|
1197
|
-
(0
|
|
1198
|
-
invocationContext,
|
|
1199
|
-
eventId: modelResponseEvent.id,
|
|
1200
|
-
llmRequest,
|
|
1201
|
-
llmResponse
|
|
1202
|
-
});
|
|
1203
|
-
if ((_j = invocationContext.abortSignal) == null ? void 0 : _j.aborted) {
|
|
1226
|
+
if ((_i = invocationContext.abortSignal) == null ? void 0 : _i.aborted) {
|
|
1204
1227
|
return;
|
|
1205
1228
|
}
|
|
1206
1229
|
const alteredLlmResponse = await this.handleAfterModelCallback(
|
|
@@ -1208,7 +1231,7 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
1208
1231
|
llmResponse,
|
|
1209
1232
|
modelResponseEvent
|
|
1210
1233
|
);
|
|
1211
|
-
if ((
|
|
1234
|
+
if ((_j = invocationContext.abortSignal) == null ? void 0 : _j.aborted) {
|
|
1212
1235
|
return;
|
|
1213
1236
|
}
|
|
1214
1237
|
yield alteredLlmResponse != null ? alteredLlmResponse : llmResponse;
|
|
@@ -55,7 +55,7 @@ const _BasicLlmRequestProcessor = class _BasicLlmRequestProcessor extends import
|
|
|
55
55
|
}
|
|
56
56
|
llmRequest.model = agent.canonicalModel.model;
|
|
57
57
|
llmRequest.config = { ...(_a = agent.generateContentConfig) != null ? _a : {} };
|
|
58
|
-
if (agent.outputSchema && agent.mode !== "task" && (!((_b = agent.tools) == null ? void 0 : _b.length) || (0, import_output_schema_utils.canUseOutputSchemaWithTools)(agent.canonicalModel
|
|
58
|
+
if (agent.outputSchema && agent.mode !== "task" && (!((_b = agent.tools) == null ? void 0 : _b.length) || (0, import_output_schema_utils.canUseOutputSchemaWithTools)(agent.canonicalModel))) {
|
|
59
59
|
(0, import_llm_request.setOutputSchema)(llmRequest, agent.outputSchema);
|
|
60
60
|
}
|
|
61
61
|
if (invocationContext.runConfig) {
|
|
@@ -83,6 +83,14 @@ const DATA_FILE_UTIL_MAP = {
|
|
|
83
83
|
const DATA_FILE_HELPER_LIB = `
|
|
84
84
|
import pandas as pd
|
|
85
85
|
|
|
86
|
+
def crop(s: str, max_chars: int = 64) -> str:
|
|
87
|
+
"""Crops a string to max_chars characters."""
|
|
88
|
+
if len(s) <= max_chars:
|
|
89
|
+
return s
|
|
90
|
+
if max_chars >= 3:
|
|
91
|
+
return s[:max_chars - 3] + '...'
|
|
92
|
+
return s[:max_chars]
|
|
93
|
+
|
|
86
94
|
def explore_df(df: pd.DataFrame) -> None:
|
|
87
95
|
"""Prints some information about a pandas DataFrame."""
|
|
88
96
|
|
|
@@ -56,7 +56,7 @@ function removeClientFunctionCallId(content) {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
__name(removeClientFunctionCallId, "removeClientFunctionCallId");
|
|
59
|
-
function getContents(events, agentName, currentBranch, currentIsolationScope) {
|
|
59
|
+
function getContents(events, agentName, currentBranch, currentIsolationScope, preserveFunctionCallIds = false) {
|
|
60
60
|
const filteredEvents = [];
|
|
61
61
|
for (const event of events) {
|
|
62
62
|
if (!(0, import_compaction_utils.isEventVisibleInIsolationScope)(event, currentIsolationScope)) {
|
|
@@ -69,16 +69,23 @@ function getContents(events, agentName, currentBranch, currentIsolationScope) {
|
|
|
69
69
|
if (!shouldIncludeEventInContext(event, currentBranch, currentIsolationScope)) {
|
|
70
70
|
continue;
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
if (isEventFromAnotherAgent(agentName, event)) {
|
|
73
|
+
const converted = convertForeignEvent(event);
|
|
74
|
+
if (converted) {
|
|
75
|
+
filteredEvents.push(converted);
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
filteredEvents.push(event);
|
|
79
|
+
}
|
|
75
80
|
}
|
|
76
81
|
let resultEvents = rearrangeEventsForLatestFunctionResponse(filteredEvents);
|
|
77
82
|
resultEvents = rearrangeEventsForAsyncFunctionResponsesInHistory(resultEvents);
|
|
78
83
|
const contents = [];
|
|
79
84
|
for (const event of resultEvents) {
|
|
80
85
|
const content = (0, import_lodash_es.cloneDeep)(event.content);
|
|
81
|
-
|
|
86
|
+
if (!preserveFunctionCallIds) {
|
|
87
|
+
removeClientFunctionCallId(content);
|
|
88
|
+
}
|
|
82
89
|
contents.push(content);
|
|
83
90
|
}
|
|
84
91
|
return contents;
|
|
@@ -111,18 +118,20 @@ function isRequestInputEvent(event) {
|
|
|
111
118
|
return false;
|
|
112
119
|
}
|
|
113
120
|
__name(isRequestInputEvent, "isRequestInputEvent");
|
|
114
|
-
function getCurrentTurnContents(events, agentName, currentBranch, currentIsolationScope) {
|
|
121
|
+
function getCurrentTurnContents(events, agentName, currentBranch, currentIsolationScope, preserveFunctionCallIds = false) {
|
|
122
|
+
var _a;
|
|
115
123
|
for (let i = events.length - 1; i >= 0; i--) {
|
|
116
124
|
const event = events[i];
|
|
117
125
|
if (!shouldIncludeEventInContext(event, currentBranch, currentIsolationScope)) {
|
|
118
126
|
continue;
|
|
119
127
|
}
|
|
120
|
-
if (event.author === "user" || isEventFromAnotherAgent(agentName, event)) {
|
|
128
|
+
if (event.author === "user" || isEventFromAnotherAgent(agentName, event) && ((_a = event.content.parts) == null ? void 0 : _a.some(isVisibleForeignPart))) {
|
|
121
129
|
return getContents(
|
|
122
130
|
events.slice(turnStart(events, i)),
|
|
123
131
|
agentName,
|
|
124
132
|
currentBranch,
|
|
125
|
-
currentIsolationScope
|
|
133
|
+
currentIsolationScope,
|
|
134
|
+
preserveFunctionCallIds
|
|
126
135
|
);
|
|
127
136
|
}
|
|
128
137
|
}
|
|
@@ -187,8 +196,37 @@ function isEventFromAnotherAgent(agentName, event) {
|
|
|
187
196
|
return !!agentName && event.author !== agentName && event.author !== "user";
|
|
188
197
|
}
|
|
189
198
|
__name(isEventFromAnotherAgent, "isEventFromAnotherAgent");
|
|
199
|
+
function withoutTextAndThought(part) {
|
|
200
|
+
const {
|
|
201
|
+
text: _text,
|
|
202
|
+
thought: _thought,
|
|
203
|
+
thoughtSignature: _thoughtSignature,
|
|
204
|
+
...rest
|
|
205
|
+
} = part;
|
|
206
|
+
return rest;
|
|
207
|
+
}
|
|
208
|
+
__name(withoutTextAndThought, "withoutTextAndThought");
|
|
209
|
+
function hasNonTextPayload(part) {
|
|
210
|
+
return Object.values(withoutTextAndThought(part)).some(
|
|
211
|
+
(v) => v !== void 0
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
__name(hasNonTextPayload, "hasNonTextPayload");
|
|
215
|
+
function isVisibleForeignPart(part) {
|
|
216
|
+
if (part.functionCall || part.functionResponse) {
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
if (part.thought) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
if (part.text) {
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
return hasNonTextPayload(part);
|
|
226
|
+
}
|
|
227
|
+
__name(isVisibleForeignPart, "isVisibleForeignPart");
|
|
190
228
|
function convertForeignEvent(event) {
|
|
191
|
-
var _a, _b, _c, _d, _e, _f;
|
|
229
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
192
230
|
if (!((_b = (_a = event.content) == null ? void 0 : _a.parts) == null ? void 0 : _b.length)) {
|
|
193
231
|
return event;
|
|
194
232
|
}
|
|
@@ -201,26 +239,43 @@ function convertForeignEvent(event) {
|
|
|
201
239
|
]
|
|
202
240
|
};
|
|
203
241
|
for (const part of event.content.parts) {
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
242
|
+
if (!isVisibleForeignPart(part)) {
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
if (part.functionCall) {
|
|
246
|
+
if (!part.thought && part.text) {
|
|
247
|
+
(_c = content.parts) == null ? void 0 : _c.push({
|
|
248
|
+
text: `[${event.author}] said: ${part.text}`
|
|
249
|
+
});
|
|
250
|
+
}
|
|
209
251
|
(_d = content.parts) == null ? void 0 : _d.push({
|
|
210
252
|
text: `[${event.author}] called tool \`${part.functionCall.name}\` with parameters: ${safeStringify(
|
|
211
253
|
part.functionCall.args
|
|
212
254
|
)}`
|
|
213
255
|
});
|
|
214
256
|
} else if (part.functionResponse) {
|
|
215
|
-
(
|
|
257
|
+
if (!part.thought && part.text) {
|
|
258
|
+
(_e = content.parts) == null ? void 0 : _e.push({
|
|
259
|
+
text: `[${event.author}] said: ${part.text}`
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
(_f = content.parts) == null ? void 0 : _f.push({
|
|
216
263
|
text: `[${event.author}] tool \`${part.functionResponse.name}\` returned result: ${safeStringify(
|
|
217
264
|
part.functionResponse.response
|
|
218
265
|
)}`
|
|
219
266
|
});
|
|
220
|
-
} else {
|
|
221
|
-
(
|
|
267
|
+
} else if (!part.thought && part.text) {
|
|
268
|
+
(_g = content.parts) == null ? void 0 : _g.push({
|
|
269
|
+
text: `[${event.author}] said: ${part.text}`
|
|
270
|
+
});
|
|
271
|
+
} else if (hasNonTextPayload(part)) {
|
|
272
|
+
(_h = content.parts) == null ? void 0 : _h.push((0, import_lodash_es.cloneDeep)(withoutTextAndThought(part)));
|
|
222
273
|
}
|
|
223
274
|
}
|
|
275
|
+
const preambleOnly = content.parts.length === 1;
|
|
276
|
+
if (preambleOnly) {
|
|
277
|
+
return void 0;
|
|
278
|
+
}
|
|
224
279
|
return (0, import_event.createEvent)({
|
|
225
280
|
invocationId: event.invocationId,
|
|
226
281
|
author: "user",
|