@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
package/dist/cjs/cli/cli_eval.js
CHANGED
|
@@ -38,13 +38,20 @@ __export(cli_eval_exports, {
|
|
|
38
38
|
DEFAULT_CRITERIA: () => DEFAULT_CRITERIA,
|
|
39
39
|
EVAL_SESSION_ID_PREFIX: () => EVAL_SESSION_ID_PREFIX,
|
|
40
40
|
EvalStatus: () => EvalStatus,
|
|
41
|
+
LocalEvalSetResultsManager: () => LocalEvalSetResultsManager,
|
|
42
|
+
LocalEvalSetsManager: () => LocalEvalSetsManager,
|
|
41
43
|
MISSING_EVAL_DEPENDENCIES_MESSAGE: () => MISSING_EVAL_DEPENDENCIES_MESSAGE,
|
|
42
44
|
RESPONSE_EVALUATION_SCORE_KEY: () => RESPONSE_EVALUATION_SCORE_KEY,
|
|
43
45
|
RESPONSE_MATCH_SCORE_KEY: () => RESPONSE_MATCH_SCORE_KEY,
|
|
44
46
|
TOOL_TRAJECTORY_SCORE_KEY: () => TOOL_TRAJECTORY_SCORE_KEY,
|
|
47
|
+
convertEvalSetToSchema: () => convertEvalSetToSchema,
|
|
48
|
+
createEvalSetResult: () => createEvalSetResult,
|
|
45
49
|
getEvaluationCriteriaOrDefault: () => getEvaluationCriteriaOrDefault,
|
|
46
50
|
getRootAgent: () => getRootAgent,
|
|
51
|
+
loadEvalSetFromFile: () => loadEvalSetFromFile,
|
|
52
|
+
normalizeEvalCase: () => normalizeEvalCase,
|
|
47
53
|
parseAndGetEvalsToRun: () => parseAndGetEvalsToRun,
|
|
54
|
+
parseEvalSetResultJson: () => parseEvalSetResultJson,
|
|
48
55
|
runEvals: () => runEvals,
|
|
49
56
|
tryGetResetFunc: () => tryGetResetFunc
|
|
50
57
|
});
|
|
@@ -56,10 +63,14 @@ var import_node_url = require("node:url");
|
|
|
56
63
|
var import_base_agent = require("../agents/base_agent.js");
|
|
57
64
|
var import_llm_agent = require("../agents/llm_agent.js");
|
|
58
65
|
var import_in_memory_artifact_service = require("../artifacts/in_memory_artifact_service.js");
|
|
66
|
+
var import_input_validation_error = require("../errors/input_validation_error.js");
|
|
67
|
+
var import_not_found_error = require("../errors/not_found_error.js");
|
|
68
|
+
var import_internal_metadata = require("../events/internal_metadata.js");
|
|
59
69
|
var import_runner = require("../runner/runner.js");
|
|
60
70
|
var import_in_memory_session_service = require("../sessions/in_memory_session_service.js");
|
|
61
71
|
var import_logger = require("../utils/logger.js");
|
|
62
72
|
var import_evals = require("./utils/evals.js");
|
|
73
|
+
var import_path_validation = require("./utils/path_validation.js");
|
|
63
74
|
/**
|
|
64
75
|
* @license
|
|
65
76
|
* Copyright 2026 Google LLC
|
|
@@ -145,8 +156,9 @@ function parseAndGetEvalsToRun(evalSetFilePaths) {
|
|
|
145
156
|
for (const inputEvalSet of evalSetFilePaths) {
|
|
146
157
|
let evalSetFile;
|
|
147
158
|
let evals = [];
|
|
148
|
-
|
|
149
|
-
|
|
159
|
+
const hasDrivePrefix = /^[A-Za-z]:[\\/]/.test(inputEvalSet);
|
|
160
|
+
const colonIndex = inputEvalSet.indexOf(":", hasDrivePrefix ? 3 : 0);
|
|
161
|
+
if (colonIndex !== -1) {
|
|
150
162
|
evalSetFile = inputEvalSet.slice(0, colonIndex);
|
|
151
163
|
evals = inputEvalSet.slice(colonIndex + 1).split(",").filter((s) => s.length > 0);
|
|
152
164
|
} else {
|
|
@@ -293,6 +305,23 @@ function evaluateSingleMetric(metric, actualInvocations, expectedInvocations) {
|
|
|
293
305
|
};
|
|
294
306
|
}
|
|
295
307
|
__name(evaluateSingleMetric, "evaluateSingleMetric");
|
|
308
|
+
const MOCK_TOOL_OUTPUT_RESPONSE_KEY = "result";
|
|
309
|
+
const declaredToolResponses = /* @__PURE__ */ new WeakMap();
|
|
310
|
+
function getMockToolResponse(toolUse) {
|
|
311
|
+
const declared = declaredToolResponses.get(toolUse);
|
|
312
|
+
if (declared !== void 0) {
|
|
313
|
+
return declared;
|
|
314
|
+
}
|
|
315
|
+
if (toolUse.mock_tool_output !== void 0) {
|
|
316
|
+
return { [MOCK_TOOL_OUTPUT_RESPONSE_KEY]: toolUse.mock_tool_output };
|
|
317
|
+
}
|
|
318
|
+
return void 0;
|
|
319
|
+
}
|
|
320
|
+
__name(getMockToolResponse, "getMockToolResponse");
|
|
321
|
+
function isEvalEntry(evalCase) {
|
|
322
|
+
return "data" in evalCase && Array.isArray(evalCase.data);
|
|
323
|
+
}
|
|
324
|
+
__name(isEvalEntry, "isEvalEntry");
|
|
296
325
|
function installMockToolOutputCallbacks(agent, interceptor, savedCallbacks) {
|
|
297
326
|
if ((0, import_llm_agent.isLlmAgent)(agent) && !savedCallbacks.has(agent)) {
|
|
298
327
|
savedCallbacks.set(agent, agent.beforeToolCallback);
|
|
@@ -305,7 +334,7 @@ function installMockToolOutputCallbacks(agent, interceptor, savedCallbacks) {
|
|
|
305
334
|
}
|
|
306
335
|
__name(installMockToolOutputCallbacks, "installMockToolOutputCallbacks");
|
|
307
336
|
async function generateActualInvocations(rootAgent, evalCase, resetFunc, sessionService, artifactService) {
|
|
308
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
337
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
309
338
|
if (resetFunc) {
|
|
310
339
|
await resetFunc();
|
|
311
340
|
}
|
|
@@ -327,8 +356,13 @@ async function generateActualInvocations(rootAgent, evalCase, resetFunc, session
|
|
|
327
356
|
const pendingMockToolUses = [];
|
|
328
357
|
for (const turn of evalCase.data) {
|
|
329
358
|
for (const expectedTool of (_g = turn.expected_tool_use) != null ? _g : []) {
|
|
330
|
-
|
|
331
|
-
|
|
359
|
+
const response = getMockToolResponse(expectedTool);
|
|
360
|
+
if (response !== void 0) {
|
|
361
|
+
pendingMockToolUses.push({
|
|
362
|
+
toolName: expectedTool.tool_name,
|
|
363
|
+
toolInput: (_h = expectedTool.tool_input) != null ? _h : {},
|
|
364
|
+
response
|
|
365
|
+
});
|
|
332
366
|
}
|
|
333
367
|
}
|
|
334
368
|
}
|
|
@@ -336,14 +370,11 @@ async function generateActualInvocations(rootAgent, evalCase, resetFunc, session
|
|
|
336
370
|
if (pendingMockToolUses.length > 0) {
|
|
337
371
|
const interceptor = /* @__PURE__ */ __name(({ tool, args }) => {
|
|
338
372
|
const idx = pendingMockToolUses.findIndex(
|
|
339
|
-
(expected) =>
|
|
340
|
-
var _a2;
|
|
341
|
-
return expected.mock_tool_output !== void 0 && tool.name === expected.tool_name && deepEqual(args, (_a2 = expected.tool_input) != null ? _a2 : {});
|
|
342
|
-
}
|
|
373
|
+
(expected) => tool.name === expected.toolName && deepEqual(args, expected.toolInput)
|
|
343
374
|
);
|
|
344
375
|
if (idx !== -1) {
|
|
345
376
|
const [matched] = pendingMockToolUses.splice(idx, 1);
|
|
346
|
-
return
|
|
377
|
+
return matched.response;
|
|
347
378
|
}
|
|
348
379
|
return void 0;
|
|
349
380
|
}, "interceptor");
|
|
@@ -387,27 +418,97 @@ async function generateActualInvocations(rootAgent, evalCase, resetFunc, session
|
|
|
387
418
|
reference: ""
|
|
388
419
|
});
|
|
389
420
|
}
|
|
390
|
-
return { actualInvocations, sessionId, userId };
|
|
421
|
+
return { actualInvocations, sessionId, userId, recordedSession };
|
|
391
422
|
}
|
|
392
423
|
__name(generateActualInvocations, "generateActualInvocations");
|
|
424
|
+
function evalCaseToEvalEntry(evalCase) {
|
|
425
|
+
if (isEvalEntry(evalCase)) {
|
|
426
|
+
return evalCase;
|
|
427
|
+
}
|
|
428
|
+
const structured = evalCase;
|
|
429
|
+
const data = structured.conversation.map((invocation) => {
|
|
430
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
431
|
+
const query = (_c = (_b = (_a = invocation.userContent) == null ? void 0 : _a.parts) == null ? void 0 : _b.map((p) => {
|
|
432
|
+
var _a2;
|
|
433
|
+
return (_a2 = p.text) != null ? _a2 : "";
|
|
434
|
+
}).join("")) != null ? _c : "";
|
|
435
|
+
const reference = (_f = (_e = (_d = invocation.finalResponse) == null ? void 0 : _d.parts) == null ? void 0 : _e.map((p) => {
|
|
436
|
+
var _a2;
|
|
437
|
+
return (_a2 = p.text) != null ? _a2 : "";
|
|
438
|
+
}).join("")) != null ? _f : "";
|
|
439
|
+
const toolResponsesById = /* @__PURE__ */ new Map();
|
|
440
|
+
for (const toolResponse of (_h = (_g = invocation.intermediateData) == null ? void 0 : _g.toolResponses) != null ? _h : []) {
|
|
441
|
+
if (toolResponse.id) {
|
|
442
|
+
toolResponsesById.set(toolResponse.id, toolResponse);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
const expected_tool_use = ((_j = (_i = invocation.intermediateData) == null ? void 0 : _i.toolUses) != null ? _j : []).map((fc) => {
|
|
446
|
+
var _a2, _b2;
|
|
447
|
+
const toolUse = {
|
|
448
|
+
tool_name: (_a2 = fc.name) != null ? _a2 : "",
|
|
449
|
+
tool_input: (_b2 = fc.args) != null ? _b2 : {}
|
|
450
|
+
};
|
|
451
|
+
const toolResponse = fc.id ? toolResponsesById.get(fc.id) : void 0;
|
|
452
|
+
if ((toolResponse == null ? void 0 : toolResponse.response) !== void 0) {
|
|
453
|
+
declaredToolResponses.set(toolUse, toolResponse.response);
|
|
454
|
+
}
|
|
455
|
+
return toolUse;
|
|
456
|
+
});
|
|
457
|
+
const expected_intermediate_agent_responses = ((_l = (_k = invocation.intermediateData) == null ? void 0 : _k.intermediateResponses) != null ? _l : []).map(
|
|
458
|
+
([author, parts]) => [author, parts]
|
|
459
|
+
);
|
|
460
|
+
return {
|
|
461
|
+
query,
|
|
462
|
+
expected_tool_use,
|
|
463
|
+
expected_intermediate_agent_responses,
|
|
464
|
+
reference
|
|
465
|
+
};
|
|
466
|
+
});
|
|
467
|
+
const sessionInput = structured.sessionInput;
|
|
468
|
+
return {
|
|
469
|
+
name: structured.evalId,
|
|
470
|
+
data,
|
|
471
|
+
...sessionInput ? {
|
|
472
|
+
initial_session: {
|
|
473
|
+
...sessionInput.appName ? { app_name: sessionInput.appName } : {},
|
|
474
|
+
...sessionInput.userId ? { user_id: sessionInput.userId } : {},
|
|
475
|
+
state: sessionInput.state
|
|
476
|
+
}
|
|
477
|
+
} : {}
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
__name(evalCaseToEvalEntry, "evalCaseToEvalEntry");
|
|
393
481
|
function resolveEvalCasesForSet(evalSetId, entries) {
|
|
394
482
|
if (entries.length > 0 && typeof entries[0] === "string") {
|
|
395
483
|
const filterNames = entries;
|
|
396
|
-
const
|
|
484
|
+
const rawFileData = JSON.parse(
|
|
397
485
|
fs.readFileSync(evalSetId, "utf-8")
|
|
398
486
|
);
|
|
399
|
-
|
|
487
|
+
if (Array.isArray(rawFileData)) {
|
|
488
|
+
return rawFileData.filter(
|
|
489
|
+
(e) => filterNames.includes(e.name)
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
const loadedSet = loadEvalSetFromFile(evalSetId, evalSetId);
|
|
493
|
+
return loadedSet.evalCases.filter((e) => filterNames.includes(e.evalId)).map(evalCaseToEvalEntry);
|
|
400
494
|
}
|
|
401
495
|
if (entries.length === 0 && fs.existsSync(evalSetId) && fs.statSync(evalSetId).isFile()) {
|
|
402
|
-
|
|
496
|
+
const rawFileData = JSON.parse(
|
|
497
|
+
fs.readFileSync(evalSetId, "utf-8")
|
|
498
|
+
);
|
|
499
|
+
if (Array.isArray(rawFileData)) {
|
|
500
|
+
return rawFileData;
|
|
501
|
+
}
|
|
502
|
+
const loadedSet = loadEvalSetFromFile(evalSetId, evalSetId);
|
|
503
|
+
return loadedSet.evalCases.map(evalCaseToEvalEntry);
|
|
403
504
|
}
|
|
404
|
-
return entries;
|
|
505
|
+
return entries.map(evalCaseToEvalEntry);
|
|
405
506
|
}
|
|
406
507
|
__name(resolveEvalCasesForSet, "resolveEvalCasesForSet");
|
|
407
508
|
function printCaseDetailedResults(result) {
|
|
408
509
|
var _a;
|
|
409
510
|
import_logger.logger.info(
|
|
410
|
-
`Eval result for ${result.
|
|
511
|
+
`Eval result for ${result.eval_set_id}:${result.eval_id}: ${EvalStatus[result.final_eval_status]}`
|
|
411
512
|
);
|
|
412
513
|
for (const metricResult of result.overall_eval_metric_results) {
|
|
413
514
|
import_logger.logger.info(
|
|
@@ -456,7 +557,7 @@ async function* runEvals(optionsOrMap, rootAgentArg, resetFuncArg, evalMetricsAr
|
|
|
456
557
|
const evalCases = resolveEvalCasesForSet(evalSetId, rawEntries);
|
|
457
558
|
for (const evalCase of evalCases) {
|
|
458
559
|
const evalName = evalCase.name;
|
|
459
|
-
const { actualInvocations, sessionId, userId } = await generateActualInvocations(
|
|
560
|
+
const { actualInvocations, sessionId, userId, recordedSession } = await generateActualInvocations(
|
|
460
561
|
rootAgent,
|
|
461
562
|
evalCase,
|
|
462
563
|
resetFunc,
|
|
@@ -499,12 +600,14 @@ async function* runEvals(optionsOrMap, rootAgentArg, resetFuncArg, evalMetricsAr
|
|
|
499
600
|
}
|
|
500
601
|
const result = {
|
|
501
602
|
eval_set_file: evalSetId,
|
|
603
|
+
eval_set_id: evalSetId,
|
|
502
604
|
eval_id: evalName,
|
|
503
605
|
final_eval_status: finalEvalStatus,
|
|
504
606
|
eval_metric_results: evalMetricResultsPairs,
|
|
505
607
|
overall_eval_metric_results: overallEvalMetricResults,
|
|
506
608
|
eval_metric_result_per_invocation: perInvocationMap,
|
|
507
609
|
session_id: sessionId,
|
|
610
|
+
session_details: recordedSession && (0, import_internal_metadata.publicSession)(recordedSession),
|
|
508
611
|
user_id: userId
|
|
509
612
|
};
|
|
510
613
|
if (printDetailedResults) {
|
|
@@ -515,18 +618,782 @@ async function* runEvals(optionsOrMap, rootAgentArg, resetFuncArg, evalMetricsAr
|
|
|
515
618
|
}
|
|
516
619
|
}
|
|
517
620
|
__name(runEvals, "runEvals");
|
|
621
|
+
const ADK_EVAL_HISTORY_DIR = ".adk/eval_history";
|
|
622
|
+
const EVAL_SET_RESULT_FILE_EXTENSION = ".evalset_result.json";
|
|
623
|
+
function sanitizeEvalSetResultName(evalSetResultName) {
|
|
624
|
+
return evalSetResultName.replace(/\//g, "_");
|
|
625
|
+
}
|
|
626
|
+
__name(sanitizeEvalSetResultName, "sanitizeEvalSetResultName");
|
|
627
|
+
function toRunEvalResult(caseResult, fallbackEvalSetId) {
|
|
628
|
+
const record = caseResult;
|
|
629
|
+
const evalSetFile = typeof record.evalSetFile === "string" ? record.evalSetFile : typeof record.eval_set_file === "string" ? record.eval_set_file : void 0;
|
|
630
|
+
const evalSetId = typeof record.evalSetId === "string" ? record.evalSetId : typeof record.eval_set_id === "string" ? record.eval_set_id : fallbackEvalSetId != null ? fallbackEvalSetId : "";
|
|
631
|
+
const evalId = typeof record.evalId === "string" ? record.evalId : typeof record.eval_id === "string" ? record.eval_id : "";
|
|
632
|
+
const finalEvalStatus = typeof record.finalEvalStatus === "number" ? record.finalEvalStatus : typeof record.final_eval_status === "number" ? record.final_eval_status : 3 /* NOT_EVALUATED */;
|
|
633
|
+
const evalMetricResults = Array.isArray(record.evalMetricResults) ? record.evalMetricResults : Array.isArray(record.eval_metric_results) ? record.eval_metric_results : void 0;
|
|
634
|
+
const overallEvalMetricResults = Array.isArray(
|
|
635
|
+
record.overallEvalMetricResults
|
|
636
|
+
) ? record.overallEvalMetricResults : Array.isArray(record.overall_eval_metric_results) ? record.overall_eval_metric_results : [];
|
|
637
|
+
const evalMetricResultPerInvocation = Array.isArray(
|
|
638
|
+
record.evalMetricResultPerInvocation
|
|
639
|
+
) ? record.evalMetricResultPerInvocation : Array.isArray(record.eval_metric_result_per_invocation) ? record.eval_metric_result_per_invocation : [];
|
|
640
|
+
const sessionId = typeof record.sessionId === "string" ? record.sessionId : typeof record.session_id === "string" ? record.session_id : "";
|
|
641
|
+
const rawSessionDetails = record.sessionDetails !== void 0 && record.sessionDetails !== null ? record.sessionDetails : record.session_details !== void 0 && record.session_details !== null ? record.session_details : void 0;
|
|
642
|
+
const sessionDetails = rawSessionDetails && (0, import_internal_metadata.publicSession)(rawSessionDetails);
|
|
643
|
+
const userId = typeof record.userId === "string" ? record.userId : typeof record.user_id === "string" ? record.user_id : void 0;
|
|
644
|
+
return {
|
|
645
|
+
...evalSetFile !== void 0 ? { evalSetFile } : {},
|
|
646
|
+
evalSetId,
|
|
647
|
+
evalId,
|
|
648
|
+
finalEvalStatus,
|
|
649
|
+
...evalMetricResults !== void 0 ? { evalMetricResults } : {},
|
|
650
|
+
overallEvalMetricResults,
|
|
651
|
+
evalMetricResultPerInvocation,
|
|
652
|
+
sessionId,
|
|
653
|
+
...sessionDetails !== void 0 ? { sessionDetails } : {},
|
|
654
|
+
...userId !== void 0 ? { userId } : {}
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
__name(toRunEvalResult, "toRunEvalResult");
|
|
658
|
+
function createEvalSetResult({
|
|
659
|
+
appName,
|
|
660
|
+
evalSetId,
|
|
661
|
+
evalCaseResults,
|
|
662
|
+
creationTimestamp = (performance.timeOrigin + performance.now()) / 1e3
|
|
663
|
+
}) {
|
|
664
|
+
const evalSetResultId = `${appName}_${evalSetId}_${creationTimestamp}`;
|
|
665
|
+
const evalSetResultName = sanitizeEvalSetResultName(evalSetResultId);
|
|
666
|
+
return {
|
|
667
|
+
evalSetResultId,
|
|
668
|
+
evalSetResultName,
|
|
669
|
+
evalSetId,
|
|
670
|
+
evalCaseResults: evalCaseResults.map(
|
|
671
|
+
(caseResult) => toRunEvalResult(caseResult, evalSetId)
|
|
672
|
+
),
|
|
673
|
+
creationTimestamp
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
__name(createEvalSetResult, "createEvalSetResult");
|
|
677
|
+
function parseEvalSetResultJson(evalSetResultJson) {
|
|
678
|
+
var _a, _b;
|
|
679
|
+
const decoded = JSON.parse(evalSetResultJson);
|
|
680
|
+
const target = typeof decoded === "string" ? JSON.parse(decoded) : decoded;
|
|
681
|
+
if (typeof target !== "object" || target === null || Array.isArray(target)) {
|
|
682
|
+
throw new Error("Invalid EvalSetResult JSON: expected an object.");
|
|
683
|
+
}
|
|
684
|
+
const record = target;
|
|
685
|
+
const evalSetResultId = typeof record.evalSetResultId === "string" ? record.evalSetResultId : typeof record.eval_set_result_id === "string" ? record.eval_set_result_id : void 0;
|
|
686
|
+
const evalSetId = typeof record.evalSetId === "string" ? record.evalSetId : typeof record.eval_set_id === "string" ? record.eval_set_id : void 0;
|
|
687
|
+
if (!evalSetResultId || !evalSetId) {
|
|
688
|
+
throw new Error(
|
|
689
|
+
"Invalid EvalSetResult JSON: missing evalSetResultId or evalSetId."
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
const evalSetResultName = typeof record.evalSetResultName === "string" ? record.evalSetResultName : typeof record.eval_set_result_name === "string" ? record.eval_set_result_name : sanitizeEvalSetResultName(evalSetResultId);
|
|
693
|
+
const rawCases = (_b = (_a = record.evalCaseResults) != null ? _a : record.eval_case_results) != null ? _b : [];
|
|
694
|
+
if (!Array.isArray(rawCases)) {
|
|
695
|
+
throw new Error(
|
|
696
|
+
"Invalid EvalSetResult JSON: evalCaseResults must be an array."
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
const evalCaseResults = rawCases.map((rawCase) => {
|
|
700
|
+
if (typeof rawCase !== "object" || rawCase === null || Array.isArray(rawCase)) {
|
|
701
|
+
throw new Error(
|
|
702
|
+
"Invalid EvalSetResult JSON: each evalCaseResult must be an object."
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
return toRunEvalResult(rawCase, evalSetId);
|
|
706
|
+
});
|
|
707
|
+
const creationTimestamp = typeof record.creationTimestamp === "number" ? record.creationTimestamp : typeof record.creation_timestamp === "number" ? record.creation_timestamp : 0;
|
|
708
|
+
return {
|
|
709
|
+
evalSetResultId,
|
|
710
|
+
evalSetResultName,
|
|
711
|
+
evalSetId,
|
|
712
|
+
evalCaseResults,
|
|
713
|
+
creationTimestamp
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
__name(parseEvalSetResultJson, "parseEvalSetResultJson");
|
|
717
|
+
const _LocalEvalSetResultsManager = class _LocalEvalSetResultsManager {
|
|
718
|
+
constructor(agentsDir) {
|
|
719
|
+
this.agentsDir = agentsDir;
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Creates and saves a new {@link EvalSetResult} for `evalCaseResults`.
|
|
723
|
+
*/
|
|
724
|
+
saveEvalSetResult({
|
|
725
|
+
appName,
|
|
726
|
+
evalSetId,
|
|
727
|
+
evalCaseResults
|
|
728
|
+
}) {
|
|
729
|
+
(0, import_path_validation.validatePathSegment)(appName, "appName");
|
|
730
|
+
(0, import_path_validation.validatePathSegment)(evalSetId, "evalSetId");
|
|
731
|
+
const evalSetResult = createEvalSetResult({
|
|
732
|
+
appName,
|
|
733
|
+
evalSetId,
|
|
734
|
+
evalCaseResults
|
|
735
|
+
});
|
|
736
|
+
const appEvalHistoryDir = this.getEvalHistoryDir(appName);
|
|
737
|
+
if (!fs.existsSync(appEvalHistoryDir)) {
|
|
738
|
+
fs.mkdirSync(appEvalHistoryDir, { recursive: true });
|
|
739
|
+
}
|
|
740
|
+
const evalSetResultFilePath = path.join(
|
|
741
|
+
appEvalHistoryDir,
|
|
742
|
+
`${evalSetResult.evalSetResultName}${EVAL_SET_RESULT_FILE_EXTENSION}`
|
|
743
|
+
);
|
|
744
|
+
import_logger.logger.info(`Writing eval result to file: ${evalSetResultFilePath}`);
|
|
745
|
+
fs.writeFileSync(
|
|
746
|
+
evalSetResultFilePath,
|
|
747
|
+
JSON.stringify(evalSetResult, null, 2),
|
|
748
|
+
"utf-8"
|
|
749
|
+
);
|
|
750
|
+
return evalSetResult;
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Loads an {@link EvalSetResult} by `appName` and `evalSetResultId`.
|
|
754
|
+
*
|
|
755
|
+
* @throws {NotFoundError} If the result file does not exist.
|
|
756
|
+
*/
|
|
757
|
+
getEvalSetResult(appName, evalSetResultId) {
|
|
758
|
+
const appEvalHistoryDir = this.getEvalHistoryDir(appName);
|
|
759
|
+
(0, import_path_validation.validatePathSegment)(evalSetResultId, "evalSetResultId");
|
|
760
|
+
const filePath = path.resolve(
|
|
761
|
+
appEvalHistoryDir,
|
|
762
|
+
`${evalSetResultId}${EVAL_SET_RESULT_FILE_EXTENSION}`
|
|
763
|
+
);
|
|
764
|
+
if (!(0, import_path_validation.isStrictlyInside)(appEvalHistoryDir, filePath)) {
|
|
765
|
+
throw new import_input_validation_error.InputValidationError(
|
|
766
|
+
`evalSetResultId '${evalSetResultId}' resolves outside the eval history directory.`
|
|
767
|
+
);
|
|
768
|
+
}
|
|
769
|
+
if (!fs.existsSync(filePath)) {
|
|
770
|
+
throw new import_not_found_error.NotFoundError(
|
|
771
|
+
`Eval set result \`${evalSetResultId}\` not found.`
|
|
772
|
+
);
|
|
773
|
+
}
|
|
774
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
775
|
+
return parseEvalSetResultJson(content);
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Lists all saved eval set result IDs for `appName`.
|
|
779
|
+
*/
|
|
780
|
+
listEvalSetResults(appName) {
|
|
781
|
+
const appEvalHistoryDir = this.getEvalHistoryDir(appName);
|
|
782
|
+
if (!fs.existsSync(appEvalHistoryDir)) {
|
|
783
|
+
return [];
|
|
784
|
+
}
|
|
785
|
+
return fs.readdirSync(appEvalHistoryDir).filter((file) => file.endsWith(EVAL_SET_RESULT_FILE_EXTENSION)).map((file) => file.slice(0, -EVAL_SET_RESULT_FILE_EXTENSION.length));
|
|
786
|
+
}
|
|
787
|
+
getEvalHistoryDir(appName) {
|
|
788
|
+
(0, import_path_validation.validatePathSegment)(appName, "appName");
|
|
789
|
+
const baseDir = path.resolve(this.agentsDir);
|
|
790
|
+
const appDir = path.resolve(baseDir, appName);
|
|
791
|
+
if (!(0, import_path_validation.isStrictlyInside)(baseDir, appDir)) {
|
|
792
|
+
throw new import_input_validation_error.InputValidationError(
|
|
793
|
+
`appName '${appName}' resolves outside agentsDir.`
|
|
794
|
+
);
|
|
795
|
+
}
|
|
796
|
+
return path.join(appDir, ADK_EVAL_HISTORY_DIR);
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
__name(_LocalEvalSetResultsManager, "LocalEvalSetResultsManager");
|
|
800
|
+
let LocalEvalSetResultsManager = _LocalEvalSetResultsManager;
|
|
801
|
+
const EVAL_SET_FILE_EXTENSION = ".evalset.json";
|
|
802
|
+
const VALID_EVAL_ID_PATTERN = /^[a-zA-Z0-9_]+$/;
|
|
803
|
+
function validateEvalId(idName, idValue) {
|
|
804
|
+
if (!VALID_EVAL_ID_PATTERN.test(idValue)) {
|
|
805
|
+
const formattedName = idName.length > 0 ? idName[0].toUpperCase() + idName.slice(1) : idName;
|
|
806
|
+
throw new import_input_validation_error.InputValidationError(
|
|
807
|
+
`Invalid ${idName}. ${formattedName} should have the \`${VALID_EVAL_ID_PATTERN.source}\` format`
|
|
808
|
+
);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
__name(validateEvalId, "validateEvalId");
|
|
812
|
+
function readCreationTimestamp(record) {
|
|
813
|
+
if (typeof record.creationTimestamp === "number") {
|
|
814
|
+
return record.creationTimestamp;
|
|
815
|
+
}
|
|
816
|
+
if (typeof record.creation_timestamp === "number") {
|
|
817
|
+
return record.creation_timestamp;
|
|
818
|
+
}
|
|
819
|
+
return void 0;
|
|
820
|
+
}
|
|
821
|
+
__name(readCreationTimestamp, "readCreationTimestamp");
|
|
822
|
+
function normalizeContent(raw, defaultRole) {
|
|
823
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
824
|
+
throw new import_input_validation_error.InputValidationError("Invalid Content: expected an object.");
|
|
825
|
+
}
|
|
826
|
+
const record = raw;
|
|
827
|
+
if (record.parts !== void 0 && !Array.isArray(record.parts)) {
|
|
828
|
+
throw new import_input_validation_error.InputValidationError(
|
|
829
|
+
"Invalid Content: parts must be an array when provided."
|
|
830
|
+
);
|
|
831
|
+
}
|
|
832
|
+
const parts = Array.isArray(record.parts) ? record.parts : [];
|
|
833
|
+
const role = typeof record.role === "string" ? record.role : defaultRole !== void 0 ? defaultRole : void 0;
|
|
834
|
+
return {
|
|
835
|
+
parts,
|
|
836
|
+
...role !== void 0 ? { role } : {}
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
__name(normalizeContent, "normalizeContent");
|
|
840
|
+
function normalizeIntermediateData(raw) {
|
|
841
|
+
var _a, _b, _c, _d, _e, _f;
|
|
842
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
843
|
+
throw new import_input_validation_error.InputValidationError(
|
|
844
|
+
"Invalid EvalIntermediateData: expected an object."
|
|
845
|
+
);
|
|
846
|
+
}
|
|
847
|
+
const record = raw;
|
|
848
|
+
const rawToolUses = (_b = (_a = record.toolUses) != null ? _a : record.tool_uses) != null ? _b : [];
|
|
849
|
+
if (!Array.isArray(rawToolUses)) {
|
|
850
|
+
throw new import_input_validation_error.InputValidationError(
|
|
851
|
+
"Invalid EvalIntermediateData: toolUses must be an array."
|
|
852
|
+
);
|
|
853
|
+
}
|
|
854
|
+
const toolUses = rawToolUses.map((tu) => {
|
|
855
|
+
if (typeof tu !== "object" || tu === null || Array.isArray(tu)) {
|
|
856
|
+
throw new import_input_validation_error.InputValidationError(
|
|
857
|
+
"Invalid FunctionCall in toolUses: expected an object."
|
|
858
|
+
);
|
|
859
|
+
}
|
|
860
|
+
const fc = tu;
|
|
861
|
+
if (fc.name !== void 0 && typeof fc.name !== "string") {
|
|
862
|
+
throw new import_input_validation_error.InputValidationError(
|
|
863
|
+
"Invalid FunctionCall: name must be a string."
|
|
864
|
+
);
|
|
865
|
+
}
|
|
866
|
+
if (fc.args !== void 0 && (typeof fc.args !== "object" || fc.args === null || Array.isArray(fc.args))) {
|
|
867
|
+
throw new import_input_validation_error.InputValidationError(
|
|
868
|
+
"Invalid FunctionCall: args must be an object."
|
|
869
|
+
);
|
|
870
|
+
}
|
|
871
|
+
return {
|
|
872
|
+
...typeof fc.id === "string" ? { id: fc.id } : {},
|
|
873
|
+
...typeof fc.name === "string" ? { name: fc.name } : {},
|
|
874
|
+
...fc.args !== void 0 ? { args: fc.args } : {}
|
|
875
|
+
};
|
|
876
|
+
});
|
|
877
|
+
const rawToolResponses = (_d = (_c = record.toolResponses) != null ? _c : record.tool_responses) != null ? _d : [];
|
|
878
|
+
if (!Array.isArray(rawToolResponses)) {
|
|
879
|
+
throw new import_input_validation_error.InputValidationError(
|
|
880
|
+
"Invalid EvalIntermediateData: toolResponses must be an array."
|
|
881
|
+
);
|
|
882
|
+
}
|
|
883
|
+
const toolResponses = rawToolResponses.map((tr) => {
|
|
884
|
+
if (typeof tr !== "object" || tr === null || Array.isArray(tr)) {
|
|
885
|
+
throw new import_input_validation_error.InputValidationError(
|
|
886
|
+
"Invalid FunctionResponse in toolResponses: expected an object."
|
|
887
|
+
);
|
|
888
|
+
}
|
|
889
|
+
const fr = tr;
|
|
890
|
+
if (fr.id !== void 0 && typeof fr.id !== "string") {
|
|
891
|
+
throw new import_input_validation_error.InputValidationError(
|
|
892
|
+
"Invalid FunctionResponse: id must be a string."
|
|
893
|
+
);
|
|
894
|
+
}
|
|
895
|
+
if (fr.name !== void 0 && typeof fr.name !== "string") {
|
|
896
|
+
throw new import_input_validation_error.InputValidationError(
|
|
897
|
+
"Invalid FunctionResponse: name must be a string."
|
|
898
|
+
);
|
|
899
|
+
}
|
|
900
|
+
if (fr.response !== void 0 && (typeof fr.response !== "object" || fr.response === null || Array.isArray(fr.response))) {
|
|
901
|
+
throw new import_input_validation_error.InputValidationError(
|
|
902
|
+
"Invalid FunctionResponse: response must be an object."
|
|
903
|
+
);
|
|
904
|
+
}
|
|
905
|
+
return {
|
|
906
|
+
...typeof fr.id === "string" ? { id: fr.id } : {},
|
|
907
|
+
...typeof fr.name === "string" ? { name: fr.name } : {},
|
|
908
|
+
...fr.response !== void 0 ? { response: fr.response } : {}
|
|
909
|
+
};
|
|
910
|
+
});
|
|
911
|
+
const rawIntermediate = (_f = (_e = record.intermediateResponses) != null ? _e : record.intermediate_responses) != null ? _f : [];
|
|
912
|
+
if (!Array.isArray(rawIntermediate)) {
|
|
913
|
+
throw new import_input_validation_error.InputValidationError(
|
|
914
|
+
"Invalid EvalIntermediateData: intermediateResponses must be an array."
|
|
915
|
+
);
|
|
916
|
+
}
|
|
917
|
+
const intermediateResponses = rawIntermediate.map((entry) => {
|
|
918
|
+
if (!Array.isArray(entry) || entry.length !== 2 || typeof entry[0] !== "string" || !Array.isArray(entry[1])) {
|
|
919
|
+
throw new import_input_validation_error.InputValidationError(
|
|
920
|
+
"Invalid intermediateResponses entry: expected [author, Part[]]."
|
|
921
|
+
);
|
|
922
|
+
}
|
|
923
|
+
return [entry[0], entry[1]];
|
|
924
|
+
});
|
|
925
|
+
return {
|
|
926
|
+
toolUses,
|
|
927
|
+
...toolResponses.length > 0 ? { toolResponses } : {},
|
|
928
|
+
intermediateResponses
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
__name(normalizeIntermediateData, "normalizeIntermediateData");
|
|
932
|
+
function normalizeInvocation(raw) {
|
|
933
|
+
var _a, _b, _c;
|
|
934
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
935
|
+
throw new import_input_validation_error.InputValidationError(
|
|
936
|
+
"Invalid EvalInvocation: expected an object."
|
|
937
|
+
);
|
|
938
|
+
}
|
|
939
|
+
const record = raw;
|
|
940
|
+
const rawUserContent = (_a = record.userContent) != null ? _a : record.user_content;
|
|
941
|
+
if (rawUserContent === void 0) {
|
|
942
|
+
throw new import_input_validation_error.InputValidationError(
|
|
943
|
+
"Invalid EvalInvocation: userContent is required."
|
|
944
|
+
);
|
|
945
|
+
}
|
|
946
|
+
const userContent = normalizeContent(rawUserContent);
|
|
947
|
+
const rawFinalResponse = (_b = record.finalResponse) != null ? _b : record.final_response;
|
|
948
|
+
const finalResponse = rawFinalResponse !== void 0 && rawFinalResponse !== null ? normalizeContent(rawFinalResponse) : void 0;
|
|
949
|
+
const rawIntermediateData = (_c = record.intermediateData) != null ? _c : record.intermediate_data;
|
|
950
|
+
const intermediateData = rawIntermediateData !== void 0 && rawIntermediateData !== null ? normalizeIntermediateData(rawIntermediateData) : void 0;
|
|
951
|
+
const invocationId = typeof record.invocationId === "string" ? record.invocationId : typeof record.invocation_id === "string" ? record.invocation_id : void 0;
|
|
952
|
+
const creationTimestamp = readCreationTimestamp(record);
|
|
953
|
+
return {
|
|
954
|
+
...invocationId !== void 0 ? { invocationId } : {},
|
|
955
|
+
userContent,
|
|
956
|
+
...finalResponse !== void 0 ? { finalResponse } : {},
|
|
957
|
+
...intermediateData !== void 0 ? { intermediateData } : {},
|
|
958
|
+
...creationTimestamp !== void 0 ? { creationTimestamp } : {}
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
__name(normalizeInvocation, "normalizeInvocation");
|
|
962
|
+
function normalizeSessionInput(raw) {
|
|
963
|
+
var _a, _b, _c, _d, _e;
|
|
964
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
965
|
+
throw new import_input_validation_error.InputValidationError(
|
|
966
|
+
"Invalid EvalSessionInput: expected an object."
|
|
967
|
+
);
|
|
968
|
+
}
|
|
969
|
+
const record = raw;
|
|
970
|
+
const rawAppName = (_b = (_a = record.appName) != null ? _a : record.app_name) != null ? _b : "";
|
|
971
|
+
const rawUserId = (_d = (_c = record.userId) != null ? _c : record.user_id) != null ? _d : "";
|
|
972
|
+
const rawState = (_e = record.state) != null ? _e : {};
|
|
973
|
+
if (typeof rawAppName !== "string") {
|
|
974
|
+
throw new import_input_validation_error.InputValidationError(
|
|
975
|
+
"Invalid EvalSessionInput: appName must be a string."
|
|
976
|
+
);
|
|
977
|
+
}
|
|
978
|
+
if (typeof rawUserId !== "string") {
|
|
979
|
+
throw new import_input_validation_error.InputValidationError(
|
|
980
|
+
"Invalid EvalSessionInput: userId must be a string."
|
|
981
|
+
);
|
|
982
|
+
}
|
|
983
|
+
if (typeof rawState !== "object" || rawState === null || Array.isArray(rawState)) {
|
|
984
|
+
throw new import_input_validation_error.InputValidationError(
|
|
985
|
+
"Invalid EvalSessionInput: state must be an object."
|
|
986
|
+
);
|
|
987
|
+
}
|
|
988
|
+
return {
|
|
989
|
+
appName: rawAppName,
|
|
990
|
+
userId: rawUserId,
|
|
991
|
+
state: rawState
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
__name(normalizeSessionInput, "normalizeSessionInput");
|
|
995
|
+
function normalizeEvalCase(raw) {
|
|
996
|
+
var _a, _b;
|
|
997
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
998
|
+
throw new import_input_validation_error.InputValidationError("Invalid EvalCase: expected an object.");
|
|
999
|
+
}
|
|
1000
|
+
const record = raw;
|
|
1001
|
+
const rawEvalId = (_a = record.evalId) != null ? _a : record.eval_id;
|
|
1002
|
+
if (typeof rawEvalId !== "string") {
|
|
1003
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1004
|
+
"Invalid EvalCase: evalId must be a string."
|
|
1005
|
+
);
|
|
1006
|
+
}
|
|
1007
|
+
if (!Array.isArray(record.conversation)) {
|
|
1008
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1009
|
+
"Invalid EvalCase: conversation must be an array."
|
|
1010
|
+
);
|
|
1011
|
+
}
|
|
1012
|
+
const conversation = record.conversation.map(normalizeInvocation);
|
|
1013
|
+
const rawSessionInput = (_b = record.sessionInput) != null ? _b : record.session_input;
|
|
1014
|
+
const sessionInput = rawSessionInput !== void 0 && rawSessionInput !== null ? normalizeSessionInput(rawSessionInput) : void 0;
|
|
1015
|
+
const creationTimestamp = readCreationTimestamp(record);
|
|
1016
|
+
return {
|
|
1017
|
+
evalId: rawEvalId,
|
|
1018
|
+
conversation,
|
|
1019
|
+
...sessionInput !== void 0 ? { sessionInput } : {},
|
|
1020
|
+
...creationTimestamp !== void 0 ? { creationTimestamp } : {}
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
__name(normalizeEvalCase, "normalizeEvalCase");
|
|
1024
|
+
function convertLegacyInvocationToSchema(rawInvocation) {
|
|
1025
|
+
var _a, _b, _c;
|
|
1026
|
+
if (typeof rawInvocation !== "object" || rawInvocation === null || Array.isArray(rawInvocation)) {
|
|
1027
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1028
|
+
"Invalid legacy invocation: expected an object."
|
|
1029
|
+
);
|
|
1030
|
+
}
|
|
1031
|
+
const record = rawInvocation;
|
|
1032
|
+
if (typeof record.query !== "string") {
|
|
1033
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1034
|
+
"Invalid legacy invocation: query must be a string."
|
|
1035
|
+
);
|
|
1036
|
+
}
|
|
1037
|
+
const query = record.query;
|
|
1038
|
+
const rawReference = (_a = record.reference) != null ? _a : "";
|
|
1039
|
+
if (typeof rawReference !== "string") {
|
|
1040
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1041
|
+
"Invalid legacy invocation: reference must be a string."
|
|
1042
|
+
);
|
|
1043
|
+
}
|
|
1044
|
+
const rawExpectedToolUse = (_b = record.expected_tool_use) != null ? _b : [];
|
|
1045
|
+
if (!Array.isArray(rawExpectedToolUse)) {
|
|
1046
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1047
|
+
"Invalid legacy invocation: expected_tool_use must be an array."
|
|
1048
|
+
);
|
|
1049
|
+
}
|
|
1050
|
+
const toolResponses = [];
|
|
1051
|
+
const toolUses = rawExpectedToolUse.map((oldToolUse) => {
|
|
1052
|
+
var _a2;
|
|
1053
|
+
if (typeof oldToolUse !== "object" || oldToolUse === null || Array.isArray(oldToolUse)) {
|
|
1054
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1055
|
+
"Invalid legacy tool_use entry: expected an object."
|
|
1056
|
+
);
|
|
1057
|
+
}
|
|
1058
|
+
const tu = oldToolUse;
|
|
1059
|
+
if (typeof tu.tool_name !== "string") {
|
|
1060
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1061
|
+
"Invalid legacy tool_use: tool_name must be a string."
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
if (tu.tool_input !== void 0 && (typeof tu.tool_input !== "object" || tu.tool_input === null || Array.isArray(tu.tool_input))) {
|
|
1065
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1066
|
+
"Invalid legacy tool_use: tool_input must be an object."
|
|
1067
|
+
);
|
|
1068
|
+
}
|
|
1069
|
+
const toolUse = {
|
|
1070
|
+
name: tu.tool_name,
|
|
1071
|
+
args: (_a2 = tu.tool_input) != null ? _a2 : {}
|
|
1072
|
+
};
|
|
1073
|
+
if (tu.mock_tool_output !== void 0) {
|
|
1074
|
+
toolUse.id = (0, import_node_crypto.randomUUID)();
|
|
1075
|
+
toolResponses.push({
|
|
1076
|
+
id: toolUse.id,
|
|
1077
|
+
name: tu.tool_name,
|
|
1078
|
+
response: { [MOCK_TOOL_OUTPUT_RESPONSE_KEY]: tu.mock_tool_output }
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
return toolUse;
|
|
1082
|
+
});
|
|
1083
|
+
const rawExpectedIntermediate = (_c = record.expected_intermediate_agent_responses) != null ? _c : [];
|
|
1084
|
+
if (!Array.isArray(rawExpectedIntermediate)) {
|
|
1085
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1086
|
+
"Invalid legacy invocation: expected_intermediate_agent_responses must be an array."
|
|
1087
|
+
);
|
|
1088
|
+
}
|
|
1089
|
+
const intermediateResponses = rawExpectedIntermediate.map((oldIntermediate) => {
|
|
1090
|
+
if (Array.isArray(oldIntermediate)) {
|
|
1091
|
+
if (oldIntermediate.length !== 2 || typeof oldIntermediate[0] !== "string" || !Array.isArray(oldIntermediate[1])) {
|
|
1092
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1093
|
+
"Invalid legacy intermediate response tuple: expected [author, Part[]]."
|
|
1094
|
+
);
|
|
1095
|
+
}
|
|
1096
|
+
return [oldIntermediate[0], oldIntermediate[1]];
|
|
1097
|
+
}
|
|
1098
|
+
if (typeof oldIntermediate === "object" && oldIntermediate !== null) {
|
|
1099
|
+
const ir = oldIntermediate;
|
|
1100
|
+
if (typeof ir.author !== "string" || typeof ir.text !== "string") {
|
|
1101
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1102
|
+
"Invalid legacy intermediate response: author and text must be strings."
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
return [ir.author, [{ text: ir.text }]];
|
|
1106
|
+
}
|
|
1107
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1108
|
+
"Invalid legacy intermediate response: expected an object or tuple."
|
|
1109
|
+
);
|
|
1110
|
+
});
|
|
1111
|
+
return {
|
|
1112
|
+
invocationId: (0, import_node_crypto.randomUUID)(),
|
|
1113
|
+
userContent: {
|
|
1114
|
+
parts: [{ text: query }],
|
|
1115
|
+
role: "user"
|
|
1116
|
+
},
|
|
1117
|
+
finalResponse: {
|
|
1118
|
+
parts: [{ text: rawReference }],
|
|
1119
|
+
role: "model"
|
|
1120
|
+
},
|
|
1121
|
+
intermediateData: {
|
|
1122
|
+
toolUses,
|
|
1123
|
+
...toolResponses.length > 0 ? { toolResponses } : {},
|
|
1124
|
+
intermediateResponses
|
|
1125
|
+
},
|
|
1126
|
+
creationTimestamp: Date.now() / 1e3
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
__name(convertLegacyInvocationToSchema, "convertLegacyInvocationToSchema");
|
|
1130
|
+
function convertEvalSetToSchema(evalSetId, evalSetInJsonFormat) {
|
|
1131
|
+
if (!Array.isArray(evalSetInJsonFormat)) {
|
|
1132
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1133
|
+
"Invalid legacy eval set JSON: expected an array of eval entries."
|
|
1134
|
+
);
|
|
1135
|
+
}
|
|
1136
|
+
const evalCases = [];
|
|
1137
|
+
for (const rawEvalCase of evalSetInJsonFormat) {
|
|
1138
|
+
if (typeof rawEvalCase !== "object" || rawEvalCase === null || Array.isArray(rawEvalCase)) {
|
|
1139
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1140
|
+
"Invalid legacy eval case: expected an object."
|
|
1141
|
+
);
|
|
1142
|
+
}
|
|
1143
|
+
const oldEvalCase = rawEvalCase;
|
|
1144
|
+
if (typeof oldEvalCase.name !== "string") {
|
|
1145
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1146
|
+
"Invalid legacy eval case: name must be a string."
|
|
1147
|
+
);
|
|
1148
|
+
}
|
|
1149
|
+
if (!Array.isArray(oldEvalCase.data)) {
|
|
1150
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1151
|
+
"Invalid legacy eval case: data must be an array."
|
|
1152
|
+
);
|
|
1153
|
+
}
|
|
1154
|
+
const newInvocations = oldEvalCase.data.map(
|
|
1155
|
+
convertLegacyInvocationToSchema
|
|
1156
|
+
);
|
|
1157
|
+
let sessionInput;
|
|
1158
|
+
if (oldEvalCase.initial_session !== void 0 && oldEvalCase.initial_session !== null) {
|
|
1159
|
+
if (typeof oldEvalCase.initial_session !== "object" || Array.isArray(oldEvalCase.initial_session)) {
|
|
1160
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1161
|
+
"Invalid legacy eval case: initial_session must be an object."
|
|
1162
|
+
);
|
|
1163
|
+
}
|
|
1164
|
+
const initSess = oldEvalCase.initial_session;
|
|
1165
|
+
if (Object.keys(initSess).length > 0) {
|
|
1166
|
+
sessionInput = normalizeSessionInput(initSess);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
evalCases.push({
|
|
1170
|
+
evalId: oldEvalCase.name,
|
|
1171
|
+
conversation: newInvocations,
|
|
1172
|
+
...sessionInput !== void 0 ? { sessionInput } : {},
|
|
1173
|
+
creationTimestamp: Date.now() / 1e3
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
return {
|
|
1177
|
+
evalSetId,
|
|
1178
|
+
name: evalSetId,
|
|
1179
|
+
creationTimestamp: Date.now() / 1e3,
|
|
1180
|
+
evalCases
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
__name(convertEvalSetToSchema, "convertEvalSetToSchema");
|
|
1184
|
+
function parseEvalSetObject(raw) {
|
|
1185
|
+
var _a, _b;
|
|
1186
|
+
const rawEvalSetId = (_a = raw.evalSetId) != null ? _a : raw.eval_set_id;
|
|
1187
|
+
const rawEvalCases = (_b = raw.evalCases) != null ? _b : raw.eval_cases;
|
|
1188
|
+
if (typeof rawEvalSetId !== "string" || !Array.isArray(rawEvalCases)) {
|
|
1189
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1190
|
+
"Invalid EvalSet JSON: missing evalSetId or evalCases."
|
|
1191
|
+
);
|
|
1192
|
+
}
|
|
1193
|
+
const name = typeof raw.name === "string" ? raw.name : void 0;
|
|
1194
|
+
const description = typeof raw.description === "string" ? raw.description : void 0;
|
|
1195
|
+
const creationTimestamp = readCreationTimestamp(raw);
|
|
1196
|
+
return {
|
|
1197
|
+
evalSetId: rawEvalSetId,
|
|
1198
|
+
...name !== void 0 ? { name } : {},
|
|
1199
|
+
...description !== void 0 ? { description } : {},
|
|
1200
|
+
evalCases: rawEvalCases.map(normalizeEvalCase),
|
|
1201
|
+
...creationTimestamp !== void 0 ? { creationTimestamp } : {}
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
__name(parseEvalSetObject, "parseEvalSetObject");
|
|
1205
|
+
function loadEvalSetFromFile(evalSetFilePath, evalSetId) {
|
|
1206
|
+
const content = fs.readFileSync(evalSetFilePath, "utf-8");
|
|
1207
|
+
const parsed = JSON.parse(content);
|
|
1208
|
+
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) && ("evalSetId" in parsed || "eval_set_id" in parsed || "evalCases" in parsed || "eval_cases" in parsed)) {
|
|
1209
|
+
return parseEvalSetObject(parsed);
|
|
1210
|
+
}
|
|
1211
|
+
return convertEvalSetToSchema(evalSetId, parsed);
|
|
1212
|
+
}
|
|
1213
|
+
__name(loadEvalSetFromFile, "loadEvalSetFromFile");
|
|
1214
|
+
const _LocalEvalSetsManager = class _LocalEvalSetsManager {
|
|
1215
|
+
constructor(agentsDir) {
|
|
1216
|
+
this.agentsDir = agentsDir;
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Loads an {@link EvalSet} identified by `appName` and `evalSetId`, or
|
|
1220
|
+
* returns `undefined` if the file does not exist.
|
|
1221
|
+
*/
|
|
1222
|
+
getEvalSet(appName, evalSetId) {
|
|
1223
|
+
const evalSetFilePath = this.getEvalSetFilePath(appName, evalSetId);
|
|
1224
|
+
if (!fs.existsSync(evalSetFilePath)) {
|
|
1225
|
+
return void 0;
|
|
1226
|
+
}
|
|
1227
|
+
return loadEvalSetFromFile(evalSetFilePath, evalSetId);
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Creates an empty {@link EvalSet} file for `appName` and `evalSetId`.
|
|
1231
|
+
*
|
|
1232
|
+
* @throws {InputValidationError} If `evalSetId` is invalid or the eval set
|
|
1233
|
+
* already exists.
|
|
1234
|
+
*/
|
|
1235
|
+
createEvalSet(appName, evalSetId) {
|
|
1236
|
+
validateEvalId("eval set ID", evalSetId);
|
|
1237
|
+
const newEvalSetPath = this.getEvalSetFilePath(appName, evalSetId);
|
|
1238
|
+
if (fs.existsSync(newEvalSetPath)) {
|
|
1239
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1240
|
+
`EvalSet ${evalSetId} already exists for app ${appName}.`
|
|
1241
|
+
);
|
|
1242
|
+
}
|
|
1243
|
+
import_logger.logger.info(`Creating eval set file \`${newEvalSetPath}\``);
|
|
1244
|
+
const newEvalSet = {
|
|
1245
|
+
evalSetId,
|
|
1246
|
+
name: evalSetId,
|
|
1247
|
+
evalCases: [],
|
|
1248
|
+
creationTimestamp: Date.now() / 1e3
|
|
1249
|
+
};
|
|
1250
|
+
this.writeEvalSet(newEvalSetPath, newEvalSet);
|
|
1251
|
+
return newEvalSet;
|
|
1252
|
+
}
|
|
1253
|
+
/**
|
|
1254
|
+
* Lists all eval set IDs stored under `appName`, sorted alphabetically.
|
|
1255
|
+
*/
|
|
1256
|
+
listEvalSets(appName) {
|
|
1257
|
+
(0, import_path_validation.validatePathSegment)(appName, "appName");
|
|
1258
|
+
const baseDir = path.resolve(this.agentsDir);
|
|
1259
|
+
const appDir = path.resolve(baseDir, appName);
|
|
1260
|
+
if (!(0, import_path_validation.isStrictlyInside)(baseDir, appDir)) {
|
|
1261
|
+
throw new import_input_validation_error.InputValidationError(`Invalid appName '${appName}'.`);
|
|
1262
|
+
}
|
|
1263
|
+
if (!fs.existsSync(appDir)) {
|
|
1264
|
+
return [];
|
|
1265
|
+
}
|
|
1266
|
+
const evalSets = [];
|
|
1267
|
+
for (const file of fs.readdirSync(appDir)) {
|
|
1268
|
+
if (file.endsWith(EVAL_SET_FILE_EXTENSION)) {
|
|
1269
|
+
evalSets.push(file.slice(0, -EVAL_SET_FILE_EXTENSION.length));
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
return evalSets.sort();
|
|
1273
|
+
}
|
|
1274
|
+
/**
|
|
1275
|
+
* Adds `evalCase` to the {@link EvalSet} identified by `appName` and
|
|
1276
|
+
* `evalSetId`.
|
|
1277
|
+
*
|
|
1278
|
+
* @throws {NotFoundError} If the eval set does not exist.
|
|
1279
|
+
* @throws {InputValidationError} If `evalCase.evalId` is invalid or already exists.
|
|
1280
|
+
*/
|
|
1281
|
+
addEvalCase(appName, evalSetId, evalCase) {
|
|
1282
|
+
const normalizedCase = normalizeEvalCase(evalCase);
|
|
1283
|
+
const evalCaseId = normalizedCase.evalId;
|
|
1284
|
+
validateEvalId("Eval Case ID", evalCaseId);
|
|
1285
|
+
const evalSet = this.getEvalSet(appName, evalSetId);
|
|
1286
|
+
if (!evalSet) {
|
|
1287
|
+
throw new import_not_found_error.NotFoundError(`Eval set \`${evalSetId}\` not found.`);
|
|
1288
|
+
}
|
|
1289
|
+
if (evalSet.evalCases.some((x) => x.evalId === evalCaseId)) {
|
|
1290
|
+
throw new import_input_validation_error.InputValidationError(
|
|
1291
|
+
`Eval id \`${evalCaseId}\` already exists in \`${evalSetId}\` eval set.`
|
|
1292
|
+
);
|
|
1293
|
+
}
|
|
1294
|
+
evalSet.evalCases.push(normalizedCase);
|
|
1295
|
+
const evalSetFilePath = this.getEvalSetFilePath(appName, evalSetId);
|
|
1296
|
+
this.writeEvalSet(evalSetFilePath, evalSet);
|
|
1297
|
+
}
|
|
1298
|
+
/**
|
|
1299
|
+
* Returns a single {@link EvalCase} by `appName`, `evalSetId`, and
|
|
1300
|
+
* `evalCaseId`, or `undefined` if not found.
|
|
1301
|
+
*/
|
|
1302
|
+
getEvalCase(appName, evalSetId, evalCaseId) {
|
|
1303
|
+
const evalSet = this.getEvalSet(appName, evalSetId);
|
|
1304
|
+
if (!evalSet) {
|
|
1305
|
+
return void 0;
|
|
1306
|
+
}
|
|
1307
|
+
return evalSet.evalCases.find((c) => c.evalId === evalCaseId);
|
|
1308
|
+
}
|
|
1309
|
+
/**
|
|
1310
|
+
* Updates an existing {@link EvalCase} in the {@link EvalSet} identified by
|
|
1311
|
+
* `appName` and `evalSetId`.
|
|
1312
|
+
*
|
|
1313
|
+
* @throws {NotFoundError} If the eval set or eval case is not found.
|
|
1314
|
+
*/
|
|
1315
|
+
updateEvalCase(appName, evalSetId, updatedEvalCase) {
|
|
1316
|
+
const normalizedCase = normalizeEvalCase(updatedEvalCase);
|
|
1317
|
+
const evalCaseId = normalizedCase.evalId;
|
|
1318
|
+
const evalSet = this.getEvalSet(appName, evalSetId);
|
|
1319
|
+
if (!evalSet || !evalSet.evalCases.some((c) => c.evalId === evalCaseId)) {
|
|
1320
|
+
throw new import_not_found_error.NotFoundError(
|
|
1321
|
+
`Eval Set \`${evalSetId}\` or Eval id \`${evalCaseId}\` not found.`
|
|
1322
|
+
);
|
|
1323
|
+
}
|
|
1324
|
+
evalSet.evalCases = evalSet.evalCases.filter(
|
|
1325
|
+
(c) => c.evalId !== evalCaseId
|
|
1326
|
+
);
|
|
1327
|
+
evalSet.evalCases.push(normalizedCase);
|
|
1328
|
+
const evalSetFilePath = this.getEvalSetFilePath(appName, evalSetId);
|
|
1329
|
+
this.writeEvalSet(evalSetFilePath, evalSet);
|
|
1330
|
+
}
|
|
1331
|
+
/**
|
|
1332
|
+
* Deletes an {@link EvalCase} identified by `appName`, `evalSetId`, and
|
|
1333
|
+
* `evalCaseId`.
|
|
1334
|
+
*
|
|
1335
|
+
* @throws {NotFoundError} If the eval set or eval case to delete is not found.
|
|
1336
|
+
*/
|
|
1337
|
+
deleteEvalCase(appName, evalSetId, evalCaseId) {
|
|
1338
|
+
const evalSet = this.getEvalSet(appName, evalSetId);
|
|
1339
|
+
if (!evalSet || !evalSet.evalCases.some((c) => c.evalId === evalCaseId)) {
|
|
1340
|
+
throw new import_not_found_error.NotFoundError(
|
|
1341
|
+
`Eval Set \`${evalSetId}\` or Eval id \`${evalCaseId}\` not found.`
|
|
1342
|
+
);
|
|
1343
|
+
}
|
|
1344
|
+
import_logger.logger.info(
|
|
1345
|
+
`EvalCase \`${evalCaseId}\` was found in the eval set. It will be removed permanently.`
|
|
1346
|
+
);
|
|
1347
|
+
evalSet.evalCases = evalSet.evalCases.filter(
|
|
1348
|
+
(c) => c.evalId !== evalCaseId
|
|
1349
|
+
);
|
|
1350
|
+
const evalSetFilePath = this.getEvalSetFilePath(appName, evalSetId);
|
|
1351
|
+
this.writeEvalSet(evalSetFilePath, evalSet);
|
|
1352
|
+
}
|
|
1353
|
+
getEvalSetFilePath(appName, evalSetId) {
|
|
1354
|
+
(0, import_path_validation.validatePathSegment)(appName, "appName");
|
|
1355
|
+
(0, import_path_validation.validatePathSegment)(evalSetId, "evalSetId");
|
|
1356
|
+
validateEvalId("eval set ID", evalSetId);
|
|
1357
|
+
const baseDir = path.resolve(this.agentsDir);
|
|
1358
|
+
const appDir = path.resolve(baseDir, appName);
|
|
1359
|
+
if (!(0, import_path_validation.isStrictlyInside)(baseDir, appDir)) {
|
|
1360
|
+
throw new import_input_validation_error.InputValidationError(`Invalid appName '${appName}'.`);
|
|
1361
|
+
}
|
|
1362
|
+
const filePath = path.resolve(
|
|
1363
|
+
appDir,
|
|
1364
|
+
`${evalSetId}${EVAL_SET_FILE_EXTENSION}`
|
|
1365
|
+
);
|
|
1366
|
+
if (!(0, import_path_validation.isStrictlyInside)(appDir, filePath)) {
|
|
1367
|
+
throw new import_input_validation_error.InputValidationError(`Invalid evalSetId '${evalSetId}'.`);
|
|
1368
|
+
}
|
|
1369
|
+
return filePath;
|
|
1370
|
+
}
|
|
1371
|
+
writeEvalSet(evalSetPath, evalSet) {
|
|
1372
|
+
fs.mkdirSync(path.dirname(evalSetPath), { recursive: true });
|
|
1373
|
+
fs.writeFileSync(evalSetPath, JSON.stringify(evalSet, null, 2), "utf-8");
|
|
1374
|
+
}
|
|
1375
|
+
};
|
|
1376
|
+
__name(_LocalEvalSetsManager, "LocalEvalSetsManager");
|
|
1377
|
+
let LocalEvalSetsManager = _LocalEvalSetsManager;
|
|
518
1378
|
// Annotate the CommonJS export names for ESM import in node:
|
|
519
1379
|
0 && (module.exports = {
|
|
520
1380
|
DEFAULT_CRITERIA,
|
|
521
1381
|
EVAL_SESSION_ID_PREFIX,
|
|
522
1382
|
EvalStatus,
|
|
1383
|
+
LocalEvalSetResultsManager,
|
|
1384
|
+
LocalEvalSetsManager,
|
|
523
1385
|
MISSING_EVAL_DEPENDENCIES_MESSAGE,
|
|
524
1386
|
RESPONSE_EVALUATION_SCORE_KEY,
|
|
525
1387
|
RESPONSE_MATCH_SCORE_KEY,
|
|
526
1388
|
TOOL_TRAJECTORY_SCORE_KEY,
|
|
1389
|
+
convertEvalSetToSchema,
|
|
1390
|
+
createEvalSetResult,
|
|
527
1391
|
getEvaluationCriteriaOrDefault,
|
|
528
1392
|
getRootAgent,
|
|
1393
|
+
loadEvalSetFromFile,
|
|
1394
|
+
normalizeEvalCase,
|
|
529
1395
|
parseAndGetEvalsToRun,
|
|
1396
|
+
parseEvalSetResultJson,
|
|
530
1397
|
runEvals,
|
|
531
1398
|
tryGetResetFunc
|
|
532
1399
|
});
|