@google/adk 2.2.1 → 2.4.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 +4 -1
- package/dist/cjs/a2a/agent_card.js +102 -26
- package/dist/cjs/a2a/agent_to_a2a.js +1 -1
- package/dist/cjs/agents/agent_engine_client.js +172 -0
- package/dist/cjs/agents/base_agent.js +20 -4
- package/dist/cjs/agents/functions.js +227 -25
- package/dist/cjs/agents/instructions.js +6 -2
- package/dist/cjs/agents/invocation_context.js +26 -4
- package/dist/cjs/agents/langgraph_agent.js +152 -0
- package/dist/cjs/agents/llm_agent.js +194 -107
- package/dist/cjs/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/code_execution_request_processor.js +18 -6
- package/dist/cjs/agents/processors/content_processor_utils.js +38 -10
- package/dist/cjs/agents/processors/content_request_processor.js +34 -2
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/nl_planning_processor.js +12 -3
- package/dist/cjs/artifacts/in_memory_artifact_service.js +14 -0
- package/dist/cjs/auth/auth_handler.js +37 -5
- package/dist/cjs/auth/auth_schemes.js +9 -0
- package/dist/cjs/cli/cli_eval.js +532 -0
- package/dist/cjs/cli/utils/envs.js +116 -0
- package/dist/cjs/cli/utils/evals.js +137 -0
- package/dist/cjs/cli/utils/logs.js +150 -0
- package/dist/cjs/code_executors/agent_engine_sandbox_code_executor.js +7 -2
- package/dist/cjs/code_executors/code_execution_utils.js +48 -16
- package/dist/cjs/code_executors/code_executor_context.js +6 -2
- package/dist/cjs/code_executors/container_code_executor.js +27 -16
- package/dist/cjs/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/cjs/common.js +61 -0
- package/dist/cjs/context/summarizers/llm_summarizer.js +12 -10
- package/dist/cjs/context/token_based_context_compactor.js +2 -1
- package/dist/cjs/errors/input_validation_error.js +3 -2
- package/dist/cjs/events/event.js +4 -2
- package/dist/cjs/examples/example_util.js +23 -2
- package/dist/cjs/flows/llm_flows/audio_transcriber.js +170 -0
- package/dist/cjs/index.js +104 -1
- package/dist/cjs/integrations/agent_registry/helpers.js +1 -1
- package/dist/cjs/models/gemini_llm_connection.js +16 -8
- package/dist/cjs/models/google_llm.js +13 -16
- package/dist/cjs/models/llm_response.js +9 -1
- package/dist/cjs/models/registry.js +1 -1
- package/dist/cjs/models/routed_llm.js +9 -8
- package/dist/cjs/planners/plan_re_act_planner.js +1 -1
- package/dist/cjs/plugins/base_plugin.js +13 -23
- package/dist/cjs/runner/in_memory_runner.js +6 -11
- package/dist/cjs/runner/runner.js +105 -33
- package/dist/cjs/sessions/base_session_service.js +14 -8
- package/dist/cjs/sessions/database_session_service.js +50 -28
- package/dist/cjs/sessions/db/operations.js +1 -1
- package/dist/cjs/sessions/in_memory_session_service.js +3 -1
- package/dist/cjs/sessions/stale_session_error.js +59 -0
- package/dist/cjs/sessions/state.js +8 -4
- package/dist/cjs/sessions/vertex_ai_session_service.js +34 -15
- package/dist/cjs/skills/loader.js +52 -18
- package/dist/cjs/telemetry/setup.js +0 -1
- package/dist/cjs/telemetry/tracing.js +147 -73
- package/dist/cjs/tools/agent_tool.js +44 -0
- package/dist/cjs/tools/apihub_tool/apihub_toolset.js +137 -0
- package/dist/cjs/tools/apihub_tool/clients/apihub_client.js +272 -0
- package/dist/cjs/tools/apihub_tool/clients/secret_client.js +148 -0
- package/dist/cjs/tools/apihub_tool/clients/service_account.js +48 -0
- package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +263 -0
- package/dist/cjs/tools/application_integration_tool/clients/cloud_request.js +133 -0
- package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +671 -0
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +223 -0
- package/dist/cjs/tools/application_integration_tool/integration_connector_tool.js +184 -0
- package/dist/cjs/tools/example_tool.js +10 -0
- package/dist/cjs/tools/function_tool.js +319 -0
- package/dist/cjs/tools/google_api_tool/google_api_tool.js +100 -0
- package/dist/cjs/tools/google_api_tool/google_api_toolset.js +173 -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 +440 -0
- package/dist/cjs/tools/google_api_tool/index.js +61 -0
- package/dist/cjs/tools/load_artifacts_tool.js +12 -6
- package/dist/cjs/tools/load_memory_tool.js +12 -10
- package/dist/cjs/tools/mcp/index.js +12 -0
- package/dist/cjs/tools/mcp/mcp_session_manager.js +25 -0
- package/dist/cjs/tools/mcp/mcp_toolset.js +1 -14
- package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +1 -2
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +46 -2
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +4 -3
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
- 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_spec_parser/tool_auth_handler.js +14 -2
- package/dist/cjs/tools/openapi_tool/openapi_toolset.js +7 -13
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +17 -1
- package/dist/cjs/tools/retrieval/base_retrieval_tool.js +18 -3
- package/dist/cjs/tools/toolbox_toolset.js +174 -0
- package/dist/cjs/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/cjs/utils/client_labels.js +19 -2
- package/dist/cjs/utils/env_aware_utils.js +6 -8
- package/dist/cjs/utils/error_utils.js +11 -11
- package/dist/cjs/utils/failover_utils.js +1 -1
- package/dist/cjs/utils/file_extension_utils.js +11 -0
- package/dist/cjs/utils/file_utils.js +2 -24
- package/dist/cjs/utils/gemini_schema_util.js +28 -7
- package/dist/cjs/utils/json_utils.js +49 -0
- package/dist/cjs/utils/live_connection_utils.js +4 -5
- package/dist/cjs/utils/logger_node.js +11 -1
- package/dist/cjs/utils/object_notation_utils.js +6 -3
- package/dist/cjs/utils/output_schema_utils.js +5 -2
- package/dist/cjs/utils/streaming_utils.js +12 -12
- package/dist/cjs/utils/task.js +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/a2a/a2a_remote_agent.js +4 -1
- package/dist/esm/a2a/agent_card.js +103 -27
- package/dist/esm/a2a/agent_to_a2a.js +5 -2
- package/dist/esm/agents/agent_engine_client.js +144 -0
- package/dist/esm/agents/base_agent.js +20 -4
- package/dist/esm/agents/functions.js +226 -25
- package/dist/esm/agents/instructions.js +6 -2
- package/dist/esm/agents/invocation_context.js +24 -4
- package/dist/esm/agents/langgraph_agent.js +123 -0
- package/dist/esm/agents/llm_agent.js +204 -110
- package/dist/esm/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/code_execution_request_processor.js +21 -8
- package/dist/esm/agents/processors/content_processor_utils.js +38 -10
- package/dist/esm/agents/processors/content_request_processor.js +34 -2
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/nl_planning_processor.js +12 -3
- package/dist/esm/artifacts/in_memory_artifact_service.js +14 -0
- package/dist/esm/auth/auth_handler.js +37 -5
- package/dist/esm/auth/auth_schemes.js +8 -0
- package/dist/esm/cli/cli_eval.js +510 -0
- package/dist/esm/cli/utils/envs.js +78 -0
- package/dist/esm/cli/utils/evals.js +109 -0
- package/dist/esm/cli/utils/logs.js +111 -0
- package/dist/esm/code_executors/agent_engine_sandbox_code_executor.js +7 -2
- package/dist/esm/code_executors/code_execution_utils.js +46 -16
- package/dist/esm/code_executors/code_executor_context.js +5 -2
- package/dist/esm/code_executors/container_code_executor.js +27 -16
- package/dist/esm/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/esm/common.js +65 -4
- package/dist/esm/context/summarizers/llm_summarizer.js +12 -10
- package/dist/esm/context/token_based_context_compactor.js +2 -1
- package/dist/esm/errors/input_validation_error.js +3 -2
- package/dist/esm/events/event.js +4 -2
- package/dist/esm/examples/example_util.js +21 -1
- package/dist/esm/flows/llm_flows/audio_transcriber.js +142 -0
- package/dist/esm/index.js +114 -2
- package/dist/esm/integrations/agent_registry/helpers.js +1 -1
- package/dist/esm/models/gemini_llm_connection.js +16 -8
- package/dist/esm/models/google_llm.js +14 -17
- package/dist/esm/models/llm_response.js +9 -1
- package/dist/esm/models/registry.js +1 -1
- package/dist/esm/models/routed_llm.js +9 -8
- package/dist/esm/planners/plan_re_act_planner.js +1 -1
- package/dist/esm/plugins/base_plugin.js +13 -23
- package/dist/esm/runner/in_memory_runner.js +6 -11
- package/dist/esm/runner/runner.js +105 -33
- package/dist/esm/sessions/base_session_service.js +12 -7
- package/dist/esm/sessions/database_session_service.js +49 -28
- package/dist/esm/sessions/db/operations.js +1 -1
- package/dist/esm/sessions/in_memory_session_service.js +3 -1
- package/dist/esm/sessions/stale_session_error.js +31 -0
- package/dist/esm/sessions/state.js +8 -4
- package/dist/esm/sessions/vertex_ai_session_service.js +34 -15
- package/dist/esm/skills/loader.js +51 -17
- package/dist/esm/telemetry/setup.js +1 -2
- package/dist/esm/telemetry/tracing.js +151 -74
- package/dist/esm/tools/agent_tool.js +44 -0
- package/dist/esm/tools/apihub_tool/apihub_toolset.js +101 -0
- package/dist/esm/tools/apihub_tool/clients/apihub_client.js +244 -0
- package/dist/esm/tools/apihub_tool/clients/secret_client.js +132 -0
- package/dist/esm/tools/apihub_tool/clients/service_account.js +21 -0
- package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +245 -0
- package/dist/esm/tools/application_integration_tool/clients/cloud_request.js +103 -0
- package/dist/esm/tools/application_integration_tool/clients/connections_client.js +629 -0
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +219 -0
- package/dist/esm/tools/application_integration_tool/integration_connector_tool.js +158 -0
- package/dist/esm/tools/example_tool.js +13 -1
- package/dist/esm/tools/function_tool.js +316 -0
- package/dist/esm/tools/google_api_tool/google_api_tool.js +73 -0
- package/dist/esm/tools/google_api_tool/google_api_toolset.js +146 -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 +393 -0
- package/dist/esm/tools/google_api_tool/index.js +31 -0
- package/dist/esm/tools/load_artifacts_tool.js +10 -5
- package/dist/esm/tools/load_memory_tool.js +12 -10
- package/dist/esm/tools/mcp/index.js +6 -0
- package/dist/esm/tools/mcp/mcp_session_manager.js +25 -0
- package/dist/esm/tools/mcp/mcp_toolset.js +1 -14
- package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +1 -2
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +50 -3
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +4 -3
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
- 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_spec_parser/tool_auth_handler.js +15 -2
- package/dist/esm/tools/openapi_tool/openapi_toolset.js +6 -12
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +17 -1
- package/dist/esm/tools/retrieval/base_retrieval_tool.js +16 -2
- package/dist/esm/tools/toolbox_toolset.js +148 -0
- package/dist/esm/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/esm/utils/client_labels.js +19 -2
- package/dist/esm/utils/env_aware_utils.js +6 -8
- package/dist/esm/utils/error_utils.js +9 -10
- package/dist/esm/utils/failover_utils.js +1 -1
- package/dist/esm/utils/file_extension_utils.js +11 -0
- package/dist/esm/utils/file_utils.js +2 -23
- package/dist/esm/utils/gemini_schema_util.js +27 -7
- package/dist/esm/utils/json_utils.js +21 -0
- package/dist/esm/utils/live_connection_utils.js +4 -5
- package/dist/esm/utils/logger_node.js +11 -1
- package/dist/esm/utils/object_notation_utils.js +4 -2
- package/dist/esm/utils/output_schema_utils.js +5 -2
- package/dist/esm/utils/streaming_utils.js +11 -11
- package/dist/esm/utils/task.js +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/a2a_remote_agent.d.ts +9 -0
- package/dist/types/a2a/agent_card.d.ts +44 -1
- package/dist/types/a2a/agent_to_a2a.d.ts +9 -0
- package/dist/types/a2a/index.d.ts +1 -0
- package/dist/types/agents/agent_engine_client.d.ts +37 -0
- package/dist/types/agents/base_agent.d.ts +12 -0
- package/dist/types/agents/functions.d.ts +33 -1
- package/dist/types/agents/invocation_context.d.ts +20 -1
- package/dist/types/agents/langgraph_agent.d.ts +153 -0
- package/dist/types/agents/llm_agent.d.ts +5 -1
- package/dist/types/agents/processors/content_processor_utils.d.ts +4 -2
- package/dist/types/agents/processors/nl_planning_processor.d.ts +2 -1
- package/dist/types/auth/auth_handler.d.ts +28 -1
- package/dist/types/auth/auth_schemes.d.ts +13 -0
- package/dist/types/cli/cli_eval.d.ts +173 -0
- package/dist/types/cli/utils/envs.d.ts +23 -0
- package/dist/types/cli/utils/evals.d.ts +47 -0
- package/dist/types/cli/utils/logs.d.ts +38 -0
- package/dist/types/code_executors/code_execution_utils.d.ts +39 -0
- package/dist/types/code_executors/code_executor_context.d.ts +1 -0
- package/dist/types/code_executors/container_code_executor.d.ts +17 -5
- package/dist/types/common.d.ts +24 -5
- package/dist/types/errors/input_validation_error.d.ts +2 -1
- package/dist/types/events/event.d.ts +4 -0
- package/dist/types/examples/example_util.d.ts +17 -0
- package/dist/types/flows/llm_flows/audio_transcriber.d.ts +85 -0
- package/dist/types/index.d.ts +19 -2
- package/dist/types/models/gemini_llm_connection.d.ts +6 -7
- package/dist/types/models/routed_llm.d.ts +1 -1
- package/dist/types/plugins/base_plugin.d.ts +0 -10
- package/dist/types/runner/in_memory_runner.d.ts +2 -1
- package/dist/types/runner/runner.d.ts +34 -0
- package/dist/types/sessions/base_session_service.d.ts +5 -0
- package/dist/types/sessions/database_session_service.d.ts +17 -1
- package/dist/types/sessions/stale_session_error.d.ts +21 -0
- package/dist/types/sessions/state.d.ts +5 -1
- package/dist/types/sessions/vertex_ai_session_service.d.ts +8 -0
- package/dist/types/skills/loader.d.ts +3 -2
- package/dist/types/skills/skill.d.ts +1 -1
- package/dist/types/telemetry/tracing.d.ts +20 -4
- package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +115 -0
- package/dist/types/tools/apihub_tool/clients/apihub_client.d.ts +142 -0
- package/dist/types/tools/apihub_tool/clients/secret_client.d.ts +55 -0
- package/dist/types/tools/apihub_tool/clients/service_account.d.ts +11 -0
- package/dist/types/tools/application_integration_tool/application_integration_toolset.d.ts +109 -0
- package/dist/types/tools/application_integration_tool/clients/cloud_request.d.ts +53 -0
- package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +229 -0
- package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +72 -0
- package/dist/types/tools/application_integration_tool/integration_connector_tool.d.ts +70 -0
- package/dist/types/tools/base_toolset.d.ts +6 -5
- package/dist/types/tools/example_tool.d.ts +10 -0
- package/dist/types/tools/function_tool.d.ts +32 -0
- package/dist/types/tools/google_api_tool/google_api_tool.d.ts +37 -0
- package/dist/types/tools/google_api_tool/google_api_toolset.d.ts +55 -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 +165 -0
- package/dist/types/tools/google_api_tool/index.d.ts +10 -0
- package/dist/types/tools/load_artifacts_tool.d.ts +14 -1
- package/dist/types/tools/load_memory_tool.d.ts +23 -1
- package/dist/types/tools/mcp/index.d.ts +3 -0
- package/dist/types/tools/mcp/mcp_session_manager.d.ts +34 -1
- package/dist/types/tools/mcp/mcp_toolset.d.ts +15 -0
- package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +19 -0
- package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +18 -1
- 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 +8 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +2 -1
- 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/retrieval/base_retrieval_tool.d.ts +15 -0
- package/dist/types/tools/toolbox_toolset.d.ts +159 -0
- package/dist/types/utils/client_labels.d.ts +2 -1
- package/dist/types/utils/env_aware_utils.d.ts +18 -2
- package/dist/types/utils/error_utils.d.ts +7 -0
- package/dist/types/utils/file_utils.d.ts +6 -1
- package/dist/types/utils/gemini_schema_util.d.ts +9 -2
- package/dist/types/utils/json_utils.d.ts +11 -0
- package/dist/types/utils/object_notation_utils.d.ts +7 -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/streaming_utils.d.ts +11 -4
- package/dist/types/version.d.ts +1 -1
- package/dist/web/index_web.js +117 -110
- package/dist/web/index_web.js.map +4 -4
- package/package.json +38 -26
- package/dist/cjs/models/gemini_continuation.js +0 -232
- package/dist/esm/models/gemini_continuation.js +0 -205
- package/dist/types/models/gemini_continuation.d.ts +0 -59
|
@@ -9,11 +9,14 @@ import { Event } from '../events/event.js';
|
|
|
9
9
|
import { BaseTool } from '../tools/base_tool.js';
|
|
10
10
|
import { ResumeInputs } from '../tools/resume_inputs.js';
|
|
11
11
|
import { ToolConfirmation } from '../tools/tool_confirmation.js';
|
|
12
|
+
import { Context } from './context.js';
|
|
12
13
|
import { SingleAfterToolCallback, SingleBeforeToolCallback } from './llm_agent.js';
|
|
13
14
|
export { AF_FUNCTION_CALL_ID_PREFIX, generateClientFunctionCallId, populateClientFunctionCallId, } from '../events/event.js';
|
|
14
15
|
export { REQUEST_CONFIRMATION_FUNCTION_CALL_NAME, REQUEST_CREDENTIAL_FUNCTION_CALL_NAME, REQUEST_INPUT_FUNCTION_CALL_NAME, reservedFunctionCallName, } from './framework_function_calls.js';
|
|
15
16
|
export declare const functionsExportedForTestingOnly: {
|
|
16
17
|
handleFunctionCallList: typeof handleFunctionCallList;
|
|
18
|
+
handleFunctionCallsLive: typeof handleFunctionCallsLive;
|
|
19
|
+
processFunctionLiveHelper: typeof processFunctionLiveHelper;
|
|
17
20
|
generateAuthEvent: typeof generateAuthEvent;
|
|
18
21
|
generateRequestConfirmationEvent: typeof generateRequestConfirmationEvent;
|
|
19
22
|
};
|
|
@@ -63,6 +66,23 @@ export declare function handleFunctionCallsAsync({ invocationContext, functionCa
|
|
|
63
66
|
toolConfirmationDict?: Record<string, ToolConfirmation>;
|
|
64
67
|
resumeInputsDict?: Record<string, ResumeInputs>;
|
|
65
68
|
}): Promise<Event | null>;
|
|
69
|
+
/**
|
|
70
|
+
* Handles function calls in a live (bidirectional streaming) session.
|
|
71
|
+
*
|
|
72
|
+
* Supports regular sync/async tools, async-generator streaming tools that push
|
|
73
|
+
* incremental results onto `invocationContext.liveRequestQueue`, and the
|
|
74
|
+
* `stop_streaming` control call that cancels an active streaming tool task.
|
|
75
|
+
*/
|
|
76
|
+
export declare function handleFunctionCallsLive({ invocationContext, functionCallEvent, toolsDict, beforeToolCallbacks, afterToolCallbacks, filters, toolConfirmationDict, resumeInputsDict, }: {
|
|
77
|
+
invocationContext: InvocationContext;
|
|
78
|
+
functionCallEvent: Event;
|
|
79
|
+
toolsDict: Record<string, BaseTool>;
|
|
80
|
+
beforeToolCallbacks: SingleBeforeToolCallback[];
|
|
81
|
+
afterToolCallbacks: SingleAfterToolCallback[];
|
|
82
|
+
filters?: Set<string>;
|
|
83
|
+
toolConfirmationDict?: Record<string, ToolConfirmation>;
|
|
84
|
+
resumeInputsDict?: Record<string, ResumeInputs>;
|
|
85
|
+
}): Promise<Event | null>;
|
|
66
86
|
/**
|
|
67
87
|
* Whether `tool` is the placeholder handed to the on-tool-error callbacks for a
|
|
68
88
|
* function call naming a tool this agent cannot call.
|
|
@@ -76,7 +96,7 @@ export declare function isToolNotFound(tool: unknown): boolean;
|
|
|
76
96
|
* function calls instead of an event.
|
|
77
97
|
* This is also used by llm_agent execution flow in preprocessing.
|
|
78
98
|
*/
|
|
79
|
-
export declare function handleFunctionCallList({ invocationContext, functionCalls, toolsDict, beforeToolCallbacks, afterToolCallbacks, filters, toolConfirmationDict, resumeInputsDict, }: {
|
|
99
|
+
export declare function handleFunctionCallList({ invocationContext, functionCalls, toolsDict, beforeToolCallbacks, afterToolCallbacks, filters, toolConfirmationDict, resumeInputsDict, isLive, }: {
|
|
80
100
|
invocationContext: InvocationContext;
|
|
81
101
|
functionCalls: FunctionCall[];
|
|
82
102
|
toolsDict: Record<string, BaseTool>;
|
|
@@ -91,11 +111,23 @@ export declare function handleFunctionCallList({ invocationContext, functionCall
|
|
|
91
111
|
* approval; see {@link ResumeInputs}.
|
|
92
112
|
*/
|
|
93
113
|
resumeInputsDict?: Record<string, ResumeInputs>;
|
|
114
|
+
isLive?: boolean;
|
|
94
115
|
}): Promise<Event | null>;
|
|
95
116
|
/**
|
|
96
117
|
* Merges a list of function response events into a single event.
|
|
97
118
|
*/
|
|
98
119
|
export declare function mergeParallelFunctionResponseEvents(functionResponseEvents: Event[]): Event;
|
|
120
|
+
/**
|
|
121
|
+
* Executes a single tool call in live mode, supporting `stop_streaming`,
|
|
122
|
+
* async-generator streaming tools, and standard sync/async tools.
|
|
123
|
+
*/
|
|
124
|
+
declare function processFunctionLiveHelper({ tool, toolContext, functionCall, functionArgs, invocationContext, }: {
|
|
125
|
+
tool: BaseTool;
|
|
126
|
+
toolContext: Context;
|
|
127
|
+
functionCall: FunctionCall;
|
|
128
|
+
functionArgs: Record<string, unknown>;
|
|
129
|
+
invocationContext: InvocationContext;
|
|
130
|
+
}): Promise<unknown>;
|
|
99
131
|
/**
|
|
100
132
|
* Finds the most recent event before `endIndex` that contains a function call
|
|
101
133
|
* with the given ID.
|
|
@@ -59,6 +59,24 @@ export interface InvocationContextParams {
|
|
|
59
59
|
*/
|
|
60
60
|
a2aMetadata?: Record<string, unknown>;
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* A unique symbol to identify {@link LlmCallsLimitExceededError} instances.
|
|
64
|
+
*/
|
|
65
|
+
declare const LLM_CALLS_LIMIT_EXCEEDED_ERROR_SIGNATURE_SYMBOL: unique symbol;
|
|
66
|
+
/**
|
|
67
|
+
* Error thrown when the number of LLM calls in an invocation exceeds {@link RunConfig.maxLlmCalls}.
|
|
68
|
+
*/
|
|
69
|
+
export declare class LlmCallsLimitExceededError extends Error {
|
|
70
|
+
readonly [LLM_CALLS_LIMIT_EXCEEDED_ERROR_SIGNATURE_SYMBOL] = true;
|
|
71
|
+
constructor(message: string);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Type guard to check if an object is an instance of {@link LlmCallsLimitExceededError}.
|
|
75
|
+
*
|
|
76
|
+
* @param obj The object to check.
|
|
77
|
+
* @returns True if the object is an instance of {@link LlmCallsLimitExceededError}.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isLlmCallsLimitExceededError(obj: unknown): obj is LlmCallsLimitExceededError;
|
|
62
80
|
/**
|
|
63
81
|
* An invocation context represents the data of a single invocation of an agent.
|
|
64
82
|
*
|
|
@@ -198,7 +216,7 @@ export declare class InvocationContext {
|
|
|
198
216
|
* The live request queue feeding the model on the bidirectional (live) path.
|
|
199
217
|
* Set only for invocations started via `runner.runLive`.
|
|
200
218
|
*/
|
|
201
|
-
|
|
219
|
+
liveRequestQueue?: LiveRequestQueue;
|
|
202
220
|
/**
|
|
203
221
|
* The most recent session resumption handle observed on the live path.
|
|
204
222
|
* Updated as the server emits resumption updates so a reconnect can restore
|
|
@@ -255,3 +273,4 @@ export declare function newInvocationContextId(): string;
|
|
|
255
273
|
* @throws if the invocation is driving a bare node rather than an agent.
|
|
256
274
|
*/
|
|
257
275
|
export declare function requireAgent(ctx: InvocationContext): BaseAgent;
|
|
276
|
+
export {};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Event } from '../events/event.js';
|
|
7
|
+
import { BaseAgent, BaseAgentConfig } from './base_agent.js';
|
|
8
|
+
import { InvocationContext } from './invocation_context.js';
|
|
9
|
+
/**
|
|
10
|
+
* Text or structured content part inside a LangGraph message content array.
|
|
11
|
+
*/
|
|
12
|
+
export interface LangGraphContentPart {
|
|
13
|
+
readonly type?: string;
|
|
14
|
+
readonly text?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Content carried by a LangGraph message (`string` or an array of content parts).
|
|
18
|
+
*/
|
|
19
|
+
export type LangGraphMessageContent = string | ReadonlyArray<string | LangGraphContentPart>;
|
|
20
|
+
/**
|
|
21
|
+
* Structural representation of a message exchanged with a LangGraph graph.
|
|
22
|
+
*/
|
|
23
|
+
export interface LangGraphMessageLike {
|
|
24
|
+
/**
|
|
25
|
+
* Text or structured content of the message.
|
|
26
|
+
*/
|
|
27
|
+
readonly content: LangGraphMessageContent;
|
|
28
|
+
/**
|
|
29
|
+
* Optional role or message type identifier (`'human'`, `'ai'`, or `'system'`).
|
|
30
|
+
*/
|
|
31
|
+
readonly type?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Represents a human user message passed to a LangGraph graph.
|
|
35
|
+
*/
|
|
36
|
+
export interface LangGraphHumanMessage extends LangGraphMessageLike {
|
|
37
|
+
readonly type: 'human';
|
|
38
|
+
readonly content: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Represents an AI assistant message passed to or returned by a LangGraph graph.
|
|
42
|
+
*/
|
|
43
|
+
export interface LangGraphAIMessage extends LangGraphMessageLike {
|
|
44
|
+
readonly type: 'ai';
|
|
45
|
+
readonly content: LangGraphMessageContent;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Represents a system instruction message passed to a LangGraph graph.
|
|
49
|
+
*/
|
|
50
|
+
export interface LangGraphSystemMessage extends LangGraphMessageLike {
|
|
51
|
+
readonly type: 'system';
|
|
52
|
+
readonly content: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Runnable configuration passed to a compiled LangGraph graph invocation.
|
|
56
|
+
*/
|
|
57
|
+
export interface LangGraphRunnableConfig {
|
|
58
|
+
readonly configurable: {
|
|
59
|
+
/**
|
|
60
|
+
* Thread identifier expected in `snake_case` by LangGraph.js checkpointers.
|
|
61
|
+
*/
|
|
62
|
+
readonly thread_id: string;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* State snapshot returned by a compiled LangGraph graph's `getState` method.
|
|
67
|
+
*/
|
|
68
|
+
export interface LangGraphStateSnapshot {
|
|
69
|
+
readonly values?: {
|
|
70
|
+
readonly messages?: readonly LangGraphMessageLike[];
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Input state passed to a compiled LangGraph graph's `invoke` method.
|
|
75
|
+
*/
|
|
76
|
+
export interface LangGraphInvokeInput {
|
|
77
|
+
readonly messages: readonly LangGraphMessageLike[];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Output state returned by a compiled LangGraph graph's `invoke` method.
|
|
81
|
+
*/
|
|
82
|
+
export interface LangGraphInvokeOutput {
|
|
83
|
+
readonly messages?: readonly LangGraphMessageLike[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Structural interface for a compiled LangGraph graph.
|
|
87
|
+
*/
|
|
88
|
+
export interface CompiledGraphLike {
|
|
89
|
+
/**
|
|
90
|
+
* Optional checkpointer configured on the compiled graph for multi-turn state persistence.
|
|
91
|
+
*/
|
|
92
|
+
readonly checkpointer?: unknown;
|
|
93
|
+
/**
|
|
94
|
+
* Optional helper returning the underlying graph representation.
|
|
95
|
+
*/
|
|
96
|
+
getGraph?(...args: unknown[]): unknown;
|
|
97
|
+
/**
|
|
98
|
+
* Retrieves the current graph state for the given runnable configuration.
|
|
99
|
+
*/
|
|
100
|
+
getState?(config: LangGraphRunnableConfig): LangGraphStateSnapshot | undefined | Promise<LangGraphStateSnapshot | undefined>;
|
|
101
|
+
/**
|
|
102
|
+
* Invokes the compiled graph with the given message list and runnable configuration.
|
|
103
|
+
*/
|
|
104
|
+
invoke(input: LangGraphInvokeInput, config: LangGraphRunnableConfig): LangGraphInvokeOutput | Promise<LangGraphInvokeOutput>;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Configuration options for {@link LangGraphAgent}.
|
|
108
|
+
*/
|
|
109
|
+
export interface LangGraphAgentConfig extends BaseAgentConfig {
|
|
110
|
+
/**
|
|
111
|
+
* The compiled LangGraph graph to execute.
|
|
112
|
+
*/
|
|
113
|
+
graph: CompiledGraphLike;
|
|
114
|
+
/**
|
|
115
|
+
* Optional system instruction prepended when the graph state has no existing messages.
|
|
116
|
+
*/
|
|
117
|
+
instruction?: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Extracts the trailing contiguous sequence of human user messages from `events`.
|
|
121
|
+
*
|
|
122
|
+
* @param events The session events to inspect.
|
|
123
|
+
* @returns The trailing user messages in chronological order.
|
|
124
|
+
*/
|
|
125
|
+
export declare function getLastHumanMessages(events: readonly Event[]): LangGraphHumanMessage[];
|
|
126
|
+
declare const LANGGRAPH_AGENT_SIGNATURE_SYMBOL: unique symbol;
|
|
127
|
+
/**
|
|
128
|
+
* Type guard to check if an object is an instance of {@link LangGraphAgent}.
|
|
129
|
+
*
|
|
130
|
+
* @param obj The object to check.
|
|
131
|
+
* @returns True if the object is an instance of {@link LangGraphAgent}.
|
|
132
|
+
*/
|
|
133
|
+
export declare function isLangGraphAgent(obj: unknown): obj is LangGraphAgent;
|
|
134
|
+
/**
|
|
135
|
+
* An agent that wraps a compiled LangGraph graph for single-turn and multi-turn execution.
|
|
136
|
+
*/
|
|
137
|
+
export declare class LangGraphAgent extends BaseAgent<LangGraphAgentConfig> {
|
|
138
|
+
readonly [LANGGRAPH_AGENT_SIGNATURE_SYMBOL] = true;
|
|
139
|
+
/**
|
|
140
|
+
* The compiled LangGraph graph executed by this agent.
|
|
141
|
+
*/
|
|
142
|
+
readonly graph: CompiledGraphLike;
|
|
143
|
+
/**
|
|
144
|
+
* System instruction prepended when the graph state contains no prior messages.
|
|
145
|
+
*/
|
|
146
|
+
readonly instruction: string;
|
|
147
|
+
constructor(config: LangGraphAgentConfig);
|
|
148
|
+
protected runAsyncImpl(ctx: InvocationContext): AsyncGenerator<Event, void, void>;
|
|
149
|
+
protected runLiveImpl(_ctx: InvocationContext): AsyncGenerator<Event, void, void>;
|
|
150
|
+
private getMessages;
|
|
151
|
+
private getConversationWithAgent;
|
|
152
|
+
}
|
|
153
|
+
export {};
|
|
@@ -226,7 +226,11 @@ export interface LlmAgentConfig extends BaseAgentConfig {
|
|
|
226
226
|
*/
|
|
227
227
|
contextCompactors?: BaseContextCompactor[];
|
|
228
228
|
/**
|
|
229
|
-
*
|
|
229
|
+
* Allows the agent to execute code blocks from model responses using the
|
|
230
|
+
* provided `BaseCodeExecutor`.
|
|
231
|
+
*
|
|
232
|
+
* NOTE: to use the model's built-in code executor, use the
|
|
233
|
+
* `BuiltInCodeExecutor`.
|
|
230
234
|
*/
|
|
231
235
|
codeExecutor?: BaseCodeExecutor;
|
|
232
236
|
/**
|
|
@@ -20,10 +20,12 @@ export declare function removeClientFunctionCallId(content: Content): void;
|
|
|
20
20
|
* @param agentName: The name of the agent.
|
|
21
21
|
* @param currentBranch: The current branch of the agent.
|
|
22
22
|
* @param currentIsolationScope: The isolation scope of the current node, if any.
|
|
23
|
+
* @param preserveFunctionCallIds: Whether to preserve client-generated
|
|
24
|
+
* `adk-*` function call and response IDs instead of stripping them.
|
|
23
25
|
*
|
|
24
26
|
* @returns A list of processed contents.
|
|
25
27
|
*/
|
|
26
|
-
export declare function getContents(events: Event[], agentName: string, currentBranch?: string, currentIsolationScope?: string): Content[];
|
|
28
|
+
export declare function getContents(events: Event[], agentName: string, currentBranch?: string, currentIsolationScope?: string, preserveFunctionCallIds?: boolean): Content[];
|
|
27
29
|
/**
|
|
28
30
|
* Get contents for the current turn only (no conversation history).
|
|
29
31
|
*
|
|
@@ -42,7 +44,7 @@ export declare function getContents(events: Event[], agentName: string, currentB
|
|
|
42
44
|
* @returns A list of contents for the current turn only, preserving context
|
|
43
45
|
* needed for proper tool execution while excluding conversation history.
|
|
44
46
|
*/
|
|
45
|
-
export declare function getCurrentTurnContents(events: Event[], agentName: string, currentBranch?: string, currentIsolationScope?: string): Content[];
|
|
47
|
+
export declare function getCurrentTurnContents(events: Event[], agentName: string, currentBranch?: string, currentIsolationScope?: string, preserveFunctionCallIds?: boolean): Content[];
|
|
46
48
|
/**
|
|
47
49
|
* Merges a list of function_response events into one event.
|
|
48
50
|
*
|
|
@@ -19,7 +19,8 @@ export declare class NlPlanningRequestProcessor extends BaseLlmRequestProcessor
|
|
|
19
19
|
runAsync(invocationContext: InvocationContext, llmRequest: LlmRequest): AsyncGenerator<Event, void, void>;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* Replaces the LLM response parts with the planner's processed parts
|
|
22
|
+
* Replaces the LLM response parts with the planner's processed parts and emits
|
|
23
|
+
* a state-update event when the planner modifies session state.
|
|
23
24
|
*
|
|
24
25
|
* Partial responses are processed too.
|
|
25
26
|
*/
|
|
@@ -12,7 +12,12 @@ import { AuthConfig } from './auth_tool.js';
|
|
|
12
12
|
* This class should only be used by Agent Development Kit.
|
|
13
13
|
*/
|
|
14
14
|
export declare class AuthHandler {
|
|
15
|
-
|
|
15
|
+
authConfig: AuthConfig;
|
|
16
|
+
/**
|
|
17
|
+
* @param authConfig The auth config this handler reads. It stays readable
|
|
18
|
+
* and replaceable after construction; each method reads the current
|
|
19
|
+
* value.
|
|
20
|
+
*/
|
|
16
21
|
constructor(authConfig: AuthConfig);
|
|
17
22
|
getAuthResponse(state: State): AuthCredential | undefined;
|
|
18
23
|
/**
|
|
@@ -22,6 +27,24 @@ export declare class AuthHandler {
|
|
|
22
27
|
* @throws Error: If the auth config has no credentialKey.
|
|
23
28
|
*/
|
|
24
29
|
parseAndStoreAuthResponse(state: State): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Builds the auth request to send to the client.
|
|
32
|
+
*
|
|
33
|
+
* The result is always a new object, and its `exchangedAuthCredential` is
|
|
34
|
+
* never an object held by {@link authConfig}. A caller that fills in the
|
|
35
|
+
* response, for example `exchangedAuthCredential.oauth2.authResponseUri`,
|
|
36
|
+
* therefore leaves the handler's credentials unchanged.
|
|
37
|
+
*
|
|
38
|
+
* When the config is returned as is, because the scheme is not OAuth2 or
|
|
39
|
+
* OpenID Connect or the exchanged credential already has an auth URI, the
|
|
40
|
+
* result is a deep copy of the whole config. In the other branches only the
|
|
41
|
+
* exchanged credential is guaranteed independent: `authScheme` and
|
|
42
|
+
* `rawAuthCredential` are the handler's own objects.
|
|
43
|
+
*
|
|
44
|
+
* @return The auth config to request from the client.
|
|
45
|
+
* @throws Error: If an OAuth2 or OpenID Connect scheme has no raw
|
|
46
|
+
* credential, no `oauth2` on it, or no client ID and secret.
|
|
47
|
+
*/
|
|
25
48
|
generateAuthRequest(): AuthConfig;
|
|
26
49
|
/**
|
|
27
50
|
* Generates an response containing the auth uri for user to sign in.
|
|
@@ -30,6 +53,10 @@ export declare class AuthHandler {
|
|
|
30
53
|
* challenge derived from the credential's code verifier, and the returned
|
|
31
54
|
* credential carries the verifier the later token exchange must send.
|
|
32
55
|
*
|
|
56
|
+
* The URI leaves out `redirect_uri` when the credential has no
|
|
57
|
+
* `redirectUri`, so the provider uses the redirect registered for the
|
|
58
|
+
* client, and leaves out `scope` when the scheme lists no scopes.
|
|
59
|
+
*
|
|
33
60
|
* @return An AuthCredential object containing the auth URI and state.
|
|
34
61
|
* @throws Error: If the authorization endpoint is not configured in the
|
|
35
62
|
* auth scheme, or the credential requests a code challenge method other
|
|
@@ -23,6 +23,19 @@ export interface OpenIdConnectWithConfig extends OpenAPIV3.OpenIdSecurityScheme
|
|
|
23
23
|
* OpenIdConnectWithConfig.
|
|
24
24
|
*/
|
|
25
25
|
export type AuthScheme = OpenAPIV3.SecuritySchemeObject | OpenIdConnectWithConfig;
|
|
26
|
+
/**
|
|
27
|
+
* The OpenAPI security scheme types an {@link AuthScheme} can declare.
|
|
28
|
+
*
|
|
29
|
+
* The values are the exact strings of the OpenAPI `type` field, so a member
|
|
30
|
+
* compares equal to `authScheme.type` and can be enumerated at runtime with
|
|
31
|
+
* `Object.values(AuthSchemeType)`.
|
|
32
|
+
*/
|
|
33
|
+
export declare enum AuthSchemeType {
|
|
34
|
+
API_KEY = "apiKey",
|
|
35
|
+
HTTP = "http",
|
|
36
|
+
OAUTH2 = "oauth2",
|
|
37
|
+
OPEN_ID_CONNECT = "openIdConnect"
|
|
38
|
+
}
|
|
26
39
|
/**
|
|
27
40
|
* Represents the OAuth2 flow (or grant type).
|
|
28
41
|
*/
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { BaseAgent } from '../agents/base_agent.js';
|
|
7
|
+
import { BaseArtifactService } from '../artifacts/base_artifact_service.js';
|
|
8
|
+
import { BaseSessionService } from '../sessions/base_session_service.js';
|
|
9
|
+
import { EvaluationItem } from './utils/evals.js';
|
|
10
|
+
/**
|
|
11
|
+
* Error message when evaluation dependencies are missing.
|
|
12
|
+
*/
|
|
13
|
+
export declare const MISSING_EVAL_DEPENDENCIES_MESSAGE = "Eval module is not installed, please install via `pip install google-adk[eval]`.";
|
|
14
|
+
/**
|
|
15
|
+
* Metric key for average tool trajectory score.
|
|
16
|
+
*/
|
|
17
|
+
export declare const TOOL_TRAJECTORY_SCORE_KEY = "tool_trajectory_avg_score";
|
|
18
|
+
/**
|
|
19
|
+
* Metric key for response match (ROUGE-1) score.
|
|
20
|
+
*/
|
|
21
|
+
export declare const RESPONSE_MATCH_SCORE_KEY = "response_match_score";
|
|
22
|
+
/**
|
|
23
|
+
* Metric key for LLM-based response evaluation score.
|
|
24
|
+
*/
|
|
25
|
+
export declare const RESPONSE_EVALUATION_SCORE_KEY = "response_evaluation_score";
|
|
26
|
+
/**
|
|
27
|
+
* Prefix applied to session IDs generated during evaluation runs.
|
|
28
|
+
*/
|
|
29
|
+
export declare const EVAL_SESSION_ID_PREFIX = "___eval___session___";
|
|
30
|
+
/**
|
|
31
|
+
* Default evaluation criteria thresholds when no config file is supplied.
|
|
32
|
+
*/
|
|
33
|
+
export declare const DEFAULT_CRITERIA: Record<string, number>;
|
|
34
|
+
/**
|
|
35
|
+
* Outcome status of an evaluation metric or case.
|
|
36
|
+
*/
|
|
37
|
+
export declare enum EvalStatus {
|
|
38
|
+
PASSED = 1,
|
|
39
|
+
FAILED = 2,
|
|
40
|
+
NOT_EVALUATED = 3
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* An evaluation metric definition and its pass threshold.
|
|
44
|
+
*/
|
|
45
|
+
export interface EvalMetric {
|
|
46
|
+
metric_name: string;
|
|
47
|
+
threshold: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Result of evaluating a single metric.
|
|
51
|
+
*/
|
|
52
|
+
export interface EvalMetricResult extends EvalMetric {
|
|
53
|
+
score?: number;
|
|
54
|
+
eval_status: EvalStatus;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Per-invocation evaluation metric breakdown.
|
|
58
|
+
*/
|
|
59
|
+
export interface InvocationEvalMetricResult {
|
|
60
|
+
actual_invocation: EvaluationItem;
|
|
61
|
+
expected_invocation: EvaluationItem;
|
|
62
|
+
eval_metric_results: EvalMetricResult[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Complete evaluation result for a single eval case in an evalset.
|
|
66
|
+
*/
|
|
67
|
+
export interface EvalResult {
|
|
68
|
+
eval_set_file: string;
|
|
69
|
+
eval_id: string;
|
|
70
|
+
final_eval_status: EvalStatus;
|
|
71
|
+
eval_metric_results: Array<[EvalMetric, EvalMetricResult]>;
|
|
72
|
+
overall_eval_metric_results: EvalMetricResult[];
|
|
73
|
+
eval_metric_result_per_invocation: InvocationEvalMetricResult[];
|
|
74
|
+
session_id: string;
|
|
75
|
+
user_id?: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Request payload for adding a session to an eval set (`add_session`).
|
|
79
|
+
*/
|
|
80
|
+
export interface AddSessionToEvalSetRequest {
|
|
81
|
+
evalId: string;
|
|
82
|
+
sessionId: string;
|
|
83
|
+
userId: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Request payload for running evaluations on an eval set (`run_eval`).
|
|
87
|
+
*/
|
|
88
|
+
export interface RunEvalRequest {
|
|
89
|
+
evalIds: string[];
|
|
90
|
+
evalMetrics: EvalMetric[];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Result returned for a single evaluation case by the `run_eval` endpoint.
|
|
94
|
+
*/
|
|
95
|
+
export interface RunEvalResult extends EvalResult {
|
|
96
|
+
evalSetFile: string;
|
|
97
|
+
evalSetId: string;
|
|
98
|
+
evalId: string;
|
|
99
|
+
finalEvalStatus: EvalStatus;
|
|
100
|
+
evalMetricResults: Array<[EvalMetric, EvalMetricResult]>;
|
|
101
|
+
overallEvalMetricResults: EvalMetricResult[];
|
|
102
|
+
evalMetricResultPerInvocation: InvocationEvalMetricResult[];
|
|
103
|
+
userId?: string;
|
|
104
|
+
sessionId: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Initial session metadata for an evaluation case.
|
|
108
|
+
*/
|
|
109
|
+
export interface EvalInitialSession {
|
|
110
|
+
state?: Record<string, unknown>;
|
|
111
|
+
app_name?: string;
|
|
112
|
+
user_id?: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* A named evaluation case within an evalset file.
|
|
116
|
+
*/
|
|
117
|
+
export interface EvalEntry {
|
|
118
|
+
name: string;
|
|
119
|
+
data: EvaluationItem[];
|
|
120
|
+
initial_session?: EvalInitialSession;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Alias for a single evaluation case entry in an evalset.
|
|
124
|
+
*/
|
|
125
|
+
export type EvalSetItem = EvalEntry;
|
|
126
|
+
/**
|
|
127
|
+
* Options for running evaluations via `runEvals`.
|
|
128
|
+
*/
|
|
129
|
+
export interface RunEvalsOptions {
|
|
130
|
+
evalCasesByEvalSetId: Record<string, EvalEntry[] | string[]>;
|
|
131
|
+
rootAgent: BaseAgent;
|
|
132
|
+
resetFunc?: () => void | Promise<void>;
|
|
133
|
+
evalMetrics?: EvalMetric[];
|
|
134
|
+
printDetailedResults?: boolean;
|
|
135
|
+
sessionService?: BaseSessionService;
|
|
136
|
+
artifactService?: BaseArtifactService;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Loads evaluation criteria from a JSON config file, or returns `DEFAULT_CRITERIA`
|
|
140
|
+
* if no path is supplied.
|
|
141
|
+
*
|
|
142
|
+
* @param evalConfigFilePath Optional path to a `test_config.json` file.
|
|
143
|
+
* @returns Map of metric names to numeric thresholds.
|
|
144
|
+
*/
|
|
145
|
+
export declare function getEvaluationCriteriaOrDefault(evalConfigFilePath?: string): Record<string, number>;
|
|
146
|
+
/**
|
|
147
|
+
* Dynamically imports an agent module and returns its `rootAgent`.
|
|
148
|
+
*
|
|
149
|
+
* @param agentModuleFilePath File or directory path to the agent module.
|
|
150
|
+
* @returns The loaded `BaseAgent` instance.
|
|
151
|
+
*/
|
|
152
|
+
export declare function getRootAgent(agentModuleFilePath: string): Promise<BaseAgent>;
|
|
153
|
+
/**
|
|
154
|
+
* Attempts to retrieve an optional `reset_data` or `resetData` function from
|
|
155
|
+
* the agent module.
|
|
156
|
+
*
|
|
157
|
+
* @param agentModuleFilePath File or directory path to the agent module.
|
|
158
|
+
* @returns The reset function if exported, or `undefined`.
|
|
159
|
+
*/
|
|
160
|
+
export declare function tryGetResetFunc(agentModuleFilePath: string): Promise<(() => void | Promise<void>) | undefined>;
|
|
161
|
+
/**
|
|
162
|
+
* Parses CLI evalset file arguments of the form `file_path` or
|
|
163
|
+
* `file_path:eval_1,eval_2` into a mapping from file path to requested eval IDs.
|
|
164
|
+
*
|
|
165
|
+
* @param evalSetFilePaths Array of evalset file specifications.
|
|
166
|
+
* @returns Mapping of evalset file path to list of eval case names.
|
|
167
|
+
*/
|
|
168
|
+
export declare function parseAndGetEvalsToRun(evalSetFilePaths: string[]): Record<string, string[]>;
|
|
169
|
+
/**
|
|
170
|
+
* Runs a collection of evaluation cases against `rootAgent` and yields an
|
|
171
|
+
* `EvalResult` for each case.
|
|
172
|
+
*/
|
|
173
|
+
export declare function runEvals(optionsOrMap: RunEvalsOptions | Record<string, EvalEntry[] | string[]>, rootAgentArg?: BaseAgent, resetFuncArg?: () => void | Promise<void>, evalMetricsArg?: EvalMetric[], printDetailedResultsArg?: boolean, sessionServiceArg?: BaseSessionService, artifactServiceArg?: BaseArtifactService): AsyncGenerator<EvalResult, void, void>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Walks up the directory tree starting from `folder` until `filename` is found,
|
|
8
|
+
* or until the filesystem root is reached.
|
|
9
|
+
*
|
|
10
|
+
* @param folder The directory to start searching from.
|
|
11
|
+
* @param filename The file name to look for. Defaults to `'.env'`.
|
|
12
|
+
* @returns The absolute path to the found file, or `''` if not found.
|
|
13
|
+
*/
|
|
14
|
+
export declare function walkToRootUntilFound(folder: string, filename?: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Walks up from the agent directory to the root directory and loads the first
|
|
17
|
+
* `.env` file found into `process.env` with override semantics.
|
|
18
|
+
*
|
|
19
|
+
* @param agentName The name or path of the agent.
|
|
20
|
+
* @param agentParentFolder The parent directory containing the agent. Defaults to `'.'`.
|
|
21
|
+
* @param filename The dotenv filename to search for. Defaults to `'.env'`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function loadDotenvForAgent(agentName: string, agentParentFolder?: string, filename?: string): void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Part } from '@google/genai';
|
|
7
|
+
import { BaseAgent } from '../../agents/base_agent.js';
|
|
8
|
+
import { Session } from '../../sessions/session.js';
|
|
9
|
+
/**
|
|
10
|
+
* Represents a single expected tool invocation in an evaluation item.
|
|
11
|
+
*/
|
|
12
|
+
export interface ToolUseItem {
|
|
13
|
+
tool_name: string;
|
|
14
|
+
tool_input: Record<string, unknown>;
|
|
15
|
+
mock_tool_output?: unknown;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Represents an intermediate agent response tuple of `[author, parts]`.
|
|
19
|
+
*/
|
|
20
|
+
export type IntermediateAgentResponseItem = [string, Part[]];
|
|
21
|
+
/**
|
|
22
|
+
* Represents a single turn in an evaluation dataset converted from a session.
|
|
23
|
+
*/
|
|
24
|
+
export interface EvaluationItem {
|
|
25
|
+
query: string;
|
|
26
|
+
expected_tool_use: ToolUseItem[];
|
|
27
|
+
expected_intermediate_agent_responses: IntermediateAgentResponseItem[];
|
|
28
|
+
reference: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Converts a session into a list of evaluation items suitable for saving into
|
|
32
|
+
* an evalset or running through `runEvals`.
|
|
33
|
+
*
|
|
34
|
+
* @param session The session whose events should be converted.
|
|
35
|
+
* @returns An array of `EvaluationItem` records, one per user turn.
|
|
36
|
+
*/
|
|
37
|
+
export declare function convertSessionToEvalFormat(session?: Session): EvaluationItem[];
|
|
38
|
+
/**
|
|
39
|
+
* Creates a state object initialized with empty strings `''` for all `{var}`
|
|
40
|
+
* placeholders referenced in the instruction strings of `agent` and its
|
|
41
|
+
* sub-agents, overridden by any keys provided in `initializedStates`.
|
|
42
|
+
*
|
|
43
|
+
* @param agent The root agent to inspect.
|
|
44
|
+
* @param initializedStates Optional pre-initialized state values that take precedence.
|
|
45
|
+
* @returns The combined state record.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createEmptyState(agent: BaseAgent, initializedStates?: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { LogLevel } from '../../utils/logger.js';
|
|
7
|
+
/**
|
|
8
|
+
* Standard log format template for CLI log output.
|
|
9
|
+
*/
|
|
10
|
+
export declare const LOGGING_FORMAT = "%(asctime)s - %(levelname)s - %(filename)s:%(lineno)d - %(message)s";
|
|
11
|
+
/**
|
|
12
|
+
* Options for configuring `logToTmpFolder`.
|
|
13
|
+
*/
|
|
14
|
+
export interface LogToTmpFolderOptions {
|
|
15
|
+
/** Minimum log level to record. Defaults to `LogLevel.INFO`. */
|
|
16
|
+
level?: LogLevel;
|
|
17
|
+
/** Subdirectory inside the system temp folder. Defaults to `'agents_log'`. */
|
|
18
|
+
subFolder?: string;
|
|
19
|
+
/** Prefix for generated log files. Defaults to `'agent'`. */
|
|
20
|
+
logFilePrefix?: string;
|
|
21
|
+
/** Timestamp suffix for the log filename. Defaults to `YYYYMMDD_HHMMSS`. */
|
|
22
|
+
logFileTimestamp?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Configures the global ADK logger to write formatted log records to `stderr`.
|
|
26
|
+
*
|
|
27
|
+
* @param level The minimum `LogLevel` to emit. Defaults to `LogLevel.INFO`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function setupAdkLogger(level?: LogLevel): void;
|
|
30
|
+
/**
|
|
31
|
+
* Configures the global ADK logger to write formatted log records to a timestamped
|
|
32
|
+
* file in the system temporary directory and updates the `<prefix>.latest.log`
|
|
33
|
+
* symlink to point to the newest file.
|
|
34
|
+
*
|
|
35
|
+
* @param options Configuration options for the temporary log file.
|
|
36
|
+
* @returns The absolute path to the created log file.
|
|
37
|
+
*/
|
|
38
|
+
export declare function logToTmpFolder(options?: LogToTmpFolderOptions): string;
|