@google/adk 1.1.0 → 1.3.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/agents/base_agent.js +19 -1
- package/dist/cjs/agents/functions.js +4 -0
- package/dist/cjs/agents/instructions.js +81 -33
- package/dist/cjs/agents/invocation_context.js +0 -1
- package/dist/cjs/agents/llm_agent.js +52 -5
- package/dist/cjs/agents/processors/agent_transfer_llm_request_processor.js +7 -0
- package/dist/cjs/agents/processors/basic_llm_request_processor.js +8 -1
- package/dist/cjs/agents/processors/content_processor_utils.js +37 -24
- package/dist/cjs/agents/processors/content_request_processor.js +7 -0
- package/dist/cjs/agents/processors/context_compactor_request_processor.js +12 -0
- package/dist/cjs/agents/processors/identity_llm_request_processor.js +7 -0
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +5 -0
- package/dist/cjs/agents/processors/request_confirmation_llm_request_processor.js +9 -1
- package/dist/cjs/agents/processors/tool_filter_request_processor.js +7 -1
- package/dist/cjs/auth/auth_preprocessor.js +12 -10
- package/dist/cjs/auth/oauth2/oauth2_discovery.js +26 -2
- package/dist/cjs/code_executors/agent_engine_sandbox_code_executor.js +305 -0
- package/dist/cjs/code_executors/code_execution_utils.js +1 -1
- package/dist/cjs/code_executors/code_executor_context.js +7 -7
- package/dist/cjs/common.js +50 -0
- package/dist/cjs/context/summarizers/llm_summarizer.js +11 -0
- package/dist/cjs/context/token_based_context_compactor.js +1 -1
- package/dist/cjs/events/event.js +4 -2
- package/dist/cjs/index.js +14 -0
- package/dist/cjs/integrations/agent_registry/agent_registry.js +362 -0
- package/dist/cjs/integrations/agent_registry/agent_registry_mcp_toolset.js +122 -0
- package/dist/cjs/integrations/agent_registry/helpers.js +57 -0
- package/dist/cjs/integrations/agent_registry/types.js +50 -0
- package/dist/cjs/memory/vertex_ai_memory_bank_service.js +496 -0
- package/dist/cjs/models/gemini_llm_connection.js +62 -19
- package/dist/cjs/models/google_llm.js +26 -8
- package/dist/cjs/plugins/security_plugin.js +16 -0
- package/dist/cjs/runner/in_memory_runner.js +10 -5
- package/dist/cjs/runner/runner.js +32 -2
- package/dist/cjs/sessions/base_session_service.js +13 -2
- package/dist/cjs/sessions/database_session_service.js +51 -5
- package/dist/cjs/sessions/db/schema.js +45 -10
- package/dist/cjs/sessions/in_memory_session_service.js +72 -15
- package/dist/cjs/sessions/registry.js +4 -0
- package/dist/cjs/sessions/vertex_ai_session_service.js +429 -0
- package/dist/cjs/skills/gcp_skill_registry.js +104 -0
- package/dist/cjs/skills/loader.js +65 -0
- package/dist/cjs/skills/skill_registry.js +27 -0
- package/dist/cjs/tools/agent_tool.js +10 -5
- package/dist/cjs/tools/exit_loop_tool.js +9 -0
- package/dist/cjs/tools/function_tool.js +7 -2
- package/dist/cjs/tools/google_maps_grounding_tool.js +80 -0
- package/dist/cjs/tools/long_running_tool.js +2 -1
- package/dist/cjs/tools/mcp/mcp_session_manager.js +11 -0
- package/dist/cjs/tools/mcp/mcp_tool.js +10 -6
- package/dist/cjs/tools/mcp/mcp_toolset.js +26 -3
- package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +78 -0
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +84 -0
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +133 -0
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +232 -0
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +224 -0
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +127 -0
- package/dist/cjs/tools/openapi_tool/openapi_toolset.js +133 -0
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +256 -0
- package/dist/cjs/tools/skill/load_skill_resource_tool.js +27 -28
- package/dist/cjs/tools/skill/load_skill_tool.js +12 -1
- package/dist/cjs/tools/skill/run_skill_script_tool.js +12 -1
- package/dist/cjs/tools/skill/search_skills_tool.js +108 -0
- package/dist/cjs/tools/skill/skill_toolset.js +40 -5
- package/dist/cjs/tools/vertex_rag_retrieval_tool.js +64 -0
- package/dist/cjs/utils/async_queue.js +88 -0
- package/dist/cjs/utils/case_utils.js +53 -0
- package/dist/cjs/utils/env_aware_utils.js +4 -0
- package/dist/cjs/utils/file_utils.js +28 -0
- package/dist/cjs/utils/gemini_schema_util.js +18 -0
- package/dist/cjs/utils/live_connection_utils.js +284 -0
- package/dist/cjs/utils/model_name.js +9 -0
- package/dist/cjs/utils/partial_copy.js +51 -0
- package/dist/cjs/utils/streaming_utils.js +169 -122
- package/dist/cjs/utils/vertex_ai_utils.js +50 -0
- package/dist/cjs/version.js +1 -1
- package/dist/esm/agents/base_agent.js +19 -1
- package/dist/esm/agents/functions.js +4 -0
- package/dist/esm/agents/instructions.js +81 -33
- package/dist/esm/agents/invocation_context.js +0 -1
- package/dist/esm/agents/llm_agent.js +53 -5
- package/dist/esm/agents/processors/agent_transfer_llm_request_processor.js +7 -0
- package/dist/esm/agents/processors/basic_llm_request_processor.js +8 -1
- package/dist/esm/agents/processors/content_processor_utils.js +35 -23
- package/dist/esm/agents/processors/content_request_processor.js +7 -0
- package/dist/esm/agents/processors/context_compactor_request_processor.js +12 -0
- package/dist/esm/agents/processors/identity_llm_request_processor.js +7 -0
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +5 -0
- package/dist/esm/agents/processors/request_confirmation_llm_request_processor.js +9 -1
- package/dist/esm/agents/processors/tool_filter_request_processor.js +7 -1
- package/dist/esm/auth/auth_preprocessor.js +12 -10
- package/dist/esm/auth/oauth2/oauth2_discovery.js +26 -2
- package/dist/esm/code_executors/agent_engine_sandbox_code_executor.js +281 -0
- package/dist/esm/code_executors/code_execution_utils.js +1 -1
- package/dist/esm/code_executors/code_executor_context.js +7 -7
- package/dist/esm/common.js +43 -1
- package/dist/esm/context/summarizers/llm_summarizer.js +11 -0
- package/dist/esm/context/token_based_context_compactor.js +1 -1
- package/dist/esm/events/event.js +4 -2
- package/dist/esm/index.js +11 -0
- package/dist/esm/integrations/agent_registry/agent_registry.js +333 -0
- package/dist/esm/integrations/agent_registry/agent_registry_mcp_toolset.js +96 -0
- package/dist/esm/integrations/agent_registry/helpers.js +28 -0
- package/dist/esm/integrations/agent_registry/types.js +20 -0
- package/dist/esm/memory/vertex_ai_memory_bank_service.js +468 -0
- package/dist/esm/models/gemini_llm_connection.js +62 -19
- package/dist/esm/models/google_llm.js +26 -8
- package/dist/esm/plugins/security_plugin.js +16 -0
- package/dist/esm/runner/in_memory_runner.js +10 -5
- package/dist/esm/runner/runner.js +32 -2
- package/dist/esm/sessions/base_session_service.js +11 -1
- package/dist/esm/sessions/database_session_service.js +51 -5
- package/dist/esm/sessions/db/schema.js +44 -10
- package/dist/esm/sessions/in_memory_session_service.js +74 -16
- package/dist/esm/sessions/registry.js +7 -0
- package/dist/esm/sessions/vertex_ai_session_service.js +405 -0
- package/dist/esm/skills/gcp_skill_registry.js +78 -0
- package/dist/esm/skills/loader.js +64 -0
- package/dist/esm/skills/skill_registry.js +7 -0
- package/dist/esm/tools/agent_tool.js +10 -5
- package/dist/esm/tools/exit_loop_tool.js +9 -0
- package/dist/esm/tools/function_tool.js +7 -2
- package/dist/esm/tools/google_maps_grounding_tool.js +54 -0
- package/dist/esm/tools/long_running_tool.js +2 -1
- package/dist/esm/tools/mcp/mcp_session_manager.js +11 -0
- package/dist/esm/tools/mcp/mcp_tool.js +10 -6
- package/dist/esm/tools/mcp/mcp_toolset.js +26 -3
- package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +48 -0
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +60 -0
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +111 -0
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +206 -0
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +198 -0
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +101 -0
- package/dist/esm/tools/openapi_tool/openapi_toolset.js +97 -0
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +229 -0
- package/dist/esm/tools/skill/load_skill_resource_tool.js +26 -27
- package/dist/esm/tools/skill/load_skill_tool.js +12 -1
- package/dist/esm/tools/skill/run_skill_script_tool.js +12 -1
- package/dist/esm/tools/skill/search_skills_tool.js +82 -0
- package/dist/esm/tools/skill/skill_toolset.js +40 -5
- package/dist/esm/tools/vertex_rag_retrieval_tool.js +36 -0
- package/dist/esm/utils/async_queue.js +60 -0
- package/dist/esm/utils/case_utils.js +25 -0
- package/dist/esm/utils/env_aware_utils.js +4 -0
- package/dist/esm/utils/file_utils.js +26 -0
- package/dist/esm/utils/gemini_schema_util.js +18 -0
- package/dist/esm/utils/live_connection_utils.js +256 -0
- package/dist/esm/utils/model_name.js +8 -0
- package/dist/esm/utils/partial_copy.js +23 -0
- package/dist/esm/utils/streaming_utils.js +167 -121
- package/dist/esm/utils/vertex_ai_utils.js +22 -0
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/a2a_remote_agent.d.ts +14 -0
- package/dist/types/a2a/a2a_remote_agent_utils.d.ts +29 -4
- package/dist/types/a2a/event_converter_utils.d.ts +14 -1
- package/dist/types/a2a/metadata_converter_utils.d.ts +18 -0
- package/dist/types/a2a/part_converter_utils.d.ts +51 -6
- package/dist/types/agents/invocation_context.d.ts +0 -9
- package/dist/types/agents/llm_agent.d.ts +14 -0
- package/dist/types/agents/processors/agent_transfer_llm_request_processor.d.ts +14 -0
- package/dist/types/agents/processors/base_llm_processor.d.ts +12 -4
- package/dist/types/agents/processors/basic_llm_request_processor.d.ts +12 -0
- package/dist/types/agents/processors/content_processor_utils.d.ts +26 -0
- package/dist/types/agents/processors/content_request_processor.d.ts +16 -0
- package/dist/types/agents/processors/context_compactor_request_processor.d.ts +12 -0
- package/dist/types/agents/processors/identity_llm_request_processor.d.ts +11 -0
- package/dist/types/agents/processors/request_confirmation_llm_request_processor.d.ts +14 -1
- package/dist/types/agents/processors/tool_filter_request_processor.d.ts +12 -1
- package/dist/types/agents/run_config.d.ts +15 -0
- package/dist/types/code_executors/agent_engine_sandbox_code_executor.d.ts +51 -0
- package/dist/types/common.d.ts +19 -1
- package/dist/types/context/summarizers/llm_summarizer.d.ts +17 -0
- package/dist/types/events/event_actions.d.ts +25 -8
- package/dist/types/events/structured_events.d.ts +13 -0
- package/dist/types/examples/example_util.d.ts +25 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/integrations/agent_registry/agent_registry.d.ts +94 -0
- package/dist/types/integrations/agent_registry/agent_registry_mcp_toolset.d.ts +62 -0
- package/dist/types/integrations/agent_registry/helpers.d.ts +7 -0
- package/dist/types/integrations/agent_registry/types.d.ts +101 -0
- package/dist/types/memory/vertex_ai_memory_bank_service.d.ts +52 -0
- package/dist/types/models/base_llm_connection.d.ts +10 -0
- package/dist/types/models/gemini_llm_connection.d.ts +15 -4
- package/dist/types/models/llm_response.d.ts +10 -1
- package/dist/types/plugins/security_plugin.d.ts +30 -0
- package/dist/types/runner/in_memory_runner.d.ts +28 -1
- package/dist/types/runner/runner.d.ts +47 -0
- package/dist/types/sessions/base_session_service.d.ts +22 -0
- package/dist/types/sessions/database_session_service.d.ts +1 -1
- package/dist/types/sessions/db/schema.d.ts +1 -0
- package/dist/types/sessions/in_memory_session_service.d.ts +1 -1
- package/dist/types/sessions/vertex_ai_session_service.d.ts +37 -0
- package/dist/types/skills/gcp_skill_registry.d.ts +24 -0
- package/dist/types/skills/loader.d.ts +7 -0
- package/dist/types/skills/skill.d.ts +1 -1
- package/dist/types/skills/skill_registry.d.ts +29 -0
- package/dist/types/tools/exit_loop_tool.d.ts +9 -0
- package/dist/types/tools/function_tool.d.ts +22 -2
- package/dist/types/tools/google_maps_grounding_tool.d.ts +22 -0
- package/dist/types/tools/long_running_tool.d.ts +11 -1
- package/dist/types/tools/mcp/mcp_session_manager.d.ts +3 -0
- package/dist/types/tools/mcp/mcp_toolset.d.ts +2 -1
- package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +25 -0
- package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +20 -0
- package/dist/types/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.d.ts +20 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +34 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +59 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +23 -0
- package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +27 -0
- package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +50 -0
- package/dist/types/tools/skill/load_skill_resource_tool.d.ts +1 -1
- package/dist/types/tools/skill/search_skills_tool.d.ts +14 -0
- package/dist/types/tools/skill/skill_toolset.d.ts +5 -0
- package/dist/types/tools/vertex_rag_retrieval_tool.d.ts +42 -0
- package/dist/types/utils/async_queue.d.ts +18 -0
- package/dist/types/utils/case_utils.d.ts +12 -0
- package/dist/types/utils/file_utils.d.ts +2 -0
- package/dist/types/utils/live_connection_utils.d.ts +30 -0
- package/dist/types/utils/model_name.d.ts +7 -0
- package/dist/types/utils/partial_copy.d.ts +13 -0
- package/dist/types/utils/streaming_utils.d.ts +7 -17
- package/dist/types/utils/vertex_ai_utils.d.ts +14 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/web/agents/base_agent.js +31 -1
- package/dist/web/agents/functions.js +4 -0
- package/dist/web/agents/instructions.js +81 -33
- package/dist/web/agents/invocation_context.js +0 -1
- package/dist/web/agents/llm_agent.js +53 -5
- package/dist/web/agents/processors/agent_transfer_llm_request_processor.js +7 -0
- package/dist/web/agents/processors/basic_llm_request_processor.js +8 -1
- package/dist/web/agents/processors/content_processor_utils.js +53 -23
- package/dist/web/agents/processors/content_request_processor.js +7 -0
- package/dist/web/agents/processors/context_compactor_request_processor.js +12 -0
- package/dist/web/agents/processors/identity_llm_request_processor.js +7 -0
- package/dist/web/agents/processors/instructions_llm_request_processor.js +5 -0
- package/dist/web/agents/processors/request_confirmation_llm_request_processor.js +9 -1
- package/dist/web/agents/processors/tool_filter_request_processor.js +7 -1
- package/dist/web/auth/auth_preprocessor.js +12 -10
- package/dist/web/auth/oauth2/oauth2_discovery.js +26 -2
- package/dist/web/code_executors/agent_engine_sandbox_code_executor.js +281 -0
- package/dist/web/code_executors/code_execution_utils.js +1 -1
- package/dist/web/code_executors/code_executor_context.js +7 -7
- package/dist/web/common.js +43 -1
- package/dist/web/context/summarizers/llm_summarizer.js +11 -0
- package/dist/web/context/token_based_context_compactor.js +1 -1
- package/dist/web/events/event.js +4 -2
- package/dist/web/index.js +11 -0
- package/dist/web/integrations/agent_registry/agent_registry.js +333 -0
- package/dist/web/integrations/agent_registry/agent_registry_mcp_toolset.js +109 -0
- package/dist/web/integrations/agent_registry/helpers.js +28 -0
- package/dist/web/integrations/agent_registry/types.js +20 -0
- package/dist/web/memory/vertex_ai_memory_bank_service.js +475 -0
- package/dist/web/models/gemini_llm_connection.js +75 -19
- package/dist/web/models/google_llm.js +26 -8
- package/dist/web/plugins/security_plugin.js +16 -0
- package/dist/web/runner/in_memory_runner.js +10 -5
- package/dist/web/runner/runner.js +32 -2
- package/dist/web/sessions/base_session_service.js +11 -1
- package/dist/web/sessions/database_session_service.js +51 -5
- package/dist/web/sessions/db/schema.js +44 -10
- package/dist/web/sessions/in_memory_session_service.js +74 -16
- package/dist/web/sessions/registry.js +7 -0
- package/dist/web/sessions/vertex_ai_session_service.js +416 -0
- package/dist/web/skills/gcp_skill_registry.js +78 -0
- package/dist/web/skills/loader.js +64 -0
- package/dist/web/skills/skill_registry.js +7 -0
- package/dist/web/tools/agent_tool.js +10 -5
- package/dist/web/tools/exit_loop_tool.js +9 -0
- package/dist/web/tools/function_tool.js +7 -2
- package/dist/web/tools/google_maps_grounding_tool.js +54 -0
- package/dist/web/tools/long_running_tool.js +2 -1
- package/dist/web/tools/mcp/mcp_session_manager.js +11 -0
- package/dist/web/tools/mcp/mcp_tool.js +10 -6
- package/dist/web/tools/mcp/mcp_toolset.js +26 -3
- package/dist/web/tools/openapi_tool/auth/auth_helpers.js +48 -0
- package/dist/web/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +60 -0
- package/dist/web/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +111 -0
- package/dist/web/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +221 -0
- package/dist/web/tools/openapi_tool/openapi_spec_parser/operation_parser.js +198 -0
- package/dist/web/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +101 -0
- package/dist/web/tools/openapi_tool/openapi_toolset.js +97 -0
- package/dist/web/tools/openapi_tool/rest_api_tool.js +229 -0
- package/dist/web/tools/skill/load_skill_resource_tool.js +26 -27
- package/dist/web/tools/skill/load_skill_tool.js +12 -1
- package/dist/web/tools/skill/run_skill_script_tool.js +12 -1
- package/dist/web/tools/skill/search_skills_tool.js +82 -0
- package/dist/web/tools/skill/skill_toolset.js +40 -5
- package/dist/web/tools/vertex_rag_retrieval_tool.js +36 -0
- package/dist/web/utils/async_queue.js +60 -0
- package/dist/web/utils/case_utils.js +25 -0
- package/dist/web/utils/env_aware_utils.js +4 -0
- package/dist/web/utils/file_utils.js +26 -0
- package/dist/web/utils/gemini_schema_util.js +18 -0
- package/dist/web/utils/live_connection_utils.js +254 -0
- package/dist/web/utils/model_name.js +8 -0
- package/dist/web/utils/partial_copy.js +23 -0
- package/dist/web/utils/streaming_utils.js +221 -122
- package/dist/web/utils/vertex_ai_utils.js +22 -0
- package/dist/web/version.js +1 -1
- package/package.json +4 -1
|
@@ -46,6 +46,13 @@ function isGemini2OrAbove(modelString) {
|
|
|
46
46
|
const parsedVersion = parseVersion(versionString);
|
|
47
47
|
return parsedVersion.valid && parsedVersion.major >= 2;
|
|
48
48
|
}
|
|
49
|
+
function isGemini3xFlashLive(modelString) {
|
|
50
|
+
if (!modelString) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
const modelName = extractModelName(modelString);
|
|
54
|
+
return modelName.startsWith("gemini-3.") && modelName.includes("-flash-live");
|
|
55
|
+
}
|
|
49
56
|
function isGeminiModelIdCheckDisabled() {
|
|
50
57
|
return getBooleanEnvVar("ADK_DISABLE_GEMINI_MODEL_ID_CHECK");
|
|
51
58
|
}
|
|
@@ -53,6 +60,7 @@ export {
|
|
|
53
60
|
extractModelName,
|
|
54
61
|
isGemini1Model,
|
|
55
62
|
isGemini2OrAbove,
|
|
63
|
+
isGemini3xFlashLive,
|
|
56
64
|
isGeminiModel,
|
|
57
65
|
isGeminiModelIdCheckDisabled
|
|
58
66
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
/**
|
|
4
|
+
* @license
|
|
5
|
+
* Copyright 2026 Google LLC
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
function partialCopy(source, targetKeys) {
|
|
9
|
+
const result = {};
|
|
10
|
+
const sourceAsUnknown = source;
|
|
11
|
+
targetKeys.forEach((key) => {
|
|
12
|
+
const keyStr = key;
|
|
13
|
+
if (keyStr in source) {
|
|
14
|
+
result[key] = sourceAsUnknown[keyStr];
|
|
15
|
+
} else {
|
|
16
|
+
result[key] = void 0;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
partialCopy
|
|
23
|
+
};
|
|
@@ -12,15 +12,9 @@ import { JSONPath } from "jsonpath-plus";
|
|
|
12
12
|
import { generateClientFunctionCallId } from "../agents/functions.js";
|
|
13
13
|
import { FeatureName, isFeatureEnabled } from "../features/feature_registry.js";
|
|
14
14
|
import { createLlmResponse } from "../models/llm_response.js";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
)) {
|
|
19
|
-
this.isProgressiveMode = isProgressiveMode;
|
|
20
|
-
// For non-progressive SSE streaming mode
|
|
21
|
-
this.text = "";
|
|
22
|
-
this.thoughtText = "";
|
|
23
|
-
// For progressive SSE streaming mode: accumulate parts in order
|
|
15
|
+
const UNSAFE_PROPERTY_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
16
|
+
class ProgressiveStrategy {
|
|
17
|
+
constructor() {
|
|
24
18
|
this.partsSequence = [];
|
|
25
19
|
this.currentTextBuffer = "";
|
|
26
20
|
this.currentFcArgs = {};
|
|
@@ -85,10 +79,13 @@ class StreamingResponseAggregator {
|
|
|
85
79
|
const pathParts = JSONPath.toPathArray(jsonPath).filter(
|
|
86
80
|
(p) => p !== "$" && p !== "$["
|
|
87
81
|
);
|
|
82
|
+
if (pathParts.some((part) => UNSAFE_PROPERTY_KEYS.has(String(part)))) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
88
85
|
let current = this.currentFcArgs;
|
|
89
86
|
for (let i = 0; i < pathParts.length - 1; i++) {
|
|
90
87
|
const part = pathParts[i];
|
|
91
|
-
if (!(part
|
|
88
|
+
if (!Object.prototype.hasOwnProperty.call(current, part)) {
|
|
92
89
|
current[part] = {};
|
|
93
90
|
}
|
|
94
91
|
current = current[part];
|
|
@@ -147,11 +144,6 @@ class StreamingResponseAggregator {
|
|
|
147
144
|
if (!fc) {
|
|
148
145
|
return;
|
|
149
146
|
}
|
|
150
|
-
if (part.thoughtSignature) {
|
|
151
|
-
this.lastThoughtSignature = part.thoughtSignature;
|
|
152
|
-
} else if (this.lastThoughtSignature) {
|
|
153
|
-
part.thoughtSignature = this.lastThoughtSignature.toString();
|
|
154
|
-
}
|
|
155
147
|
if (fc.partialArgs || fc.willContinue) {
|
|
156
148
|
if (!fc.id && !this.currentFcId) {
|
|
157
149
|
fc.id = generateClientFunctionCallId();
|
|
@@ -170,63 +162,103 @@ class StreamingResponseAggregator {
|
|
|
170
162
|
}
|
|
171
163
|
}
|
|
172
164
|
}
|
|
173
|
-
async *processResponse(
|
|
174
|
-
var _a
|
|
175
|
-
this.response = response;
|
|
176
|
-
const llmResponse = createLlmResponse(response);
|
|
177
|
-
this.usageMetadata = llmResponse.usageMetadata;
|
|
178
|
-
if (llmResponse.groundingMetadata) {
|
|
179
|
-
this.groundingMetadata = llmResponse.groundingMetadata;
|
|
180
|
-
}
|
|
181
|
-
if (llmResponse.citationMetadata) {
|
|
182
|
-
this.citationMetadata = llmResponse.citationMetadata;
|
|
183
|
-
}
|
|
184
|
-
if (llmResponse.finishReason) {
|
|
185
|
-
this.finishReason = llmResponse.finishReason;
|
|
186
|
-
}
|
|
165
|
+
async *processResponse(llmResponse) {
|
|
166
|
+
var _a;
|
|
187
167
|
if (llmResponse.content && llmResponse.content.parts) {
|
|
188
168
|
for (const part of llmResponse.content.parts) {
|
|
189
|
-
if (part.
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
169
|
+
if (part.text) {
|
|
170
|
+
const isThought = (_a = part.thought) != null ? _a : false;
|
|
171
|
+
if (this.currentTextBuffer && isThought !== this.currentTextIsThought) {
|
|
172
|
+
this.flushTextBufferToSequence();
|
|
173
|
+
}
|
|
174
|
+
if (!this.currentTextBuffer) {
|
|
175
|
+
this.currentTextIsThought = isThought;
|
|
176
|
+
}
|
|
177
|
+
this.currentTextBuffer += part.text;
|
|
178
|
+
} else if (part.functionCall) {
|
|
179
|
+
this.processFunctionCallPart(part);
|
|
180
|
+
} else {
|
|
181
|
+
this.flushTextBufferToSequence();
|
|
182
|
+
this.partsSequence.push(part);
|
|
193
183
|
}
|
|
194
184
|
}
|
|
195
185
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
186
|
+
llmResponse.partial = true;
|
|
187
|
+
yield llmResponse;
|
|
188
|
+
}
|
|
189
|
+
close() {
|
|
190
|
+
this.flushTextBufferToSequence();
|
|
191
|
+
this.flushFunctionCallToSequence();
|
|
192
|
+
const finalParts = this.partsSequence;
|
|
193
|
+
if (finalParts.length === 0) {
|
|
194
|
+
return void 0;
|
|
195
|
+
}
|
|
196
|
+
return finalParts;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
class NonProgressiveStrategy {
|
|
200
|
+
constructor() {
|
|
201
|
+
this.text = "";
|
|
202
|
+
this.thoughtText = "";
|
|
203
|
+
}
|
|
204
|
+
async *processResponse(llmResponse) {
|
|
205
|
+
var _a;
|
|
206
|
+
if ((_a = llmResponse.content) == null ? void 0 : _a.parts) {
|
|
207
|
+
const nonTextParts = [];
|
|
208
|
+
let sawTextPart = false;
|
|
209
|
+
for (const part of llmResponse.content.parts) {
|
|
210
|
+
if (typeof part.text === "string") {
|
|
211
|
+
sawTextPart = true;
|
|
212
|
+
if (part.thought) {
|
|
213
|
+
this.thoughtText += part.text;
|
|
210
214
|
} else {
|
|
211
|
-
this.
|
|
212
|
-
this.partsSequence.push(part);
|
|
215
|
+
this.text += part.text;
|
|
213
216
|
}
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
if (part.functionCall && !part.functionCall.id) {
|
|
220
|
+
part.functionCall.id = generateClientFunctionCallId();
|
|
214
221
|
}
|
|
222
|
+
nonTextParts.push(part);
|
|
215
223
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
if (nonTextParts.length > 0) {
|
|
225
|
+
if (this.thoughtText || this.text) {
|
|
226
|
+
const parts = [];
|
|
227
|
+
if (this.thoughtText) {
|
|
228
|
+
parts.push({ text: this.thoughtText, thought: true });
|
|
229
|
+
}
|
|
230
|
+
if (this.text) {
|
|
231
|
+
parts.push({ text: this.text });
|
|
232
|
+
}
|
|
233
|
+
yield {
|
|
234
|
+
content: {
|
|
235
|
+
role: "model",
|
|
236
|
+
parts
|
|
237
|
+
},
|
|
238
|
+
usageMetadata: llmResponse.usageMetadata,
|
|
239
|
+
partial: false
|
|
240
|
+
};
|
|
241
|
+
this.thoughtText = "";
|
|
242
|
+
this.text = "";
|
|
243
|
+
}
|
|
244
|
+
yield {
|
|
245
|
+
...llmResponse,
|
|
246
|
+
content: {
|
|
247
|
+
role: llmResponse.content.role,
|
|
248
|
+
parts: nonTextParts
|
|
249
|
+
},
|
|
250
|
+
partial: false
|
|
251
|
+
};
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (sawTextPart) {
|
|
255
|
+
llmResponse.partial = true;
|
|
227
256
|
}
|
|
228
|
-
|
|
229
|
-
|
|
257
|
+
}
|
|
258
|
+
yield llmResponse;
|
|
259
|
+
}
|
|
260
|
+
close() {
|
|
261
|
+
if (this.text || this.thoughtText) {
|
|
230
262
|
const parts = [];
|
|
231
263
|
if (this.thoughtText) {
|
|
232
264
|
parts.push({ text: this.thoughtText, thought: true });
|
|
@@ -234,74 +266,88 @@ class StreamingResponseAggregator {
|
|
|
234
266
|
if (this.text) {
|
|
235
267
|
parts.push({ text: this.text });
|
|
236
268
|
}
|
|
237
|
-
|
|
238
|
-
content: {
|
|
239
|
-
role: "model",
|
|
240
|
-
parts
|
|
241
|
-
},
|
|
242
|
-
usageMetadata: llmResponse.usageMetadata,
|
|
243
|
-
partial: false
|
|
244
|
-
};
|
|
245
|
-
this.thoughtText = "";
|
|
246
|
-
this.text = "";
|
|
269
|
+
return parts;
|
|
247
270
|
}
|
|
248
|
-
|
|
271
|
+
return void 0;
|
|
249
272
|
}
|
|
250
|
-
|
|
273
|
+
}
|
|
274
|
+
class StreamingResponseAggregator {
|
|
275
|
+
constructor(isProgressiveMode = isFeatureEnabled(
|
|
276
|
+
FeatureName.PROGRESSIVE_SSE_STREAMING
|
|
277
|
+
)) {
|
|
278
|
+
this.isProgressiveMode = isProgressiveMode;
|
|
279
|
+
this.lastThoughtSignature = {};
|
|
280
|
+
this.strategy = this.isProgressiveMode ? new ProgressiveStrategy() : new NonProgressiveStrategy();
|
|
281
|
+
}
|
|
282
|
+
async *processResponse(response) {
|
|
251
283
|
var _a, _b;
|
|
252
|
-
|
|
284
|
+
const llmResponse = createLlmResponse(response);
|
|
285
|
+
const parts = (_b = (_a = llmResponse.content) == null ? void 0 : _a.parts) != null ? _b : [];
|
|
286
|
+
if (parts.every(isEmptyContentPart) && (llmResponse.finishReason === void 0 || llmResponse.finishReason === FinishReason.STOP)) {
|
|
287
|
+
if (llmResponse.usageMetadata) {
|
|
288
|
+
this.usageMetadata = llmResponse.usageMetadata;
|
|
289
|
+
}
|
|
290
|
+
if (llmResponse.groundingMetadata) {
|
|
291
|
+
this.groundingMetadata = llmResponse.groundingMetadata;
|
|
292
|
+
}
|
|
293
|
+
if (llmResponse.citationMetadata) {
|
|
294
|
+
this.citationMetadata = llmResponse.citationMetadata;
|
|
295
|
+
}
|
|
296
|
+
if (llmResponse.finishReason) {
|
|
297
|
+
this.finishReason = llmResponse.finishReason;
|
|
298
|
+
}
|
|
253
299
|
return;
|
|
254
300
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
if (finalParts.length === 0) {
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
const candidate = this.response.candidates[0];
|
|
263
|
-
const finishReason = (_b = this.finishReason) != null ? _b : candidate.finishReason;
|
|
264
|
-
return {
|
|
265
|
-
content: {
|
|
266
|
-
role: "model",
|
|
267
|
-
parts: finalParts
|
|
268
|
-
},
|
|
269
|
-
groundingMetadata: this.groundingMetadata,
|
|
270
|
-
citationMetadata: this.citationMetadata,
|
|
271
|
-
errorCode: finishReason === FinishReason.STOP ? void 0 : finishReason,
|
|
272
|
-
errorMessage: finishReason === FinishReason.STOP ? void 0 : candidate.finishMessage,
|
|
273
|
-
usageMetadata: this.usageMetadata,
|
|
274
|
-
finishReason,
|
|
275
|
-
partial: false
|
|
276
|
-
};
|
|
301
|
+
this.response = response;
|
|
302
|
+
this.usageMetadata = llmResponse.usageMetadata;
|
|
303
|
+
if (llmResponse.groundingMetadata) {
|
|
304
|
+
this.groundingMetadata = llmResponse.groundingMetadata;
|
|
277
305
|
}
|
|
278
|
-
if (
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
306
|
+
if (llmResponse.citationMetadata) {
|
|
307
|
+
this.citationMetadata = llmResponse.citationMetadata;
|
|
308
|
+
}
|
|
309
|
+
if (llmResponse.finishReason) {
|
|
310
|
+
this.finishReason = llmResponse.finishReason;
|
|
311
|
+
}
|
|
312
|
+
if (llmResponse.content && llmResponse.content.parts) {
|
|
313
|
+
for (const part of llmResponse.content.parts) {
|
|
314
|
+
if (part.thoughtSignature) {
|
|
315
|
+
this.lastThoughtSignature.value = part.thoughtSignature;
|
|
316
|
+
} else if (part.functionCall && this.lastThoughtSignature.value) {
|
|
317
|
+
part.thoughtSignature = this.lastThoughtSignature.value.toString();
|
|
318
|
+
}
|
|
285
319
|
}
|
|
286
|
-
const candidate = this.response.candidates[0];
|
|
287
|
-
const finishReason = candidate.finishReason;
|
|
288
|
-
return {
|
|
289
|
-
content: {
|
|
290
|
-
role: "model",
|
|
291
|
-
parts
|
|
292
|
-
},
|
|
293
|
-
groundingMetadata: this.groundingMetadata,
|
|
294
|
-
citationMetadata: this.citationMetadata,
|
|
295
|
-
errorCode: finishReason === FinishReason.STOP ? void 0 : finishReason,
|
|
296
|
-
errorMessage: finishReason === FinishReason.STOP ? void 0 : candidate.finishMessage,
|
|
297
|
-
usageMetadata: this.usageMetadata,
|
|
298
|
-
finishReason,
|
|
299
|
-
partial: false
|
|
300
|
-
};
|
|
301
320
|
}
|
|
302
|
-
|
|
321
|
+
yield* this.strategy.processResponse(llmResponse);
|
|
322
|
+
}
|
|
323
|
+
close() {
|
|
324
|
+
var _a, _b, _c;
|
|
325
|
+
const finalParts = this.strategy.close();
|
|
326
|
+
const hasMetadata = this.usageMetadata !== void 0 || this.groundingMetadata !== void 0 || this.citationMetadata !== void 0;
|
|
327
|
+
if (!finalParts && !hasMetadata) {
|
|
328
|
+
return void 0;
|
|
329
|
+
}
|
|
330
|
+
const candidate = (_b = (_a = this.response) == null ? void 0 : _a.candidates) == null ? void 0 : _b[0];
|
|
331
|
+
const finishReason = (_c = this.finishReason) != null ? _c : candidate == null ? void 0 : candidate.finishReason;
|
|
332
|
+
return {
|
|
333
|
+
content: {
|
|
334
|
+
role: "model",
|
|
335
|
+
parts: finalParts != null ? finalParts : []
|
|
336
|
+
},
|
|
337
|
+
groundingMetadata: this.groundingMetadata,
|
|
338
|
+
citationMetadata: this.citationMetadata,
|
|
339
|
+
errorCode: finishReason === FinishReason.STOP ? void 0 : finishReason,
|
|
340
|
+
errorMessage: finishReason === FinishReason.STOP ? void 0 : candidate == null ? void 0 : candidate.finishMessage,
|
|
341
|
+
usageMetadata: this.usageMetadata,
|
|
342
|
+
finishReason,
|
|
343
|
+
partial: false
|
|
344
|
+
};
|
|
303
345
|
}
|
|
304
346
|
}
|
|
347
|
+
function isEmptyContentPart(part) {
|
|
348
|
+
return !part.functionCall && !part.functionResponse && !part.fileData && !part.inlineData && !part.executableCode && !part.codeExecutionResult && (!part.text || part.text === "");
|
|
349
|
+
}
|
|
305
350
|
export {
|
|
306
|
-
StreamingResponseAggregator
|
|
351
|
+
StreamingResponseAggregator,
|
|
352
|
+
isEmptyContentPart
|
|
307
353
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
/**
|
|
4
|
+
* @license
|
|
5
|
+
* Copyright 2026 Google LLC
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
import { getBooleanEnvVar } from "./env_aware_utils.js";
|
|
9
|
+
function getExpressModeApiKey(project, location, expressModeApiKey) {
|
|
10
|
+
if ((project || location) && expressModeApiKey) {
|
|
11
|
+
throw new Error(
|
|
12
|
+
"Cannot specify project or location and expressModeApiKey. Either use project and location, or just the expressModeApiKey."
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
if (getBooleanEnvVar("GOOGLE_GENAI_USE_VERTEXAI")) {
|
|
16
|
+
return expressModeApiKey || process.env.GOOGLE_API_KEY;
|
|
17
|
+
}
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
getExpressModeApiKey
|
|
22
|
+
};
|
package/dist/esm/version.js
CHANGED
|
@@ -16,11 +16,25 @@ export type A2AStreamEventData = Message | Task | TaskStatusUpdateEvent | TaskAr
|
|
|
16
16
|
/**
|
|
17
17
|
* Callback called before sending a request to the remote agent.
|
|
18
18
|
* Allows modifying the request parameters.
|
|
19
|
+
*
|
|
20
|
+
* @param ctx - The current invocation context, providing access to session
|
|
21
|
+
* state, agent metadata, and services.
|
|
22
|
+
* @param params - The A2A message send parameters that will be sent to the
|
|
23
|
+
* remote agent. Mutations to this object are reflected in the outgoing
|
|
24
|
+
* request.
|
|
25
|
+
* @returns A Promise or void. Returning a rejected Promise aborts the request.
|
|
19
26
|
*/
|
|
20
27
|
export type BeforeA2ARequestCallback = (ctx: InvocationContext, params: MessageSendParams) => Promise<void> | void;
|
|
21
28
|
/**
|
|
22
29
|
* Callback called after receiving a response from the remote agent.
|
|
23
30
|
* Allows inspecting or modifying the response.
|
|
31
|
+
*
|
|
32
|
+
* @param ctx - The current invocation context, providing access to session
|
|
33
|
+
* state, agent metadata, and services.
|
|
34
|
+
* @param resp - The raw A2A stream event data received from the remote agent,
|
|
35
|
+
* before conversion to an ADK event.
|
|
36
|
+
* @returns A Promise or void. Returning a rejected Promise stops further
|
|
37
|
+
* processing of the response.
|
|
24
38
|
*/
|
|
25
39
|
export type AfterA2ARequestCallback = (ctx: InvocationContext, resp: A2AStreamEventData) => Promise<void> | void;
|
|
26
40
|
/**
|
|
@@ -13,26 +13,51 @@ export interface UserFunctionCall {
|
|
|
13
13
|
contextId: string;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Returns a UserFunctionCall when the event at index
|
|
16
|
+
* Returns a UserFunctionCall when the event at `index` contains a
|
|
17
|
+
* FunctionResponse that can be traced back to a preceding FunctionCall event.
|
|
18
|
+
*
|
|
19
|
+
* @param session - The session whose event history to inspect.
|
|
20
|
+
* @param index - Index of the candidate event to examine.
|
|
21
|
+
* @returns The matching `UserFunctionCall`, or `undefined` if the event at
|
|
22
|
+
* `index` is not a user function-response event or has no preceding call.
|
|
17
23
|
*/
|
|
18
24
|
export declare function getUserFunctionCallAt(session: Session, index: number): UserFunctionCall | undefined;
|
|
19
25
|
/**
|
|
20
26
|
* Checks if an event contains a function call with the given ID.
|
|
27
|
+
*
|
|
28
|
+
* @param event - The event to inspect.
|
|
29
|
+
* @param callId - The function call ID to look for.
|
|
30
|
+
* @returns `true` if a part in the event has a matching `functionCall.id`.
|
|
21
31
|
*/
|
|
22
32
|
export declare function isFunctionCallEvent(event: AdkEvent, callId: string): boolean;
|
|
23
33
|
/**
|
|
24
34
|
* Finds the first part with a FunctionResponse and returns the call ID.
|
|
35
|
+
*
|
|
36
|
+
* @param event - The event to inspect.
|
|
37
|
+
* @returns The `id` of the first FunctionResponse part, or `undefined` if
|
|
38
|
+
* none is found.
|
|
25
39
|
*/
|
|
26
40
|
export declare function getFunctionResponseCallId(event: AdkEvent): string | undefined;
|
|
27
41
|
/**
|
|
28
|
-
* Returns content parts for all events not
|
|
29
|
-
*
|
|
42
|
+
* Returns A2A content parts for all events not yet seen by the remote agent,
|
|
43
|
+
* along with the A2A context ID found in the most recent remote agent event.
|
|
44
|
+
*
|
|
45
|
+
* @param ctx - The current invocation context, used to identify the remote
|
|
46
|
+
* agent's authored events.
|
|
47
|
+
* @param session - The local session whose event history to diff.
|
|
48
|
+
* @returns An object with the missing `parts` and an optional `contextId`.
|
|
30
49
|
*/
|
|
31
50
|
export declare function toMissingRemoteSessionParts(ctx: InvocationContext, session: Session): {
|
|
32
51
|
parts: A2APart[];
|
|
33
52
|
contextId?: string;
|
|
34
53
|
};
|
|
35
54
|
/**
|
|
36
|
-
* Wraps an agent event as a user message
|
|
55
|
+
* Wraps an agent event as a user message so it can be sent as context to a
|
|
56
|
+
* remote agent that only accepts user-role messages.
|
|
57
|
+
*
|
|
58
|
+
* @param ctx - The current invocation context.
|
|
59
|
+
* @param agentEvent - The agent-authored event to reframe as a user message.
|
|
60
|
+
* @returns A new event with `author: 'user'` whose parts summarise the
|
|
61
|
+
* original agent event's text, function calls, and function responses.
|
|
37
62
|
*/
|
|
38
63
|
export declare function presentAsUserMessage(ctx: InvocationContext, agentEvent: AdkEvent): AdkEvent;
|
|
@@ -8,6 +8,12 @@ import { Event as AdkEvent } from '../events/event.js';
|
|
|
8
8
|
import { A2AEvent } from './a2a_event.js';
|
|
9
9
|
/**
|
|
10
10
|
* Converts a session Event to an A2A Message.
|
|
11
|
+
*
|
|
12
|
+
* @param event - The ADK event to convert.
|
|
13
|
+
* @param appName - The name of the ADK application.
|
|
14
|
+
* @param userId - The ID of the current user.
|
|
15
|
+
* @param sessionId - The ID of the current session.
|
|
16
|
+
* @returns An A2A message with the event's parts and metadata.
|
|
11
17
|
*/
|
|
12
18
|
export declare function toA2AMessage(event: AdkEvent, { appName, userId, sessionId, }: {
|
|
13
19
|
appName: string;
|
|
@@ -15,6 +21,13 @@ export declare function toA2AMessage(event: AdkEvent, { appName, userId, session
|
|
|
15
21
|
sessionId: string;
|
|
16
22
|
}): Message;
|
|
17
23
|
/**
|
|
18
|
-
* Converts an A2A Event to
|
|
24
|
+
* Converts an A2A Event to an ADK Session Event.
|
|
25
|
+
*
|
|
26
|
+
* @param event - The A2A event to convert (message, task, artifact update, or
|
|
27
|
+
* status update).
|
|
28
|
+
* @param invocationId - The ADK invocation ID to attach to the resulting event.
|
|
29
|
+
* @param agentName - The name of the agent to use as the event author.
|
|
30
|
+
* @returns The converted ADK event, or `undefined` if the A2A event type
|
|
31
|
+
* produces no content.
|
|
19
32
|
*/
|
|
20
33
|
export declare function toAdkEvent(event: A2AEvent, invocationId: string, agentName: string): AdkEvent | undefined;
|
|
@@ -39,10 +39,19 @@ export declare enum AdkMetadataKeys {
|
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Creates ADK Event metadata from an A2A Event.
|
|
42
|
+
*
|
|
43
|
+
* @param a2aEvent - The A2A event to extract metadata from.
|
|
44
|
+
* @returns A record containing the ADK task ID and context ID keys.
|
|
42
45
|
*/
|
|
43
46
|
export declare function getAdkEventMetadata(a2aEvent: A2AEvent): Record<string, unknown>;
|
|
44
47
|
/**
|
|
45
48
|
* Creates A2A Event metadata from an ADK Event.
|
|
49
|
+
*
|
|
50
|
+
* @param adkEvent - The ADK event to extract metadata from.
|
|
51
|
+
* @param appName - The name of the ADK application.
|
|
52
|
+
* @param userId - The ID of the current user.
|
|
53
|
+
* @param sessionId - The ID of the current session.
|
|
54
|
+
* @returns A record of A2A metadata keys populated from the ADK event.
|
|
46
55
|
*/
|
|
47
56
|
export declare function getA2AEventMetadata(adkEvent: AdkEvent, { appName, userId, sessionId, }: {
|
|
48
57
|
appName: string;
|
|
@@ -51,6 +60,11 @@ export declare function getA2AEventMetadata(adkEvent: AdkEvent, { appName, userI
|
|
|
51
60
|
}): Record<string, unknown>;
|
|
52
61
|
/**
|
|
53
62
|
* Creates A2A Session metadata from ADK Event invocation metadata.
|
|
63
|
+
*
|
|
64
|
+
* @param appName - The name of the ADK application.
|
|
65
|
+
* @param userId - The ID of the current user.
|
|
66
|
+
* @param sessionId - The ID of the current session.
|
|
67
|
+
* @returns A record of A2A metadata keys for app name, user ID, and session ID.
|
|
54
68
|
*/
|
|
55
69
|
export declare function getA2ASessionMetadata({ appName, userId, sessionId, }: {
|
|
56
70
|
appName: string;
|
|
@@ -59,5 +73,9 @@ export declare function getA2ASessionMetadata({ appName, userId, sessionId, }: {
|
|
|
59
73
|
}): Record<string, unknown>;
|
|
60
74
|
/**
|
|
61
75
|
* Creates A2A Event metadata from ADK Event actions.
|
|
76
|
+
*
|
|
77
|
+
* @param actions - The ADK event actions to extract escalation and transfer
|
|
78
|
+
* metadata from.
|
|
79
|
+
* @returns A record with escalate and transfer-to-agent A2A metadata keys.
|
|
62
80
|
*/
|
|
63
81
|
export declare function getA2AEventMetadataFromActions(actions: AdkEventActions): Record<string, unknown>;
|
|
@@ -6,43 +6,88 @@
|
|
|
6
6
|
import { DataPart as A2ADataPart, FilePart as A2AFilePart, Part as A2APart, TextPart as A2ATextPart, Message } from '@a2a-js/sdk';
|
|
7
7
|
import { Content as GenAIContent, Part as GenAIPart } from '@google/genai';
|
|
8
8
|
/**
|
|
9
|
-
* Converts GenAI Parts to A2A Parts.
|
|
9
|
+
* Converts an array of GenAI Parts to A2A Parts.
|
|
10
|
+
*
|
|
11
|
+
* @param parts - The GenAI parts to convert. Defaults to an empty array.
|
|
12
|
+
* @param longRunningToolIDs - IDs of function calls that are long-running.
|
|
13
|
+
* @returns An array of A2A parts.
|
|
10
14
|
*/
|
|
11
15
|
export declare function toA2AParts(parts?: GenAIPart[], longRunningToolIDs?: string[]): A2APart[];
|
|
12
16
|
/**
|
|
13
|
-
* Converts a GenAI Part to
|
|
17
|
+
* Converts a single GenAI Part to the appropriate A2A Part type.
|
|
18
|
+
*
|
|
19
|
+
* @param part - The GenAI part to convert.
|
|
20
|
+
* @param longRunningToolIDs - IDs of function calls that are long-running.
|
|
21
|
+
* @returns The corresponding A2A part (text, file, or data).
|
|
14
22
|
*/
|
|
15
23
|
export declare function toA2APart(part: GenAIPart, longRunningToolIDs?: string[]): A2APart;
|
|
16
24
|
/**
|
|
17
25
|
* Converts a GenAI Text Part to an A2A Text Part.
|
|
26
|
+
*
|
|
27
|
+
* @param part - The GenAI part containing a text field.
|
|
28
|
+
* @returns An A2A text part, with thought metadata attached if applicable.
|
|
18
29
|
*/
|
|
19
30
|
export declare function toA2ATextPart(part: GenAIPart): A2APart;
|
|
20
31
|
/**
|
|
21
32
|
* Converts a GenAI File Part to an A2A File Part.
|
|
33
|
+
*
|
|
34
|
+
* @param part - The GenAI part containing `fileData` or `inlineData`.
|
|
35
|
+
* @returns An A2A file part with URI or bytes depending on the source.
|
|
36
|
+
* @throws {Error} If the part contains neither `fileData` nor `inlineData`.
|
|
22
37
|
*/
|
|
23
38
|
export declare function toA2AFilePart(part: GenAIPart): A2APart;
|
|
24
39
|
/**
|
|
25
|
-
* Converts a GenAI Data Part to an A2A Data Part.
|
|
40
|
+
* Converts a GenAI Data Part (function call/response or code) to an A2A Data Part.
|
|
41
|
+
*
|
|
42
|
+
* @param part - The GenAI part containing structured data.
|
|
43
|
+
* @param longRunningToolIDs - IDs of function calls that are long-running.
|
|
44
|
+
* @returns An A2A data part with the appropriate type metadata.
|
|
26
45
|
*/
|
|
27
46
|
export declare function toA2ADataPart(part: GenAIPart, longRunningToolIDs?: string[]): A2APart;
|
|
47
|
+
/**
|
|
48
|
+
* Converts an A2A Message to a GenAI Content object.
|
|
49
|
+
*
|
|
50
|
+
* @param a2aMessage - The A2A message to convert.
|
|
51
|
+
* @returns A GenAI user or model content object based on the message role.
|
|
52
|
+
*/
|
|
28
53
|
export declare function toGenAIContent(a2aMessage: Message): GenAIContent;
|
|
29
54
|
/**
|
|
30
|
-
* Converts an A2A
|
|
55
|
+
* Converts an array of A2A Parts to GenAI Parts.
|
|
56
|
+
*
|
|
57
|
+
* @param a2aParts - The A2A parts to convert.
|
|
58
|
+
* @returns An array of GenAI parts.
|
|
31
59
|
*/
|
|
32
60
|
export declare function toGenAIParts(a2aParts: A2APart[]): GenAIPart[];
|
|
33
61
|
/**
|
|
34
|
-
* Converts
|
|
62
|
+
* Converts a single A2A Part to the appropriate GenAI Part type.
|
|
63
|
+
*
|
|
64
|
+
* @param a2aPart - The A2A part to convert.
|
|
65
|
+
* @returns The corresponding GenAI part.
|
|
66
|
+
* @throws {Error} If the A2A part has an unrecognized `kind`.
|
|
35
67
|
*/
|
|
36
68
|
export declare function toGenAIPart(a2aPart: A2APart): GenAIPart;
|
|
37
69
|
/**
|
|
38
70
|
* Converts an A2A Text Part to a GenAI Part.
|
|
71
|
+
*
|
|
72
|
+
* @param a2aPart - The A2A text part to convert.
|
|
73
|
+
* @returns A GenAI part with `text` and optional `thought` flag.
|
|
39
74
|
*/
|
|
40
75
|
export declare function toGenAIPartText(a2aPart: A2ATextPart): GenAIPart;
|
|
41
76
|
/**
|
|
42
77
|
* Converts an A2A File Part to a GenAI Part.
|
|
78
|
+
*
|
|
79
|
+
* @param a2aPart - The A2A file part containing bytes or a URI.
|
|
80
|
+
* @returns A GenAI part with `inlineData` or `fileData` depending on the
|
|
81
|
+
* source, with optional video metadata attached.
|
|
82
|
+
* @throws {Error} If the file part contains neither bytes nor a URI.
|
|
43
83
|
*/
|
|
44
84
|
export declare function toGenAIPartFile(a2aPart: A2AFilePart): GenAIPart;
|
|
45
85
|
/**
|
|
46
|
-
* Converts an A2A Data Part to
|
|
86
|
+
* Converts an A2A Data Part to the appropriate GenAI Part.
|
|
87
|
+
*
|
|
88
|
+
* @param a2aPart - The A2A data part containing structured data and type metadata.
|
|
89
|
+
* @returns A GenAI part with the appropriate function call, function response,
|
|
90
|
+
* or code execution fields, falling back to a JSON text part if the type is
|
|
91
|
+
* unrecognized.
|
|
47
92
|
*/
|
|
48
93
|
export declare function toGenAIPartData(a2aPart: A2ADataPart): GenAIPart;
|