@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
|
@@ -9,7 +9,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
9
9
|
*/
|
|
10
10
|
var _a, _b;
|
|
11
11
|
import { Modality } from "@google/genai";
|
|
12
|
-
import { context, trace } from "@opentelemetry/api";
|
|
13
12
|
import { FinishTaskTool } from "../tools/finish_task_tool.js";
|
|
14
13
|
import { FunctionTool } from "../tools/function_tool.js";
|
|
15
14
|
import { AsyncQueue } from "../utils/async_queue.js";
|
|
@@ -26,20 +25,22 @@ import {
|
|
|
26
25
|
isFinalResponse,
|
|
27
26
|
populateClientFunctionCallId
|
|
28
27
|
} from "../events/event.js";
|
|
29
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
createEventActions,
|
|
30
|
+
isDefaultEventActions
|
|
31
|
+
} from "../events/event_actions.js";
|
|
30
32
|
import { isBaseLlm } from "../models/base_llm.js";
|
|
31
33
|
import { LLMRegistry } from "../models/registry.js";
|
|
32
34
|
import { isBuiltInPlanner } from "../planners/built_in_planner.js";
|
|
33
35
|
import { isBaseTool } from "../tools/base_tool.js";
|
|
36
|
+
import { isBaseToolset } from "../tools/base_toolset.js";
|
|
34
37
|
import { logger } from "../utils/logger.js";
|
|
35
38
|
import { canUseOutputSchemaWithTools } from "../utils/output_schema_utils.js";
|
|
36
39
|
import { Context } from "./context.js";
|
|
37
40
|
import {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
traceSendData
|
|
42
|
-
} from "../telemetry/tracing.js";
|
|
41
|
+
recordInference,
|
|
42
|
+
recordSendData
|
|
43
|
+
} from "../telemetry/api/instrumentation.js";
|
|
43
44
|
import { parseWithSchema } from "../utils/schema.js";
|
|
44
45
|
import { isZodObject, zodObjectToSchema } from "../utils/simple_zod_to_json.js";
|
|
45
46
|
import { BaseAgent } from "./base_agent.js";
|
|
@@ -102,6 +103,13 @@ function sleep(ms) {
|
|
|
102
103
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
103
104
|
}
|
|
104
105
|
__name(sleep, "sleep");
|
|
106
|
+
function hasSettledResponses(functionResponseEvent) {
|
|
107
|
+
const awaiting = functionResponseEvent.actions.requestedToolConfirmations;
|
|
108
|
+
return getFunctionResponses(functionResponseEvent).some(
|
|
109
|
+
(response) => !response.id || !Object.hasOwn(awaiting, response.id)
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
__name(hasSettledResponses, "hasSettledResponses");
|
|
105
113
|
const LIVE_KEYS = [
|
|
106
114
|
"responseModalities",
|
|
107
115
|
"speechConfig",
|
|
@@ -127,14 +135,14 @@ function applyLiveRunConfig(runConfig, llmRequest) {
|
|
|
127
135
|
}
|
|
128
136
|
__name(applyLiveRunConfig, "applyLiveRunConfig");
|
|
129
137
|
const ADK_AGENT_NAME_LABEL_KEY = "adk_agent_name";
|
|
130
|
-
async function convertToolUnionToTools(toolUnion,
|
|
138
|
+
async function convertToolUnionToTools(toolUnion, context) {
|
|
131
139
|
if (isBaseTool(toolUnion)) {
|
|
132
140
|
return [toolUnion];
|
|
133
141
|
}
|
|
134
142
|
if (isBaseNode(toolUnion)) {
|
|
135
143
|
return [new NodeTool(toolUnion)];
|
|
136
144
|
}
|
|
137
|
-
return await toolUnion.getTools(
|
|
145
|
+
return await toolUnion.getTools(context);
|
|
138
146
|
}
|
|
139
147
|
__name(convertToolUnionToTools, "convertToolUnionToTools");
|
|
140
148
|
const LLM_AGENT_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for("google.adk.llmAgent");
|
|
@@ -225,7 +233,7 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
225
233
|
}
|
|
226
234
|
if (config.generateContentConfig.responseSchema) {
|
|
227
235
|
throw new Error(
|
|
228
|
-
"Response schema must be set via LlmAgent.
|
|
236
|
+
"Response schema must be set via LlmAgent.outputSchema."
|
|
229
237
|
);
|
|
230
238
|
}
|
|
231
239
|
if (config.generateContentConfig.thinkingConfig && isBuiltInPlanner(this.planner) && this.planner.thinkingConfig) {
|
|
@@ -286,12 +294,12 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
286
294
|
* @param context The context to retrieve the session state.
|
|
287
295
|
* @returns The resolved instruction field.
|
|
288
296
|
*/
|
|
289
|
-
async canonicalInstruction(
|
|
297
|
+
async canonicalInstruction(context) {
|
|
290
298
|
if (typeof this.instruction === "string") {
|
|
291
299
|
return { instruction: this.instruction, requireStateInjection: true };
|
|
292
300
|
}
|
|
293
301
|
return {
|
|
294
|
-
instruction: await this.instruction(
|
|
302
|
+
instruction: await this.instruction(context),
|
|
295
303
|
requireStateInjection: false
|
|
296
304
|
};
|
|
297
305
|
}
|
|
@@ -303,7 +311,7 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
303
311
|
* @returns The resolved globalInstruction field.
|
|
304
312
|
* @deprecated Use GlobalInstructionPlugin instead.
|
|
305
313
|
*/
|
|
306
|
-
async canonicalGlobalInstruction(
|
|
314
|
+
async canonicalGlobalInstruction(context) {
|
|
307
315
|
if (typeof this.globalInstruction === "string") {
|
|
308
316
|
return {
|
|
309
317
|
instruction: this.globalInstruction,
|
|
@@ -311,7 +319,7 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
311
319
|
};
|
|
312
320
|
}
|
|
313
321
|
return {
|
|
314
|
-
instruction: await this.globalInstruction(
|
|
322
|
+
instruction: await this.globalInstruction(context),
|
|
315
323
|
requireStateInjection: false
|
|
316
324
|
};
|
|
317
325
|
}
|
|
@@ -320,10 +328,10 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
320
328
|
*
|
|
321
329
|
* This method is only for use by Agent Development Kit.
|
|
322
330
|
*/
|
|
323
|
-
async canonicalTools(
|
|
331
|
+
async canonicalTools(context) {
|
|
324
332
|
const resolvedTools = [];
|
|
325
333
|
for (const toolUnion of this.tools) {
|
|
326
|
-
const tools = await convertToolUnionToTools(toolUnion,
|
|
334
|
+
const tools = await convertToolUnionToTools(toolUnion, context);
|
|
327
335
|
resolvedTools.push(...tools);
|
|
328
336
|
}
|
|
329
337
|
return resolvedTools;
|
|
@@ -413,7 +421,15 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
413
421
|
);
|
|
414
422
|
return;
|
|
415
423
|
}
|
|
416
|
-
|
|
424
|
+
if (!event.content.parts.some(
|
|
425
|
+
(part) => part.text !== void 0 && !part.thought
|
|
426
|
+
)) {
|
|
427
|
+
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("");
|
|
417
433
|
let result = resultStr;
|
|
418
434
|
if (this.outputSchema) {
|
|
419
435
|
if (!resultStr.trim()) {
|
|
@@ -466,14 +482,14 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
466
482
|
async *runImpl(ctx, nodeInput) {
|
|
467
483
|
yield* runLlmAgentAsNode(this, ctx, nodeInput);
|
|
468
484
|
}
|
|
469
|
-
async *runAsyncImpl(
|
|
485
|
+
async *runAsyncImpl(context) {
|
|
470
486
|
var _a2, _b2;
|
|
471
487
|
while (true) {
|
|
472
488
|
let lastEvent = void 0;
|
|
473
489
|
let stepHadToolCalls = false;
|
|
474
490
|
let stepTransferred = false;
|
|
475
|
-
for await (const event of this.runOneStepAsync(
|
|
476
|
-
if ((_a2 =
|
|
491
|
+
for await (const event of this.runOneStepAsync(context)) {
|
|
492
|
+
if ((_a2 = context.abortSignal) == null ? void 0 : _a2.aborted) {
|
|
477
493
|
return;
|
|
478
494
|
}
|
|
479
495
|
lastEvent = event;
|
|
@@ -499,16 +515,16 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
499
515
|
}
|
|
500
516
|
}
|
|
501
517
|
}
|
|
502
|
-
async *runLiveImpl(
|
|
518
|
+
async *runLiveImpl(context) {
|
|
503
519
|
var _a2;
|
|
504
|
-
for await (const event of this.runLiveFlow(
|
|
505
|
-
if ((_a2 =
|
|
520
|
+
for await (const event of this.runLiveFlow(context)) {
|
|
521
|
+
if ((_a2 = context.abortSignal) == null ? void 0 : _a2.aborted) {
|
|
506
522
|
return;
|
|
507
523
|
}
|
|
508
524
|
this.maybeSaveOutputToState(event);
|
|
509
525
|
yield event;
|
|
510
526
|
}
|
|
511
|
-
if (
|
|
527
|
+
if (context.endInvocation) {
|
|
512
528
|
return;
|
|
513
529
|
}
|
|
514
530
|
}
|
|
@@ -585,18 +601,14 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
585
601
|
throw err;
|
|
586
602
|
}
|
|
587
603
|
if (llmRequest.contents.length > 0 && !invocationContext.liveSessionResumptionHandle) {
|
|
588
|
-
await
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
} finally {
|
|
597
|
-
span.end();
|
|
598
|
-
}
|
|
599
|
-
});
|
|
604
|
+
await recordSendData(
|
|
605
|
+
{
|
|
606
|
+
invocationContext,
|
|
607
|
+
eventId: createNewEventId(),
|
|
608
|
+
data: llmRequest.contents
|
|
609
|
+
},
|
|
610
|
+
() => connection.sendHistory(llmRequest.contents)
|
|
611
|
+
);
|
|
600
612
|
}
|
|
601
613
|
let sendError;
|
|
602
614
|
const sendAbort = new AbortController();
|
|
@@ -657,7 +669,7 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
657
669
|
}
|
|
658
670
|
}
|
|
659
671
|
async *runLivePreprocess(invocationContext, llmRequest) {
|
|
660
|
-
var _a2, _b2;
|
|
672
|
+
var _a2, _b2, _c;
|
|
661
673
|
for (const processor of this.requestProcessors) {
|
|
662
674
|
for await (const event of processor.runAsync(
|
|
663
675
|
invocationContext,
|
|
@@ -671,6 +683,12 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
671
683
|
}
|
|
672
684
|
for (const toolUnion of this.tools) {
|
|
673
685
|
const toolContext = new Context({ invocationContext });
|
|
686
|
+
if (isBaseToolset(toolUnion)) {
|
|
687
|
+
await toolUnion.processLlmRequest(toolContext, llmRequest);
|
|
688
|
+
if ((_b2 = invocationContext.abortSignal) == null ? void 0 : _b2.aborted) {
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
674
692
|
const tools = (await convertToolUnionToTools(
|
|
675
693
|
toolUnion,
|
|
676
694
|
new ReadonlyContext(invocationContext)
|
|
@@ -679,7 +697,7 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
679
697
|
);
|
|
680
698
|
for (const tool of tools) {
|
|
681
699
|
await tool.processLlmRequest({ toolContext, llmRequest });
|
|
682
|
-
if ((
|
|
700
|
+
if ((_c = invocationContext.abortSignal) == null ? void 0 : _c.aborted) {
|
|
683
701
|
return;
|
|
684
702
|
}
|
|
685
703
|
}
|
|
@@ -902,7 +920,7 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
902
920
|
yield functionResponseEvent;
|
|
903
921
|
}
|
|
904
922
|
async *runOneStepAsync(invocationContext) {
|
|
905
|
-
var _a2, _b2, _c;
|
|
923
|
+
var _a2, _b2, _c, _d;
|
|
906
924
|
const llmRequest = {
|
|
907
925
|
contents: [],
|
|
908
926
|
toolsDict: {},
|
|
@@ -922,7 +940,7 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
922
940
|
const allTools = [...this.tools];
|
|
923
941
|
if (this.mode === "task") {
|
|
924
942
|
allTools.push(this.finishTaskTool);
|
|
925
|
-
} else if (this.outputSchema && allTools.length > 0 && !canUseOutputSchemaWithTools(this.canonicalModel
|
|
943
|
+
} else if (this.outputSchema && allTools.length > 0 && !canUseOutputSchemaWithTools(this.canonicalModel)) {
|
|
926
944
|
const setModelResponseTool = new FunctionTool({
|
|
927
945
|
name: "set_model_response",
|
|
928
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.",
|
|
@@ -946,6 +964,12 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
946
964
|
invocationContext,
|
|
947
965
|
eventActions: modelResponseEvent.actions
|
|
948
966
|
});
|
|
967
|
+
if (isBaseToolset(toolUnion)) {
|
|
968
|
+
await toolUnion.processLlmRequest(toolContext, llmRequest);
|
|
969
|
+
if ((_b2 = invocationContext.abortSignal) == null ? void 0 : _b2.aborted) {
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
949
973
|
const tools = (await convertToolUnionToTools(
|
|
950
974
|
toolUnion,
|
|
951
975
|
new ReadonlyContext(invocationContext)
|
|
@@ -954,65 +978,53 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
954
978
|
});
|
|
955
979
|
for (const tool of tools) {
|
|
956
980
|
await tool.processLlmRequest({ toolContext, llmRequest });
|
|
957
|
-
if ((
|
|
981
|
+
if ((_c = invocationContext.abortSignal) == null ? void 0 : _c.aborted) {
|
|
958
982
|
return;
|
|
959
983
|
}
|
|
960
984
|
}
|
|
961
985
|
}
|
|
962
|
-
if (invocationContext.endInvocation || ((
|
|
986
|
+
if (invocationContext.endInvocation || ((_d = invocationContext.abortSignal) == null ? void 0 : _d.aborted)) {
|
|
963
987
|
return;
|
|
964
988
|
}
|
|
965
|
-
const
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
for await (const llmResponse of this.callLlmAsync(
|
|
975
|
-
invocationContext,
|
|
976
|
-
llmRequest,
|
|
977
|
-
modelResponseEvent
|
|
978
|
-
)) {
|
|
979
|
-
if ((_a3 = invocationContext.abortSignal) == null ? void 0 : _a3.aborted) {
|
|
980
|
-
return;
|
|
981
|
-
}
|
|
982
|
-
if (((_b3 = invocationContext.runConfig) == null ? void 0 : _b3.supportCfc) && isEvent(llmResponse)) {
|
|
983
|
-
modelResponseEvent.id = createNewEventId();
|
|
984
|
-
modelResponseEvent.timestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
985
|
-
yield llmResponse;
|
|
986
|
-
continue;
|
|
987
|
-
}
|
|
988
|
-
for await (const event of this.postprocess(
|
|
989
|
-
invocationContext,
|
|
990
|
-
llmRequest,
|
|
991
|
-
llmResponse,
|
|
992
|
-
modelResponseEvent
|
|
993
|
-
)) {
|
|
994
|
-
if ((_c2 = invocationContext.abortSignal) == null ? void 0 : _c2.aborted) {
|
|
995
|
-
return;
|
|
996
|
-
}
|
|
997
|
-
if (!event.partial) {
|
|
998
|
-
modelResponseEvent.id = createNewEventId();
|
|
999
|
-
modelResponseEvent.timestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
1000
|
-
}
|
|
1001
|
-
yield event;
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
}, "responsesGenerator");
|
|
1005
|
-
yield* this.runAndHandleError(
|
|
1006
|
-
responsesGenerator.call(this),
|
|
1007
|
-
invocationContext,
|
|
1008
|
-
llmRequest,
|
|
1009
|
-
modelResponseEvent
|
|
1010
|
-
);
|
|
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;
|
|
1011
998
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
999
|
+
if (((_b3 = invocationContext.runConfig) == null ? void 0 : _b3.supportCfc) && isEvent(llmResponse)) {
|
|
1000
|
+
modelResponseEvent.id = 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 = 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
|
+
);
|
|
1016
1028
|
}
|
|
1017
1029
|
async *postprocess(invocationContext, llmRequest, llmResponse, modelResponseEvent) {
|
|
1018
1030
|
var _a2, _b2, _c, _d, _e, _f;
|
|
@@ -1055,6 +1067,9 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
1055
1067
|
if (!((_c = getFunctionCalls(mergedEvent)) == null ? void 0 : _c.length)) {
|
|
1056
1068
|
return;
|
|
1057
1069
|
}
|
|
1070
|
+
if (mergedEvent.partial) {
|
|
1071
|
+
return;
|
|
1072
|
+
}
|
|
1058
1073
|
if ((_d = invocationContext.runConfig) == null ? void 0 : _d.pauseOnToolCalls) {
|
|
1059
1074
|
invocationContext.endInvocation = true;
|
|
1060
1075
|
return;
|
|
@@ -1101,6 +1116,15 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
1101
1116
|
functionResponseEvent
|
|
1102
1117
|
});
|
|
1103
1118
|
if (toolConfirmationEvent) {
|
|
1119
|
+
if (hasSettledResponses(functionResponseEvent)) {
|
|
1120
|
+
const { requestedToolConfirmations, skipSummarization, ...settled } = functionResponseEvent.actions;
|
|
1121
|
+
functionResponseEvent.actions = createEventActions(settled);
|
|
1122
|
+
toolConfirmationEvent.actions = createEventActions({
|
|
1123
|
+
requestedToolConfirmations,
|
|
1124
|
+
skipSummarization
|
|
1125
|
+
});
|
|
1126
|
+
yield functionResponseEvent;
|
|
1127
|
+
}
|
|
1104
1128
|
yield toolConfirmationEvent;
|
|
1105
1129
|
invocationContext.endInvocation = true;
|
|
1106
1130
|
return;
|
|
@@ -1138,7 +1162,7 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
1138
1162
|
return agentToRun;
|
|
1139
1163
|
}
|
|
1140
1164
|
async *callLlmAsync(invocationContext, llmRequest, modelResponseEvent) {
|
|
1141
|
-
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j
|
|
1165
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1142
1166
|
const beforeModelResponse = await this.handleBeforeModelCallback(
|
|
1143
1167
|
invocationContext,
|
|
1144
1168
|
llmRequest,
|
|
@@ -1186,20 +1210,20 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
1186
1210
|
liveRequestQueue.close();
|
|
1187
1211
|
}
|
|
1188
1212
|
} else {
|
|
1189
|
-
const responsesGenerator =
|
|
1190
|
-
llmRequest,
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1213
|
+
const responsesGenerator = 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) === StreamingMode.SSE,
|
|
1221
|
+
invocationContext.abortSignal
|
|
1222
|
+
);
|
|
1223
|
+
}
|
|
1194
1224
|
);
|
|
1195
1225
|
for await (const llmResponse of responsesGenerator) {
|
|
1196
|
-
|
|
1197
|
-
invocationContext,
|
|
1198
|
-
eventId: modelResponseEvent.id,
|
|
1199
|
-
llmRequest,
|
|
1200
|
-
llmResponse
|
|
1201
|
-
});
|
|
1202
|
-
if ((_j = invocationContext.abortSignal) == null ? void 0 : _j.aborted) {
|
|
1226
|
+
if ((_i = invocationContext.abortSignal) == null ? void 0 : _i.aborted) {
|
|
1203
1227
|
return;
|
|
1204
1228
|
}
|
|
1205
1229
|
const alteredLlmResponse = await this.handleAfterModelCallback(
|
|
@@ -1207,7 +1231,7 @@ const _LlmAgent = class _LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNAT
|
|
|
1207
1231
|
llmResponse,
|
|
1208
1232
|
modelResponseEvent
|
|
1209
1233
|
);
|
|
1210
|
-
if ((
|
|
1234
|
+
if ((_j = invocationContext.abortSignal) == null ? void 0 : _j.aborted) {
|
|
1211
1235
|
return;
|
|
1212
1236
|
}
|
|
1213
1237
|
yield alteredLlmResponse != null ? alteredLlmResponse : llmResponse;
|
|
@@ -28,7 +28,7 @@ const _BasicLlmRequestProcessor = class _BasicLlmRequestProcessor extends BaseLl
|
|
|
28
28
|
}
|
|
29
29
|
llmRequest.model = agent.canonicalModel.model;
|
|
30
30
|
llmRequest.config = { ...(_a = agent.generateContentConfig) != null ? _a : {} };
|
|
31
|
-
if (agent.outputSchema && agent.mode !== "task" && (!((_b = agent.tools) == null ? void 0 : _b.length) || canUseOutputSchemaWithTools(agent.canonicalModel
|
|
31
|
+
if (agent.outputSchema && agent.mode !== "task" && (!((_b = agent.tools) == null ? void 0 : _b.length) || canUseOutputSchemaWithTools(agent.canonicalModel))) {
|
|
32
32
|
setOutputSchema(llmRequest, agent.outputSchema);
|
|
33
33
|
}
|
|
34
34
|
if (invocationContext.runConfig) {
|
|
@@ -63,6 +63,14 @@ const DATA_FILE_UTIL_MAP = {
|
|
|
63
63
|
const DATA_FILE_HELPER_LIB = `
|
|
64
64
|
import pandas as pd
|
|
65
65
|
|
|
66
|
+
def crop(s: str, max_chars: int = 64) -> str:
|
|
67
|
+
"""Crops a string to max_chars characters."""
|
|
68
|
+
if len(s) <= max_chars:
|
|
69
|
+
return s
|
|
70
|
+
if max_chars >= 3:
|
|
71
|
+
return s[:max_chars - 3] + '...'
|
|
72
|
+
return s[:max_chars]
|
|
73
|
+
|
|
66
74
|
def explore_df(df: pd.DataFrame) -> None:
|
|
67
75
|
"""Prints some information about a pandas DataFrame."""
|
|
68
76
|
|
|
@@ -38,7 +38,7 @@ function removeClientFunctionCallId(content) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
__name(removeClientFunctionCallId, "removeClientFunctionCallId");
|
|
41
|
-
function getContents(events, agentName, currentBranch, currentIsolationScope) {
|
|
41
|
+
function getContents(events, agentName, currentBranch, currentIsolationScope, preserveFunctionCallIds = false) {
|
|
42
42
|
const filteredEvents = [];
|
|
43
43
|
for (const event of events) {
|
|
44
44
|
if (!isEventVisibleInIsolationScope(event, currentIsolationScope)) {
|
|
@@ -51,16 +51,23 @@ function getContents(events, agentName, currentBranch, currentIsolationScope) {
|
|
|
51
51
|
if (!shouldIncludeEventInContext(event, currentBranch, currentIsolationScope)) {
|
|
52
52
|
continue;
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
if (isEventFromAnotherAgent(agentName, event)) {
|
|
55
|
+
const converted = convertForeignEvent(event);
|
|
56
|
+
if (converted) {
|
|
57
|
+
filteredEvents.push(converted);
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
filteredEvents.push(event);
|
|
61
|
+
}
|
|
57
62
|
}
|
|
58
63
|
let resultEvents = rearrangeEventsForLatestFunctionResponse(filteredEvents);
|
|
59
64
|
resultEvents = rearrangeEventsForAsyncFunctionResponsesInHistory(resultEvents);
|
|
60
65
|
const contents = [];
|
|
61
66
|
for (const event of resultEvents) {
|
|
62
67
|
const content = cloneDeep(event.content);
|
|
63
|
-
|
|
68
|
+
if (!preserveFunctionCallIds) {
|
|
69
|
+
removeClientFunctionCallId(content);
|
|
70
|
+
}
|
|
64
71
|
contents.push(content);
|
|
65
72
|
}
|
|
66
73
|
return contents;
|
|
@@ -93,18 +100,20 @@ function isRequestInputEvent(event) {
|
|
|
93
100
|
return false;
|
|
94
101
|
}
|
|
95
102
|
__name(isRequestInputEvent, "isRequestInputEvent");
|
|
96
|
-
function getCurrentTurnContents(events, agentName, currentBranch, currentIsolationScope) {
|
|
103
|
+
function getCurrentTurnContents(events, agentName, currentBranch, currentIsolationScope, preserveFunctionCallIds = false) {
|
|
104
|
+
var _a;
|
|
97
105
|
for (let i = events.length - 1; i >= 0; i--) {
|
|
98
106
|
const event = events[i];
|
|
99
107
|
if (!shouldIncludeEventInContext(event, currentBranch, currentIsolationScope)) {
|
|
100
108
|
continue;
|
|
101
109
|
}
|
|
102
|
-
if (event.author === "user" || isEventFromAnotherAgent(agentName, event)) {
|
|
110
|
+
if (event.author === "user" || isEventFromAnotherAgent(agentName, event) && ((_a = event.content.parts) == null ? void 0 : _a.some(isVisibleForeignPart))) {
|
|
103
111
|
return getContents(
|
|
104
112
|
events.slice(turnStart(events, i)),
|
|
105
113
|
agentName,
|
|
106
114
|
currentBranch,
|
|
107
|
-
currentIsolationScope
|
|
115
|
+
currentIsolationScope,
|
|
116
|
+
preserveFunctionCallIds
|
|
108
117
|
);
|
|
109
118
|
}
|
|
110
119
|
}
|
|
@@ -169,8 +178,37 @@ function isEventFromAnotherAgent(agentName, event) {
|
|
|
169
178
|
return !!agentName && event.author !== agentName && event.author !== "user";
|
|
170
179
|
}
|
|
171
180
|
__name(isEventFromAnotherAgent, "isEventFromAnotherAgent");
|
|
181
|
+
function withoutTextAndThought(part) {
|
|
182
|
+
const {
|
|
183
|
+
text: _text,
|
|
184
|
+
thought: _thought,
|
|
185
|
+
thoughtSignature: _thoughtSignature,
|
|
186
|
+
...rest
|
|
187
|
+
} = part;
|
|
188
|
+
return rest;
|
|
189
|
+
}
|
|
190
|
+
__name(withoutTextAndThought, "withoutTextAndThought");
|
|
191
|
+
function hasNonTextPayload(part) {
|
|
192
|
+
return Object.values(withoutTextAndThought(part)).some(
|
|
193
|
+
(v) => v !== void 0
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
__name(hasNonTextPayload, "hasNonTextPayload");
|
|
197
|
+
function isVisibleForeignPart(part) {
|
|
198
|
+
if (part.functionCall || part.functionResponse) {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
if (part.thought) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
if (part.text) {
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
return hasNonTextPayload(part);
|
|
208
|
+
}
|
|
209
|
+
__name(isVisibleForeignPart, "isVisibleForeignPart");
|
|
172
210
|
function convertForeignEvent(event) {
|
|
173
|
-
var _a, _b, _c, _d, _e, _f;
|
|
211
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
174
212
|
if (!((_b = (_a = event.content) == null ? void 0 : _a.parts) == null ? void 0 : _b.length)) {
|
|
175
213
|
return event;
|
|
176
214
|
}
|
|
@@ -183,26 +221,43 @@ function convertForeignEvent(event) {
|
|
|
183
221
|
]
|
|
184
222
|
};
|
|
185
223
|
for (const part of event.content.parts) {
|
|
186
|
-
if (
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
224
|
+
if (!isVisibleForeignPart(part)) {
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if (part.functionCall) {
|
|
228
|
+
if (!part.thought && part.text) {
|
|
229
|
+
(_c = content.parts) == null ? void 0 : _c.push({
|
|
230
|
+
text: `[${event.author}] said: ${part.text}`
|
|
231
|
+
});
|
|
232
|
+
}
|
|
191
233
|
(_d = content.parts) == null ? void 0 : _d.push({
|
|
192
234
|
text: `[${event.author}] called tool \`${part.functionCall.name}\` with parameters: ${safeStringify(
|
|
193
235
|
part.functionCall.args
|
|
194
236
|
)}`
|
|
195
237
|
});
|
|
196
238
|
} else if (part.functionResponse) {
|
|
197
|
-
(
|
|
239
|
+
if (!part.thought && part.text) {
|
|
240
|
+
(_e = content.parts) == null ? void 0 : _e.push({
|
|
241
|
+
text: `[${event.author}] said: ${part.text}`
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
(_f = content.parts) == null ? void 0 : _f.push({
|
|
198
245
|
text: `[${event.author}] tool \`${part.functionResponse.name}\` returned result: ${safeStringify(
|
|
199
246
|
part.functionResponse.response
|
|
200
247
|
)}`
|
|
201
248
|
});
|
|
202
|
-
} else {
|
|
203
|
-
(
|
|
249
|
+
} else if (!part.thought && part.text) {
|
|
250
|
+
(_g = content.parts) == null ? void 0 : _g.push({
|
|
251
|
+
text: `[${event.author}] said: ${part.text}`
|
|
252
|
+
});
|
|
253
|
+
} else if (hasNonTextPayload(part)) {
|
|
254
|
+
(_h = content.parts) == null ? void 0 : _h.push(cloneDeep(withoutTextAndThought(part)));
|
|
204
255
|
}
|
|
205
256
|
}
|
|
257
|
+
const preambleOnly = content.parts.length === 1;
|
|
258
|
+
if (preambleOnly) {
|
|
259
|
+
return void 0;
|
|
260
|
+
}
|
|
206
261
|
return createEvent({
|
|
207
262
|
invocationId: event.invocationId,
|
|
208
263
|
author: "user",
|