@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
|
@@ -70,7 +70,7 @@ class CodeExecutorContext {
|
|
|
70
70
|
* @return A list of input files in the code executor context.
|
|
71
71
|
*/
|
|
72
72
|
getInputFiles() {
|
|
73
|
-
if (!
|
|
73
|
+
if (!this.sessionState.has(INPUT_FILE_KEY)) {
|
|
74
74
|
return [];
|
|
75
75
|
}
|
|
76
76
|
return this.sessionState.get(INPUT_FILE_KEY);
|
|
@@ -80,13 +80,13 @@ class CodeExecutorContext {
|
|
|
80
80
|
* @param inputFiles The input files to add to the session state.
|
|
81
81
|
*/
|
|
82
82
|
addInputFiles(inputFiles) {
|
|
83
|
-
if (!
|
|
83
|
+
if (!this.sessionState.has(INPUT_FILE_KEY)) {
|
|
84
84
|
this.sessionState.set(INPUT_FILE_KEY, []);
|
|
85
85
|
}
|
|
86
86
|
this.sessionState.get(INPUT_FILE_KEY).push(...inputFiles);
|
|
87
87
|
}
|
|
88
88
|
clearInputFiles() {
|
|
89
|
-
if (
|
|
89
|
+
if (this.sessionState.has(INPUT_FILE_KEY)) {
|
|
90
90
|
this.sessionState.set(INPUT_FILE_KEY, []);
|
|
91
91
|
}
|
|
92
92
|
if (PROCESSED_FILE_NAMES_KEY in this.context) {
|
|
@@ -99,7 +99,7 @@ class CodeExecutorContext {
|
|
|
99
99
|
* @return The error count for the given invocation ID.
|
|
100
100
|
*/
|
|
101
101
|
getErrorCount(invocationId) {
|
|
102
|
-
if (!
|
|
102
|
+
if (!this.sessionState.has(ERROR_COUNT_KEY)) {
|
|
103
103
|
return 0;
|
|
104
104
|
}
|
|
105
105
|
return this.sessionState.get(ERROR_COUNT_KEY)[invocationId] || 0;
|
|
@@ -109,7 +109,7 @@ class CodeExecutorContext {
|
|
|
109
109
|
* @param invocationId The invocation ID to increment the error count for.
|
|
110
110
|
*/
|
|
111
111
|
incrementErrorCount(invocationId) {
|
|
112
|
-
if (!
|
|
112
|
+
if (!this.sessionState.has(ERROR_COUNT_KEY)) {
|
|
113
113
|
this.sessionState.set(ERROR_COUNT_KEY, {});
|
|
114
114
|
}
|
|
115
115
|
this.sessionState.get(ERROR_COUNT_KEY)[invocationId] = this.getErrorCount(invocationId) + 1;
|
|
@@ -119,7 +119,7 @@ class CodeExecutorContext {
|
|
|
119
119
|
* @param invocationId The invocation ID to reset the error count for.
|
|
120
120
|
*/
|
|
121
121
|
resetErrorCount(invocationId) {
|
|
122
|
-
if (!
|
|
122
|
+
if (!this.sessionState.has(ERROR_COUNT_KEY)) {
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
125
|
const errorCounts = this.sessionState.get(ERROR_COUNT_KEY);
|
|
@@ -141,7 +141,7 @@ class CodeExecutorContext {
|
|
|
141
141
|
resultStdout,
|
|
142
142
|
resultStderr
|
|
143
143
|
}) {
|
|
144
|
-
if (!
|
|
144
|
+
if (!this.sessionState.has(CODE_EXECUTION_RESULTS_KEY)) {
|
|
145
145
|
this.sessionState.set(CODE_EXECUTION_RESULTS_KEY, {});
|
|
146
146
|
}
|
|
147
147
|
const codeExecutionResults = this.sessionState.get(
|
package/dist/web/common.js
CHANGED
|
@@ -31,6 +31,7 @@ import { SequentialAgent, isSequentialAgent } from "./agents/sequential_agent.js
|
|
|
31
31
|
import { InMemoryArtifactService } from "./artifacts/in_memory_artifact_service.js";
|
|
32
32
|
import { AuthCredentialTypes } from "./auth/auth_credential.js";
|
|
33
33
|
import { AuthHandler } from "./auth/auth_handler.js";
|
|
34
|
+
import { AUTH_PREPROCESSOR, AuthPreprocessor } from "./auth/auth_preprocessor.js";
|
|
34
35
|
import { AuthProviderRegistry } from "./auth/auth_provider_registry.js";
|
|
35
36
|
import { OAuthGrantType } from "./auth/auth_schemes.js";
|
|
36
37
|
import { InMemoryCredentialService } from "./auth/credential_service/in_memory_credential_service.js";
|
|
@@ -64,6 +65,7 @@ import {
|
|
|
64
65
|
isBaseExampleProvider
|
|
65
66
|
} from "./examples/base_example_provider.js";
|
|
66
67
|
import { InMemoryMemoryService } from "./memory/in_memory_memory_service.js";
|
|
68
|
+
import { VertexAiMemoryBankService } from "./memory/vertex_ai_memory_bank_service.js";
|
|
67
69
|
import { ApigeeLlm } from "./models/apigee_llm.js";
|
|
68
70
|
import { BaseLlm, isBaseLlm } from "./models/base_llm.js";
|
|
69
71
|
import { Gemini, geminiInitParams } from "./models/google_llm.js";
|
|
@@ -90,6 +92,10 @@ import { BaseTool, isBaseTool } from "./tools/base_tool.js";
|
|
|
90
92
|
import { BaseToolset, isBaseToolset } from "./tools/base_toolset.js";
|
|
91
93
|
import { EXIT_LOOP, ExitLoopTool } from "./tools/exit_loop_tool.js";
|
|
92
94
|
import { FunctionTool, isFunctionTool } from "./tools/function_tool.js";
|
|
95
|
+
import {
|
|
96
|
+
GOOGLE_MAPS_GROUNDING,
|
|
97
|
+
GoogleMapsGroundingTool
|
|
98
|
+
} from "./tools/google_maps_grounding_tool.js";
|
|
93
99
|
import { GOOGLE_SEARCH, GoogleSearchTool } from "./tools/google_search_tool.js";
|
|
94
100
|
import {
|
|
95
101
|
LOAD_ARTIFACTS,
|
|
@@ -104,21 +110,39 @@ import {
|
|
|
104
110
|
import { ToolConfirmation } from "./tools/tool_confirmation.js";
|
|
105
111
|
import { URL_CONTEXT, UrlContextTool } from "./tools/url_context_tool.js";
|
|
106
112
|
import { VertexAiSearchTool } from "./tools/vertex_ai_search_tool.js";
|
|
113
|
+
import { VertexRagRetrievalTool } from "./tools/vertex_rag_retrieval_tool.js";
|
|
107
114
|
import { LogLevel, getLogger, setLogLevel, setLogger } from "./utils/logger.js";
|
|
108
|
-
import { isGemini2OrAbove } from "./utils/model_name.js";
|
|
115
|
+
import { isGemini2OrAbove, isGemini3xFlashLive } from "./utils/model_name.js";
|
|
109
116
|
import { zodObjectToSchema } from "./utils/simple_zod_to_json.js";
|
|
110
117
|
import { GoogleLLMVariant } from "./utils/variant_utils.js";
|
|
111
118
|
import { version } from "./version.js";
|
|
119
|
+
import { GCPSkillRegistry } from "./skills/gcp_skill_registry.js";
|
|
120
|
+
import {
|
|
121
|
+
loadAllSkillsInDir,
|
|
122
|
+
loadSkillFromDir,
|
|
123
|
+
loadSkillFromZipBuffer,
|
|
124
|
+
validateSkillDir
|
|
125
|
+
} from "./skills/loader.js";
|
|
112
126
|
import { ListSkillsTool } from "./tools/skill/list_skills_tool.js";
|
|
113
127
|
import { LoadSkillResourceTool } from "./tools/skill/load_skill_resource_tool.js";
|
|
114
128
|
import { LoadSkillTool } from "./tools/skill/load_skill_tool.js";
|
|
129
|
+
import { SearchSkillsTool } from "./tools/skill/search_skills_tool.js";
|
|
115
130
|
import { SkillToolset } from "./tools/skill/skill_toolset.js";
|
|
131
|
+
import { OpenApiSpecParser } from "./tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js";
|
|
132
|
+
import { OperationParser } from "./tools/openapi_tool/openapi_spec_parser/operation_parser.js";
|
|
133
|
+
import { ToolAuthHandler } from "./tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js";
|
|
134
|
+
import { OpenAPIToolset } from "./tools/openapi_tool/openapi_toolset.js";
|
|
135
|
+
import {
|
|
136
|
+
RestApiTool,
|
|
137
|
+
createRestApiTool
|
|
138
|
+
} from "./tools/openapi_tool/rest_api_tool.js";
|
|
116
139
|
export * from "./artifacts/base_artifact_service.js";
|
|
117
140
|
export * from "./features/feature_registry.js";
|
|
118
141
|
export * from "./memory/base_memory_service.js";
|
|
119
142
|
export * from "./sessions/base_session_service.js";
|
|
120
143
|
export * from "./tools/base_tool.js";
|
|
121
144
|
export {
|
|
145
|
+
AUTH_PREPROCESSOR,
|
|
122
146
|
ActiveStreamingTool,
|
|
123
147
|
LlmAgent as Agent,
|
|
124
148
|
AgentTool,
|
|
@@ -126,6 +150,7 @@ export {
|
|
|
126
150
|
ApigeeLlm,
|
|
127
151
|
AuthCredentialTypes,
|
|
128
152
|
AuthHandler,
|
|
153
|
+
AuthPreprocessor,
|
|
129
154
|
AuthProviderRegistry,
|
|
130
155
|
BaseAgent,
|
|
131
156
|
BaseCodeExecutor,
|
|
@@ -151,9 +176,12 @@ export {
|
|
|
151
176
|
ExitLoopTool,
|
|
152
177
|
FileContentEncoding,
|
|
153
178
|
FunctionTool,
|
|
179
|
+
GCPSkillRegistry,
|
|
180
|
+
GOOGLE_MAPS_GROUNDING,
|
|
154
181
|
GOOGLE_SEARCH,
|
|
155
182
|
Gemini,
|
|
156
183
|
GoogleLLMVariant,
|
|
184
|
+
GoogleMapsGroundingTool,
|
|
157
185
|
GoogleSearchTool,
|
|
158
186
|
InMemoryArtifactService,
|
|
159
187
|
InMemoryCredentialService,
|
|
@@ -180,6 +208,9 @@ export {
|
|
|
180
208
|
OAuth2CredentialExchanger,
|
|
181
209
|
OAuth2DiscoveryManager,
|
|
182
210
|
OAuthGrantType,
|
|
211
|
+
OpenAPIToolset,
|
|
212
|
+
OpenApiSpecParser,
|
|
213
|
+
OperationParser,
|
|
183
214
|
PRELOAD_MEMORY,
|
|
184
215
|
ParallelAgent,
|
|
185
216
|
PluginManager,
|
|
@@ -187,9 +218,11 @@ export {
|
|
|
187
218
|
PreloadMemoryTool,
|
|
188
219
|
REQUEST_CONFIRMATION_FUNCTION_CALL_NAME,
|
|
189
220
|
ReadonlyContext,
|
|
221
|
+
RestApiTool,
|
|
190
222
|
RoutedAgent,
|
|
191
223
|
RoutedLlm,
|
|
192
224
|
Runner,
|
|
225
|
+
SearchSkillsTool,
|
|
193
226
|
SecurityPlugin,
|
|
194
227
|
SequentialAgent,
|
|
195
228
|
SessionStateCredentialService,
|
|
@@ -197,13 +230,17 @@ export {
|
|
|
197
230
|
State,
|
|
198
231
|
StreamingMode,
|
|
199
232
|
TokenBasedContextCompactor,
|
|
233
|
+
ToolAuthHandler,
|
|
200
234
|
ToolConfirmation,
|
|
201
235
|
TruncatingContextCompactor,
|
|
202
236
|
URL_CONTEXT,
|
|
203
237
|
UrlContextTool,
|
|
238
|
+
VertexAiMemoryBankService,
|
|
204
239
|
VertexAiSearchTool,
|
|
240
|
+
VertexRagRetrievalTool,
|
|
205
241
|
createEvent,
|
|
206
242
|
createEventActions,
|
|
243
|
+
createRestApiTool,
|
|
207
244
|
createSession,
|
|
208
245
|
functionsExportedForTestingOnly,
|
|
209
246
|
geminiInitParams,
|
|
@@ -222,16 +259,21 @@ export {
|
|
|
222
259
|
isFinalResponse,
|
|
223
260
|
isFunctionTool,
|
|
224
261
|
isGemini2OrAbove,
|
|
262
|
+
isGemini3xFlashLive,
|
|
225
263
|
isLlmAgent,
|
|
226
264
|
isLoopAgent,
|
|
227
265
|
isParallelAgent,
|
|
228
266
|
isRoutedAgent,
|
|
229
267
|
isRunner,
|
|
230
268
|
isSequentialAgent,
|
|
269
|
+
loadAllSkillsInDir,
|
|
270
|
+
loadSkillFromDir,
|
|
271
|
+
loadSkillFromZipBuffer,
|
|
231
272
|
setLogLevel,
|
|
232
273
|
setLogger,
|
|
233
274
|
stringifyContent,
|
|
234
275
|
toStructuredEvents,
|
|
276
|
+
validateSkillDir,
|
|
235
277
|
version,
|
|
236
278
|
zodObjectToSchema
|
|
237
279
|
};
|
|
@@ -13,10 +13,21 @@ import {
|
|
|
13
13
|
import { stringifyContent } from "../../events/event.js";
|
|
14
14
|
const DEFAULT_PROMPT = "The following is a conversation history between a user and an AI agent. Please summarize the conversation, focusing on key information and decisions made, as well as any unresolved questions or tasks. The summary should be concise and capture the essence of the interaction.";
|
|
15
15
|
class LlmSummarizer {
|
|
16
|
+
/**
|
|
17
|
+
* @param options - Configuration specifying the LLM and optional prompt.
|
|
18
|
+
*/
|
|
16
19
|
constructor(options) {
|
|
17
20
|
this.llm = options.llm;
|
|
18
21
|
this.prompt = options.prompt || DEFAULT_PROMPT;
|
|
19
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Summarizes a list of events into a single {@link CompactedEvent} using the
|
|
25
|
+
* configured LLM.
|
|
26
|
+
*
|
|
27
|
+
* @param events - The events to summarize. Must be non-empty.
|
|
28
|
+
* @returns A promise resolving to the compacted representation.
|
|
29
|
+
* @throws {Error} If `events` is empty or the LLM returns no content.
|
|
30
|
+
*/
|
|
20
31
|
async summarize(events) {
|
|
21
32
|
var _a, _b, _c, _d, _e, _f;
|
|
22
33
|
if (events.length === 0) {
|
package/dist/web/events/event.js
CHANGED
|
@@ -38,7 +38,7 @@ function createEvent(params = {}) {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
function isFinalResponse(event) {
|
|
41
|
-
if (event.actions.skipSummarization || event.longRunningToolIds && event.longRunningToolIds.length > 0) {
|
|
41
|
+
if (event.actions.skipSummarization || event.longRunningToolIds && event.longRunningToolIds.length > 0 || event.actions.requestedAuthConfigs && Object.keys(event.actions.requestedAuthConfigs).length > 0) {
|
|
42
42
|
return true;
|
|
43
43
|
}
|
|
44
44
|
return getFunctionCalls(event).length === 0 && getFunctionResponses(event).length === 0 && !event.partial && !hasTrailingCodeExecutionResult(event);
|
|
@@ -78,7 +78,7 @@ function stringifyContent(event) {
|
|
|
78
78
|
if (!((_a = event.content) == null ? void 0 : _a.parts)) {
|
|
79
79
|
return "";
|
|
80
80
|
}
|
|
81
|
-
return event.content.parts.map((part) => {
|
|
81
|
+
return event.content.parts.filter((part) => !part.thought).map((part) => {
|
|
82
82
|
var _a2;
|
|
83
83
|
return (_a2 = part.text) != null ? _a2 : "";
|
|
84
84
|
}).join("");
|
|
@@ -97,6 +97,7 @@ const PRESERVE_KEYS_CAMEL_CASE = [
|
|
|
97
97
|
"actions.requestedAuthConfigs",
|
|
98
98
|
"actions.requestedToolConfirmations",
|
|
99
99
|
"actions.customMetadata",
|
|
100
|
+
"customMetadata",
|
|
100
101
|
"content.parts.functionCall.args",
|
|
101
102
|
"content.parts.functionResponse.response"
|
|
102
103
|
];
|
|
@@ -106,6 +107,7 @@ const PRESERVE_KEYS_SNAKE_CASE = [
|
|
|
106
107
|
"actions.requested_auth_configs",
|
|
107
108
|
"actions.requested_tool_confirmations",
|
|
108
109
|
"actions.custom_metadata",
|
|
110
|
+
"custom_metadata",
|
|
109
111
|
"content.parts.function_call.args",
|
|
110
112
|
"content.parts.function_response.response"
|
|
111
113
|
];
|
package/dist/web/index.js
CHANGED
|
@@ -9,15 +9,21 @@ import { AGENT_CARD_PATH, RemoteA2AAgent } from "./a2a/a2a_remote_agent.js";
|
|
|
9
9
|
import { getA2AAgentCard } from "./a2a/agent_card.js";
|
|
10
10
|
import { A2AAgentExecutor } from "./a2a/agent_executor.js";
|
|
11
11
|
import { toA2a } from "./a2a/agent_to_a2a.js";
|
|
12
|
+
import { InvocationContext } from "./agents/invocation_context.js";
|
|
12
13
|
import { FileArtifactService } from "./artifacts/file_artifact_service.js";
|
|
13
14
|
import { GcsArtifactService } from "./artifacts/gcs_artifact_service.js";
|
|
14
15
|
import { getArtifactServiceFromUri } from "./artifacts/registry.js";
|
|
16
|
+
import {
|
|
17
|
+
AgentEngineSandboxCodeExecutor
|
|
18
|
+
} from "./code_executors/agent_engine_sandbox_code_executor.js";
|
|
19
|
+
import { CodeExecutionLanguage } from "./code_executors/code_execution_utils.js";
|
|
15
20
|
import {
|
|
16
21
|
UnsafeLocalCodeExecutor
|
|
17
22
|
} from "./code_executors/unsafe_local_code_executor.js";
|
|
18
23
|
export * from "./common.js";
|
|
19
24
|
import { DatabaseSessionService } from "./sessions/database_session_service.js";
|
|
20
25
|
import { getSessionServiceFromUri } from "./sessions/registry.js";
|
|
26
|
+
import { VertexAiSessionService } from "./sessions/vertex_ai_session_service.js";
|
|
21
27
|
import {
|
|
22
28
|
loadAllSkillsInDir,
|
|
23
29
|
loadSkillFromDir,
|
|
@@ -25,6 +31,7 @@ import {
|
|
|
25
31
|
} from "./skills/loader.js";
|
|
26
32
|
import { RunSkillInlineScriptTool } from "./tools/skill/run_skill_inline_script_tool.js";
|
|
27
33
|
import { RunSkillScriptTool } from "./tools/skill/run_skill_script_tool.js";
|
|
34
|
+
export * from "./integrations/agent_registry/agent_registry.js";
|
|
28
35
|
export * from "./telemetry/google_cloud.js";
|
|
29
36
|
export * from "./telemetry/setup.js";
|
|
30
37
|
export * from "./tools/mcp/mcp_session_manager.js";
|
|
@@ -33,13 +40,17 @@ export * from "./tools/mcp/mcp_toolset.js";
|
|
|
33
40
|
export {
|
|
34
41
|
A2AAgentExecutor,
|
|
35
42
|
AGENT_CARD_PATH,
|
|
43
|
+
AgentEngineSandboxCodeExecutor,
|
|
44
|
+
CodeExecutionLanguage,
|
|
36
45
|
DatabaseSessionService,
|
|
37
46
|
FileArtifactService,
|
|
38
47
|
GcsArtifactService,
|
|
48
|
+
InvocationContext,
|
|
39
49
|
RemoteA2AAgent,
|
|
40
50
|
RunSkillInlineScriptTool,
|
|
41
51
|
RunSkillScriptTool,
|
|
42
52
|
UnsafeLocalCodeExecutor,
|
|
53
|
+
VertexAiSessionService,
|
|
43
54
|
getA2AAgentCard,
|
|
44
55
|
getArtifactServiceFromUri,
|
|
45
56
|
getSessionServiceFromUri,
|
|
@@ -0,0 +1,333 @@
|
|
|
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 { GoogleAuth } from "google-auth-library";
|
|
9
|
+
import { RemoteA2AAgent } from "../../a2a/a2a_remote_agent.js";
|
|
10
|
+
import { logger } from "../../utils/logger.js";
|
|
11
|
+
import { AgentRegistrySingleMCPToolset } from "./agent_registry_mcp_toolset.js";
|
|
12
|
+
import { cleanName, isGoogleApi } from "./helpers.js";
|
|
13
|
+
import {
|
|
14
|
+
AGENT_REGISTRY_BASE_URL,
|
|
15
|
+
ProtocolType
|
|
16
|
+
} from "./types.js";
|
|
17
|
+
export * from "./agent_registry_mcp_toolset.js";
|
|
18
|
+
export * from "./helpers.js";
|
|
19
|
+
export * from "./types.js";
|
|
20
|
+
const TRANSPORT_MAPPING = {
|
|
21
|
+
"HTTP_JSON": "HTTP+JSON",
|
|
22
|
+
"JSONRPC": "JSONRPC",
|
|
23
|
+
"GRPC": "GRPC"
|
|
24
|
+
};
|
|
25
|
+
class AgentRegistry {
|
|
26
|
+
constructor(options) {
|
|
27
|
+
if (!options.projectId || !options.location) {
|
|
28
|
+
throw new Error("project_id and location must be provided");
|
|
29
|
+
}
|
|
30
|
+
this.projectId = options.projectId;
|
|
31
|
+
this.location = options.location;
|
|
32
|
+
this.basePath = "projects/".concat(this.projectId, "/locations/").concat(this.location);
|
|
33
|
+
this.headerProvider = options.headerProvider;
|
|
34
|
+
this.auth = new GoogleAuth({
|
|
35
|
+
scopes: ["https://www.googleapis.com/auth/cloud-platform"]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Resolves default Google Cloud credentials and returns standard headers.
|
|
40
|
+
* Automatically caches, fetches, and handles refreshing expired OAuth tokens.
|
|
41
|
+
* Injects the billing/quota project identifier `x-goog-user-project` if present.
|
|
42
|
+
*/
|
|
43
|
+
async getAuthHeaders() {
|
|
44
|
+
try {
|
|
45
|
+
const client = await this.auth.getClient();
|
|
46
|
+
const headers = await client.getRequestHeaders(
|
|
47
|
+
"https://agentregistry.googleapis.com"
|
|
48
|
+
);
|
|
49
|
+
const authHeaders = {};
|
|
50
|
+
const rawHeaders = headers;
|
|
51
|
+
const authKey = Object.keys(rawHeaders).find(
|
|
52
|
+
(k) => k.toLowerCase() === "authorization"
|
|
53
|
+
);
|
|
54
|
+
let token = authKey ? rawHeaders[authKey] : void 0;
|
|
55
|
+
if (!token && client.credentials && client.credentials.access_token) {
|
|
56
|
+
token = "Bearer ".concat(client.credentials.access_token);
|
|
57
|
+
}
|
|
58
|
+
if (token) {
|
|
59
|
+
authHeaders["Authorization"] = token;
|
|
60
|
+
}
|
|
61
|
+
authHeaders["Content-Type"] = "application/json";
|
|
62
|
+
const quotaProjectId = client.quotaProjectId || this.auth.quotaProjectId;
|
|
63
|
+
if (quotaProjectId) {
|
|
64
|
+
authHeaders["x-goog-user-project"] = quotaProjectId;
|
|
65
|
+
}
|
|
66
|
+
return authHeaders;
|
|
67
|
+
} catch (err) {
|
|
68
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
69
|
+
throw new Error("Failed to refresh Google Cloud credentials: ".concat(msg));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Helper function to execute HTTP GET requests against the Agent Registry API.
|
|
74
|
+
* Handles path resolution, search query params compilation, and auth headers fetching.
|
|
75
|
+
*/
|
|
76
|
+
async makeRequest(path, params) {
|
|
77
|
+
let url;
|
|
78
|
+
if (path.startsWith("projects/")) {
|
|
79
|
+
url = "".concat(AGENT_REGISTRY_BASE_URL, "/").concat(path);
|
|
80
|
+
} else {
|
|
81
|
+
url = "".concat(AGENT_REGISTRY_BASE_URL, "/").concat(this.basePath, "/").concat(path);
|
|
82
|
+
}
|
|
83
|
+
if (params && Object.keys(params).length > 0) {
|
|
84
|
+
const searchParams = new URLSearchParams(params);
|
|
85
|
+
url += "?".concat(searchParams.toString());
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
const headers = await this.getAuthHeaders();
|
|
89
|
+
const res = await fetch(url, {
|
|
90
|
+
method: "GET",
|
|
91
|
+
headers
|
|
92
|
+
});
|
|
93
|
+
if (!res.ok) {
|
|
94
|
+
const text = await res.text();
|
|
95
|
+
throw new Error(
|
|
96
|
+
"API request failed with status ".concat(res.status, ": ").concat(text)
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
return await res.json();
|
|
100
|
+
} catch (err) {
|
|
101
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
102
|
+
if (msg.includes("API request failed")) {
|
|
103
|
+
throw err;
|
|
104
|
+
}
|
|
105
|
+
throw new Error("API request failed: ".concat(msg));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Parses connection interfaces list from registry metadata and returns the first match
|
|
110
|
+
* corresponding to requested protocol types and binding options.
|
|
111
|
+
*/
|
|
112
|
+
getConnectionUri(resourceDetails, filters) {
|
|
113
|
+
const protocols = [];
|
|
114
|
+
if (resourceDetails.protocols) {
|
|
115
|
+
protocols.push(...resourceDetails.protocols);
|
|
116
|
+
}
|
|
117
|
+
if (resourceDetails.interfaces) {
|
|
118
|
+
protocols.push({ interfaces: resourceDetails.interfaces });
|
|
119
|
+
}
|
|
120
|
+
for (const p of protocols) {
|
|
121
|
+
if ((filters == null ? void 0 : filters.protocolType) && p.type !== filters.protocolType) {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const protocolVersion = p.protocolVersion;
|
|
125
|
+
const interfaces = p.interfaces || [];
|
|
126
|
+
for (const i of interfaces) {
|
|
127
|
+
const mappedBinding = i.protocolBinding ? TRANSPORT_MAPPING[i.protocolBinding] : void 0;
|
|
128
|
+
if ((filters == null ? void 0 : filters.protocolBinding) && mappedBinding !== filters.protocolBinding) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (i.url) {
|
|
132
|
+
return { url: i.url, protocolVersion, protocolBinding: mappedBinding };
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return {};
|
|
137
|
+
}
|
|
138
|
+
// --- MCP Server Methods ---
|
|
139
|
+
async listMcpServers(options) {
|
|
140
|
+
const params = {};
|
|
141
|
+
if (options == null ? void 0 : options.filterStr) {
|
|
142
|
+
params["filter"] = options.filterStr;
|
|
143
|
+
}
|
|
144
|
+
if (options == null ? void 0 : options.pageSize) {
|
|
145
|
+
params["pageSize"] = String(options.pageSize);
|
|
146
|
+
}
|
|
147
|
+
if (options == null ? void 0 : options.pageToken) {
|
|
148
|
+
params["pageToken"] = options.pageToken;
|
|
149
|
+
}
|
|
150
|
+
return this.makeRequest("mcpServers", params);
|
|
151
|
+
}
|
|
152
|
+
async getMcpServer(name) {
|
|
153
|
+
return this.makeRequest(name);
|
|
154
|
+
}
|
|
155
|
+
async getMcpToolset(mcpServerName, options) {
|
|
156
|
+
var _a, _b;
|
|
157
|
+
const serverDetails = await this.getMcpServer(mcpServerName);
|
|
158
|
+
const name = cleanName(serverDetails.displayName || mcpServerName);
|
|
159
|
+
const mcpServerId = serverDetails.mcpServerId;
|
|
160
|
+
let endpointUri = this.getConnectionUri(serverDetails, {
|
|
161
|
+
protocolBinding: "JSONRPC"
|
|
162
|
+
}).url;
|
|
163
|
+
if (!endpointUri) {
|
|
164
|
+
endpointUri = this.getConnectionUri(serverDetails, {
|
|
165
|
+
protocolBinding: "HTTP+JSON"
|
|
166
|
+
}).url;
|
|
167
|
+
}
|
|
168
|
+
if (!endpointUri) {
|
|
169
|
+
throw new Error(
|
|
170
|
+
"MCP Server endpoint URI not found for: ".concat(mcpServerName)
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
let authScheme = options == null ? void 0 : options.authScheme;
|
|
174
|
+
if (mcpServerId && !authScheme) {
|
|
175
|
+
try {
|
|
176
|
+
const bindingsData = await this.makeRequest("bindings");
|
|
177
|
+
const bindings = bindingsData.bindings || [];
|
|
178
|
+
for (const b of bindings) {
|
|
179
|
+
const targetId = ((_a = b.target) == null ? void 0 : _a.identifier) || "";
|
|
180
|
+
if (targetId.endsWith(mcpServerId)) {
|
|
181
|
+
const authProvider = (_b = b.authProviderBinding) == null ? void 0 : _b.authProvider;
|
|
182
|
+
if (authProvider) {
|
|
183
|
+
authScheme = {
|
|
184
|
+
type: "gcpAuthProviderScheme",
|
|
185
|
+
name: authProvider,
|
|
186
|
+
continueUri: options == null ? void 0 : options.continueUri
|
|
187
|
+
};
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
} catch (err) {
|
|
193
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
194
|
+
logger.warn(
|
|
195
|
+
"Failed to fetch bindings for MCP Server ".concat(mcpServerName, ": ").concat(msg)
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const connectionParams = {
|
|
200
|
+
type: "StreamableHTTPConnectionParams",
|
|
201
|
+
url: endpointUri
|
|
202
|
+
};
|
|
203
|
+
const combinedHeaderProvider = async (context) => {
|
|
204
|
+
const headers = {};
|
|
205
|
+
if (!authScheme && !(options == null ? void 0 : options.authCredential) && isGoogleApi(endpointUri)) {
|
|
206
|
+
Object.assign(headers, await this.getAuthHeaders());
|
|
207
|
+
}
|
|
208
|
+
if (this.headerProvider && context) {
|
|
209
|
+
Object.assign(headers, this.headerProvider(context));
|
|
210
|
+
}
|
|
211
|
+
return headers;
|
|
212
|
+
};
|
|
213
|
+
return new AgentRegistrySingleMCPToolset({
|
|
214
|
+
destinationResourceId: mcpServerId,
|
|
215
|
+
connectionParams,
|
|
216
|
+
prefix: name,
|
|
217
|
+
headerProvider: combinedHeaderProvider,
|
|
218
|
+
authScheme,
|
|
219
|
+
authCredential: options == null ? void 0 : options.authCredential
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
// --- Endpoint Methods ---
|
|
223
|
+
async listEndpoints(options) {
|
|
224
|
+
const params = {};
|
|
225
|
+
if (options == null ? void 0 : options.filterStr) {
|
|
226
|
+
params["filter"] = options.filterStr;
|
|
227
|
+
}
|
|
228
|
+
if (options == null ? void 0 : options.pageSize) {
|
|
229
|
+
params["pageSize"] = String(options.pageSize);
|
|
230
|
+
}
|
|
231
|
+
if (options == null ? void 0 : options.pageToken) {
|
|
232
|
+
params["pageToken"] = options.pageToken;
|
|
233
|
+
}
|
|
234
|
+
return this.makeRequest("endpoints", params);
|
|
235
|
+
}
|
|
236
|
+
async getEndpoint(name) {
|
|
237
|
+
return this.makeRequest(name);
|
|
238
|
+
}
|
|
239
|
+
async getModelName(endpointName) {
|
|
240
|
+
const endpointDetails = await this.getEndpoint(endpointName);
|
|
241
|
+
const { url } = this.getConnectionUri(endpointDetails);
|
|
242
|
+
if (!url) {
|
|
243
|
+
throw new Error("Connection URI not found for endpoint: ".concat(endpointName));
|
|
244
|
+
}
|
|
245
|
+
const uri = url.replace(/:\w+$/, "");
|
|
246
|
+
if (uri.startsWith("projects/")) {
|
|
247
|
+
return uri;
|
|
248
|
+
}
|
|
249
|
+
const match = uri.match(/(projects\/.+)/);
|
|
250
|
+
if (match) {
|
|
251
|
+
return match[1];
|
|
252
|
+
}
|
|
253
|
+
return uri;
|
|
254
|
+
}
|
|
255
|
+
// --- Agent Methods ---
|
|
256
|
+
async listAgents(options) {
|
|
257
|
+
const params = {};
|
|
258
|
+
if (options == null ? void 0 : options.filterStr) {
|
|
259
|
+
params["filter"] = options.filterStr;
|
|
260
|
+
}
|
|
261
|
+
if (options == null ? void 0 : options.pageSize) {
|
|
262
|
+
params["pageSize"] = String(options.pageSize);
|
|
263
|
+
}
|
|
264
|
+
if (options == null ? void 0 : options.pageToken) {
|
|
265
|
+
params["pageToken"] = options.pageToken;
|
|
266
|
+
}
|
|
267
|
+
return this.makeRequest("agents", params);
|
|
268
|
+
}
|
|
269
|
+
async getAgentInfo(name) {
|
|
270
|
+
return this.makeRequest(name);
|
|
271
|
+
}
|
|
272
|
+
async getRemoteA2AAgent(agentName, options) {
|
|
273
|
+
const agentInfo = await this.getAgentInfo(agentName);
|
|
274
|
+
const card = agentInfo.card || {};
|
|
275
|
+
const cardContent = card.content;
|
|
276
|
+
if (card.type === "A2A_AGENT_CARD" && cardContent) {
|
|
277
|
+
const agentCard2 = cardContent;
|
|
278
|
+
const name2 = cleanName(agentCard2.name);
|
|
279
|
+
return new RemoteA2AAgent({
|
|
280
|
+
name: name2,
|
|
281
|
+
agentCard: agentCard2,
|
|
282
|
+
description: agentCard2.description,
|
|
283
|
+
client: options == null ? void 0 : options.client,
|
|
284
|
+
clientFactory: options == null ? void 0 : options.clientFactory
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
const name = cleanName(agentInfo.displayName || agentName);
|
|
288
|
+
const description = agentInfo.description || "";
|
|
289
|
+
const version = agentInfo.version || "";
|
|
290
|
+
const { url, protocolVersion, protocolBinding } = this.getConnectionUri(
|
|
291
|
+
agentInfo,
|
|
292
|
+
{
|
|
293
|
+
protocolType: ProtocolType.A2A_AGENT
|
|
294
|
+
}
|
|
295
|
+
);
|
|
296
|
+
if (!url) {
|
|
297
|
+
throw new Error("A2A connection URI not found for Agent: ".concat(agentName));
|
|
298
|
+
}
|
|
299
|
+
const skills = (agentInfo.skills || []).map(
|
|
300
|
+
(s) => ({
|
|
301
|
+
id: s.id,
|
|
302
|
+
name: s.name,
|
|
303
|
+
description: s.description || "",
|
|
304
|
+
tags: s.tags || [],
|
|
305
|
+
examples: s.examples || []
|
|
306
|
+
})
|
|
307
|
+
);
|
|
308
|
+
const agentCard = {
|
|
309
|
+
name,
|
|
310
|
+
description,
|
|
311
|
+
version,
|
|
312
|
+
preferredTransport: protocolBinding || "HTTP+JSON",
|
|
313
|
+
protocolVersion: protocolVersion || "0.3.0",
|
|
314
|
+
url,
|
|
315
|
+
skills,
|
|
316
|
+
capabilities: {
|
|
317
|
+
streaming: false
|
|
318
|
+
},
|
|
319
|
+
defaultInputModes: ["text"],
|
|
320
|
+
defaultOutputModes: ["text"]
|
|
321
|
+
};
|
|
322
|
+
return new RemoteA2AAgent({
|
|
323
|
+
name,
|
|
324
|
+
agentCard,
|
|
325
|
+
description,
|
|
326
|
+
client: options == null ? void 0 : options.client,
|
|
327
|
+
clientFactory: options == null ? void 0 : options.clientFactory
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
export {
|
|
332
|
+
AgentRegistry
|
|
333
|
+
};
|