@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
|
@@ -38,6 +38,7 @@ module.exports = __toCommonJS(skill_toolset_exports);
|
|
|
38
38
|
var import_llm_request = require("../../models/llm_request.js");
|
|
39
39
|
var import_prompt = require("../../skills/prompt.js");
|
|
40
40
|
var import_experimental = require("../../utils/experimental.js");
|
|
41
|
+
var import_logger = require("../../utils/logger.js");
|
|
41
42
|
var import_base_tool = require("../base_tool.js");
|
|
42
43
|
var import_base_toolset = require("../base_toolset.js");
|
|
43
44
|
var import_list_skills_tool = require("./list_skills_tool.js");
|
|
@@ -45,6 +46,7 @@ var import_load_skill_resource_tool = require("./load_skill_resource_tool.js");
|
|
|
45
46
|
var import_load_skill_tool = require("./load_skill_tool.js");
|
|
46
47
|
var import_run_skill_inline_script_tool = require("./run_skill_inline_script_tool.js");
|
|
47
48
|
var import_run_skill_script_tool = require("./run_skill_script_tool.js");
|
|
49
|
+
var import_search_skills_tool = require("./search_skills_tool.js");
|
|
48
50
|
/**
|
|
49
51
|
* @license
|
|
50
52
|
* Copyright 2026 Google LLC
|
|
@@ -69,9 +71,11 @@ let SkillToolset = class extends import_base_toolset.BaseToolset {
|
|
|
69
71
|
constructor(skills, options = {}) {
|
|
70
72
|
super([], "adk_skill_toolset");
|
|
71
73
|
this.toolCache = /* @__PURE__ */ new Map();
|
|
74
|
+
this.fetchedSkillCache = /* @__PURE__ */ new Map();
|
|
72
75
|
this.skills = Array.isArray(skills) ? Object.fromEntries(skills.map((s) => [s.frontmatter.name, s])) : skills;
|
|
73
76
|
this.codeExecutor = options.codeExecutor;
|
|
74
77
|
this.additionalTools = options.additionalTools || [];
|
|
78
|
+
this.registry = options.registry;
|
|
75
79
|
this.tools = [
|
|
76
80
|
new import_list_skills_tool.ListSkillsTool(this),
|
|
77
81
|
new import_load_skill_tool.LoadSkillTool(this),
|
|
@@ -79,24 +83,55 @@ let SkillToolset = class extends import_base_toolset.BaseToolset {
|
|
|
79
83
|
new import_run_skill_script_tool.RunSkillScriptTool(this),
|
|
80
84
|
new import_run_skill_inline_script_tool.RunSkillInlineScriptTool(this)
|
|
81
85
|
];
|
|
86
|
+
if (this.registry) {
|
|
87
|
+
this.tools.push(new import_search_skills_tool.SearchSkillsTool(this));
|
|
88
|
+
}
|
|
82
89
|
}
|
|
83
90
|
async getTools(context) {
|
|
84
91
|
const dynamicTools = await this.resolveAdditionalTools(context);
|
|
85
92
|
return [...this.tools, ...dynamicTools];
|
|
86
93
|
}
|
|
87
94
|
async close() {
|
|
95
|
+
this.fetchedSkillCache.clear();
|
|
88
96
|
}
|
|
89
97
|
getSkill(name) {
|
|
90
98
|
return this.skills[name];
|
|
91
99
|
}
|
|
100
|
+
async getOrFetchSkill(name, invocationId) {
|
|
101
|
+
if (this.skills[name]) {
|
|
102
|
+
return this.skills[name];
|
|
103
|
+
}
|
|
104
|
+
if (!this.registry) {
|
|
105
|
+
return void 0;
|
|
106
|
+
}
|
|
107
|
+
const contextKey = invocationId || "default";
|
|
108
|
+
if (!this.fetchedSkillCache.has(contextKey)) {
|
|
109
|
+
this.fetchedSkillCache.set(contextKey, /* @__PURE__ */ new Map());
|
|
110
|
+
}
|
|
111
|
+
const cache = this.fetchedSkillCache.get(contextKey);
|
|
112
|
+
if (cache.has(name)) {
|
|
113
|
+
return cache.get(name);
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
const skill = await this.registry.getSkill(name);
|
|
117
|
+
cache.set(name, skill);
|
|
118
|
+
return skill;
|
|
119
|
+
} catch (e) {
|
|
120
|
+
import_logger.logger.warn(`Failed to fetch skill '${name}' from registry: ${e}`);
|
|
121
|
+
throw e;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
92
124
|
async processLlmRequest(toolContext, llmRequest) {
|
|
93
125
|
await super.processLlmRequest(toolContext, llmRequest);
|
|
94
126
|
const skills = Object.values(this.skills);
|
|
95
127
|
const skillsXml = (0, import_prompt.formatSkillsAsXml)(skills);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
128
|
+
const instructions = [DEFAULT_SKILL_SYSTEM_INSTRUCTION, skillsXml];
|
|
129
|
+
if (this.registry) {
|
|
130
|
+
instructions.push(
|
|
131
|
+
"\nIf the locally available skills are not sufficient to complete your task, you can use the `search_skills` tool to discover additional skills from the registry."
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
(0, import_llm_request.appendInstructions)(llmRequest, instructions);
|
|
100
135
|
}
|
|
101
136
|
async resolveAdditionalTools(context) {
|
|
102
137
|
if (!context) return [];
|
|
@@ -110,7 +145,7 @@ let SkillToolset = class extends import_base_toolset.BaseToolset {
|
|
|
110
145
|
}
|
|
111
146
|
const additionalToolNames = /* @__PURE__ */ new Set();
|
|
112
147
|
for (const skillName of activatedSkills) {
|
|
113
|
-
const skill = this.
|
|
148
|
+
const skill = await this.getOrFetchSkill(skillName, context.invocationId);
|
|
114
149
|
if (skill && skill.frontmatter.metadata) {
|
|
115
150
|
const tools = skill.frontmatter.metadata["adk_additional_tools"];
|
|
116
151
|
if (tools) {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var vertex_rag_retrieval_tool_exports = {};
|
|
26
|
+
__export(vertex_rag_retrieval_tool_exports, {
|
|
27
|
+
VertexRagRetrievalTool: () => VertexRagRetrievalTool
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(vertex_rag_retrieval_tool_exports);
|
|
30
|
+
var import_base_tool = require("./base_tool.js");
|
|
31
|
+
/**
|
|
32
|
+
* @license
|
|
33
|
+
* Copyright 2026 Google LLC
|
|
34
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
35
|
+
*/
|
|
36
|
+
class VertexRagRetrievalTool extends import_base_tool.BaseTool {
|
|
37
|
+
constructor(config) {
|
|
38
|
+
super({
|
|
39
|
+
name: "vertex_rag_retrieval",
|
|
40
|
+
description: "Vertex AI RAG Retrieval Tool"
|
|
41
|
+
});
|
|
42
|
+
this.vertexRagStore = config;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* This tool is executed server-side by the Vertex AI RAG Engine.
|
|
46
|
+
* Local execution is not required.
|
|
47
|
+
*/
|
|
48
|
+
runAsync() {
|
|
49
|
+
return Promise.resolve();
|
|
50
|
+
}
|
|
51
|
+
async processLlmRequest({
|
|
52
|
+
llmRequest
|
|
53
|
+
}) {
|
|
54
|
+
llmRequest.config = llmRequest.config || {};
|
|
55
|
+
llmRequest.config.tools = llmRequest.config.tools || [];
|
|
56
|
+
llmRequest.config.tools.push({
|
|
57
|
+
retrieval: { vertexRagStore: this.vertexRagStore }
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
VertexRagRetrievalTool
|
|
64
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var async_queue_exports = {};
|
|
26
|
+
__export(async_queue_exports, {
|
|
27
|
+
AsyncQueue: () => AsyncQueue
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(async_queue_exports);
|
|
30
|
+
/**
|
|
31
|
+
* @license
|
|
32
|
+
* Copyright 2026 Google LLC
|
|
33
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
34
|
+
*/
|
|
35
|
+
class AsyncQueue {
|
|
36
|
+
constructor() {
|
|
37
|
+
this.queue = [];
|
|
38
|
+
this.resolvers = [];
|
|
39
|
+
this.closed = false;
|
|
40
|
+
}
|
|
41
|
+
push(value) {
|
|
42
|
+
if (this.closed) return;
|
|
43
|
+
if (this.resolvers.length > 0) {
|
|
44
|
+
const { resolve } = this.resolvers.shift();
|
|
45
|
+
resolve({ value, done: false });
|
|
46
|
+
} else {
|
|
47
|
+
this.queue.push(value);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
error(err) {
|
|
51
|
+
this.errorVal = err;
|
|
52
|
+
while (this.resolvers.length > 0) {
|
|
53
|
+
const { reject } = this.resolvers.shift();
|
|
54
|
+
reject(err);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
close() {
|
|
58
|
+
this.closed = true;
|
|
59
|
+
while (this.resolvers.length > 0) {
|
|
60
|
+
const { resolve } = this.resolvers.shift();
|
|
61
|
+
resolve({ value: void 0, done: true });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
[Symbol.asyncIterator]() {
|
|
65
|
+
return {
|
|
66
|
+
next: () => {
|
|
67
|
+
if (this.errorVal) {
|
|
68
|
+
const err = this.errorVal;
|
|
69
|
+
this.errorVal = void 0;
|
|
70
|
+
return Promise.reject(err);
|
|
71
|
+
}
|
|
72
|
+
if (this.queue.length > 0) {
|
|
73
|
+
return Promise.resolve({ value: this.queue.shift(), done: false });
|
|
74
|
+
}
|
|
75
|
+
if (this.closed) {
|
|
76
|
+
return Promise.resolve({ value: void 0, done: true });
|
|
77
|
+
}
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
this.resolvers.push({ resolve, reject });
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {
|
|
87
|
+
AsyncQueue
|
|
88
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var case_utils_exports = {};
|
|
26
|
+
__export(case_utils_exports, {
|
|
27
|
+
camelCaseKeys: () => camelCaseKeys
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(case_utils_exports);
|
|
30
|
+
/**
|
|
31
|
+
* @license
|
|
32
|
+
* Copyright 2026 Google LLC
|
|
33
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
34
|
+
*/
|
|
35
|
+
function camelCaseKeys(val) {
|
|
36
|
+
if (Array.isArray(val)) {
|
|
37
|
+
return val.map(camelCaseKeys);
|
|
38
|
+
}
|
|
39
|
+
if (val !== null && typeof val === "object" && val.constructor === Object) {
|
|
40
|
+
const obj = val;
|
|
41
|
+
const newObj = {};
|
|
42
|
+
for (const key of Object.keys(obj)) {
|
|
43
|
+
const camelKey = key.replace(/_([a-z])/g, (_, g) => g.toUpperCase());
|
|
44
|
+
newObj[camelKey] = camelCaseKeys(obj[key]);
|
|
45
|
+
}
|
|
46
|
+
return newObj;
|
|
47
|
+
}
|
|
48
|
+
return val;
|
|
49
|
+
}
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
camelCaseKeys
|
|
53
|
+
});
|
|
@@ -42,6 +42,10 @@ function isBrowser() {
|
|
|
42
42
|
}
|
|
43
43
|
const UUID_MASK = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";
|
|
44
44
|
function randomUUID() {
|
|
45
|
+
var _a;
|
|
46
|
+
if ((_a = globalThis.crypto) == null ? void 0 : _a.randomUUID) {
|
|
47
|
+
return globalThis.crypto.randomUUID();
|
|
48
|
+
}
|
|
45
49
|
let uuid = "";
|
|
46
50
|
for (let i = 0; i < UUID_MASK.length; i++) {
|
|
47
51
|
const randomValue = Math.random() * 16 | 0;
|
|
@@ -34,6 +34,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
34
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
35
|
var file_utils_exports = {};
|
|
36
36
|
__export(file_utils_exports, {
|
|
37
|
+
EXTENSION_TO_MIME_TYPE: () => EXTENSION_TO_MIME_TYPE,
|
|
38
|
+
guessMimeType: () => guessMimeType,
|
|
37
39
|
materializeFiles: () => materializeFiles
|
|
38
40
|
});
|
|
39
41
|
module.exports = __toCommonJS(file_utils_exports);
|
|
@@ -88,7 +90,33 @@ async function materializeFiles(files, dir = process.cwd()) {
|
|
|
88
90
|
}
|
|
89
91
|
return createdFiles;
|
|
90
92
|
}
|
|
93
|
+
const EXTENSION_TO_MIME_TYPE = {
|
|
94
|
+
"pdf": "application/pdf",
|
|
95
|
+
"jpg": "image/jpeg",
|
|
96
|
+
"jpeg": "image/jpeg",
|
|
97
|
+
"png": "image/png",
|
|
98
|
+
"gif": "image/gif",
|
|
99
|
+
"csv": "text/csv",
|
|
100
|
+
"json": "application/json",
|
|
101
|
+
"xml": "application/xml",
|
|
102
|
+
"sh": "text/x-shellscript",
|
|
103
|
+
"bash": "text/x-shellscript",
|
|
104
|
+
"py": "text/x-python",
|
|
105
|
+
"js": "text/javascript",
|
|
106
|
+
"cjs": "text/javascript",
|
|
107
|
+
"mjs": "text/javascript",
|
|
108
|
+
"ts": "text/javascript",
|
|
109
|
+
"cts": "text/javascript",
|
|
110
|
+
"mts": "text/javascript"
|
|
111
|
+
};
|
|
112
|
+
function guessMimeType(filePath) {
|
|
113
|
+
var _a;
|
|
114
|
+
const ext = ((_a = filePath.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
|
|
115
|
+
return EXTENSION_TO_MIME_TYPE[ext] || "application/octet-stream";
|
|
116
|
+
}
|
|
91
117
|
// Annotate the CommonJS export names for ESM import in node:
|
|
92
118
|
0 && (module.exports = {
|
|
119
|
+
EXTENSION_TO_MIME_TYPE,
|
|
120
|
+
guessMimeType,
|
|
93
121
|
materializeFiles
|
|
94
122
|
});
|
|
@@ -108,6 +108,21 @@ function toGeminiSchema(mcpSchema) {
|
|
|
108
108
|
mcp.type = "array";
|
|
109
109
|
} else if (isNullable) {
|
|
110
110
|
mcp.type = "null";
|
|
111
|
+
} else if (mcp.enum) {
|
|
112
|
+
const enumTypes = new Set(mcp.enum.map((v) => typeof v));
|
|
113
|
+
if (enumTypes.size === 1) {
|
|
114
|
+
const jsType = [...enumTypes][0];
|
|
115
|
+
if (jsType === "string") mcp.type = "string";
|
|
116
|
+
else if (jsType === "number") mcp.type = "number";
|
|
117
|
+
else if (jsType === "boolean") mcp.type = "boolean";
|
|
118
|
+
}
|
|
119
|
+
} else if (mcp.const !== void 0) {
|
|
120
|
+
const jsType = typeof mcp.const;
|
|
121
|
+
let inferredType;
|
|
122
|
+
if (jsType === "string") inferredType = "string";
|
|
123
|
+
else if (jsType === "number") inferredType = "number";
|
|
124
|
+
else if (jsType === "boolean") inferredType = "boolean";
|
|
125
|
+
mcp = { ...mcp, type: inferredType, enum: [mcp.const] };
|
|
111
126
|
}
|
|
112
127
|
}
|
|
113
128
|
const geminiType = toGeminiType(mcp.type);
|
|
@@ -122,6 +137,9 @@ function toGeminiSchema(mcpSchema) {
|
|
|
122
137
|
if (mcp.description) {
|
|
123
138
|
geminiSchema.description = mcp.description;
|
|
124
139
|
}
|
|
140
|
+
if (mcp.enum) {
|
|
141
|
+
geminiSchema.enum = mcp.enum.map(String);
|
|
142
|
+
}
|
|
125
143
|
if (isNullable && mcp.type !== "null") {
|
|
126
144
|
geminiSchema.nullable = true;
|
|
127
145
|
}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var live_connection_utils_exports = {};
|
|
26
|
+
__export(live_connection_utils_exports, {
|
|
27
|
+
LiveResponseAggregator: () => LiveResponseAggregator
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(live_connection_utils_exports);
|
|
30
|
+
var import_model_name = require("./model_name.js");
|
|
31
|
+
/**
|
|
32
|
+
* @license
|
|
33
|
+
* Copyright 2026 Google LLC
|
|
34
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
35
|
+
*/
|
|
36
|
+
class LiveResponseAggregator {
|
|
37
|
+
constructor(modelVersion) {
|
|
38
|
+
this.modelVersion = modelVersion;
|
|
39
|
+
this.text = "";
|
|
40
|
+
this.isThought = false;
|
|
41
|
+
this.toolCallParts = [];
|
|
42
|
+
this.pendingGroundingMetadata = void 0;
|
|
43
|
+
this.inputTranscriptionText = "";
|
|
44
|
+
this.outputTranscriptionText = "";
|
|
45
|
+
}
|
|
46
|
+
*processMessage(message) {
|
|
47
|
+
if (message.usageMetadata) {
|
|
48
|
+
yield {
|
|
49
|
+
usageMetadata: message.usageMetadata,
|
|
50
|
+
...this.modelVersion ? { modelVersion: this.modelVersion } : {}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (message.serverContent) {
|
|
54
|
+
const serverContent = message.serverContent;
|
|
55
|
+
const content = serverContent.modelTurn;
|
|
56
|
+
if (serverContent.groundingMetadata) {
|
|
57
|
+
this.pendingGroundingMetadata = serverContent.groundingMetadata;
|
|
58
|
+
}
|
|
59
|
+
if (!(content && content.parts) && serverContent.groundingMetadata && !serverContent.turnComplete) {
|
|
60
|
+
yield {
|
|
61
|
+
groundingMetadata: serverContent.groundingMetadata,
|
|
62
|
+
...serverContent.interrupted !== void 0 ? { interrupted: serverContent.interrupted } : {},
|
|
63
|
+
...this.modelVersion ? { modelVersion: this.modelVersion } : {}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if (content && content.parts) {
|
|
67
|
+
const llmResponse = {
|
|
68
|
+
content,
|
|
69
|
+
...serverContent.interrupted !== void 0 ? { interrupted: serverContent.interrupted } : {},
|
|
70
|
+
...this.modelVersion ? { modelVersion: this.modelVersion } : {}
|
|
71
|
+
};
|
|
72
|
+
if (!serverContent.turnComplete && serverContent.groundingMetadata) {
|
|
73
|
+
llmResponse.groundingMetadata = serverContent.groundingMetadata;
|
|
74
|
+
}
|
|
75
|
+
const hasInlineData = content.parts.some((p) => p.inlineData);
|
|
76
|
+
for (const part of content.parts) {
|
|
77
|
+
if (part.text) {
|
|
78
|
+
const currentIsThought = !!part.thought;
|
|
79
|
+
if (this.text && currentIsThought !== this.isThought) {
|
|
80
|
+
yield this.buildFullTextResponse(this.text, this.isThought);
|
|
81
|
+
this.text = "";
|
|
82
|
+
this.isThought = false;
|
|
83
|
+
}
|
|
84
|
+
this.text += part.text;
|
|
85
|
+
this.isThought = currentIsThought;
|
|
86
|
+
llmResponse.partial = true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (this.text && !content.parts.some((p) => p.text) && !hasInlineData) {
|
|
90
|
+
yield this.buildFullTextResponse(this.text, this.isThought);
|
|
91
|
+
this.text = "";
|
|
92
|
+
this.isThought = false;
|
|
93
|
+
}
|
|
94
|
+
yield llmResponse;
|
|
95
|
+
}
|
|
96
|
+
if (serverContent.inputTranscription) {
|
|
97
|
+
if (serverContent.inputTranscription.text) {
|
|
98
|
+
this.inputTranscriptionText += serverContent.inputTranscription.text;
|
|
99
|
+
yield {
|
|
100
|
+
inputTranscription: {
|
|
101
|
+
text: serverContent.inputTranscription.text,
|
|
102
|
+
finished: false
|
|
103
|
+
},
|
|
104
|
+
partial: true,
|
|
105
|
+
...this.modelVersion ? { modelVersion: this.modelVersion } : {}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
if (serverContent.inputTranscription.finished) {
|
|
109
|
+
yield {
|
|
110
|
+
inputTranscription: {
|
|
111
|
+
text: this.inputTranscriptionText,
|
|
112
|
+
finished: true
|
|
113
|
+
},
|
|
114
|
+
partial: false,
|
|
115
|
+
...this.modelVersion ? { modelVersion: this.modelVersion } : {}
|
|
116
|
+
};
|
|
117
|
+
this.inputTranscriptionText = "";
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (serverContent.outputTranscription) {
|
|
121
|
+
if (serverContent.outputTranscription.text) {
|
|
122
|
+
this.outputTranscriptionText += serverContent.outputTranscription.text;
|
|
123
|
+
yield {
|
|
124
|
+
outputTranscription: {
|
|
125
|
+
text: serverContent.outputTranscription.text,
|
|
126
|
+
finished: false
|
|
127
|
+
},
|
|
128
|
+
partial: true,
|
|
129
|
+
...this.modelVersion ? { modelVersion: this.modelVersion } : {}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
if (serverContent.outputTranscription.finished) {
|
|
133
|
+
yield {
|
|
134
|
+
outputTranscription: {
|
|
135
|
+
text: this.outputTranscriptionText,
|
|
136
|
+
finished: true
|
|
137
|
+
},
|
|
138
|
+
partial: false,
|
|
139
|
+
...this.modelVersion ? { modelVersion: this.modelVersion } : {}
|
|
140
|
+
};
|
|
141
|
+
this.outputTranscriptionText = "";
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (serverContent.interrupted || serverContent.turnComplete || serverContent.generationComplete) {
|
|
145
|
+
if (this.inputTranscriptionText) {
|
|
146
|
+
yield {
|
|
147
|
+
inputTranscription: {
|
|
148
|
+
text: this.inputTranscriptionText,
|
|
149
|
+
finished: true
|
|
150
|
+
},
|
|
151
|
+
partial: false,
|
|
152
|
+
...this.modelVersion ? { modelVersion: this.modelVersion } : {}
|
|
153
|
+
};
|
|
154
|
+
this.inputTranscriptionText = "";
|
|
155
|
+
}
|
|
156
|
+
if (this.outputTranscriptionText) {
|
|
157
|
+
yield {
|
|
158
|
+
outputTranscription: {
|
|
159
|
+
text: this.outputTranscriptionText,
|
|
160
|
+
finished: true
|
|
161
|
+
},
|
|
162
|
+
partial: false,
|
|
163
|
+
...this.modelVersion ? { modelVersion: this.modelVersion } : {}
|
|
164
|
+
};
|
|
165
|
+
this.outputTranscriptionText = "";
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (serverContent.turnComplete) {
|
|
169
|
+
let gMetadataToYield = this.pendingGroundingMetadata;
|
|
170
|
+
if (this.text) {
|
|
171
|
+
yield this.buildFullTextResponse(
|
|
172
|
+
this.text,
|
|
173
|
+
this.isThought,
|
|
174
|
+
gMetadataToYield
|
|
175
|
+
);
|
|
176
|
+
this.text = "";
|
|
177
|
+
this.isThought = false;
|
|
178
|
+
gMetadataToYield = void 0;
|
|
179
|
+
}
|
|
180
|
+
if (this.toolCallParts.length > 0) {
|
|
181
|
+
yield {
|
|
182
|
+
content: { role: "model", parts: this.toolCallParts },
|
|
183
|
+
...this.modelVersion ? { modelVersion: this.modelVersion } : {}
|
|
184
|
+
};
|
|
185
|
+
this.toolCallParts = [];
|
|
186
|
+
}
|
|
187
|
+
const finalResponse = {
|
|
188
|
+
turnComplete: true,
|
|
189
|
+
...this.modelVersion ? { modelVersion: this.modelVersion } : {}
|
|
190
|
+
};
|
|
191
|
+
if (serverContent.interrupted !== void 0) {
|
|
192
|
+
finalResponse.interrupted = serverContent.interrupted;
|
|
193
|
+
}
|
|
194
|
+
const finalGrounding = serverContent.groundingMetadata || gMetadataToYield;
|
|
195
|
+
if (finalGrounding !== void 0 && finalGrounding !== null) {
|
|
196
|
+
finalResponse.groundingMetadata = finalGrounding;
|
|
197
|
+
}
|
|
198
|
+
yield finalResponse;
|
|
199
|
+
}
|
|
200
|
+
if (serverContent.interrupted) {
|
|
201
|
+
if (this.text) {
|
|
202
|
+
yield this.buildFullTextResponse(this.text, this.isThought);
|
|
203
|
+
this.text = "";
|
|
204
|
+
this.isThought = false;
|
|
205
|
+
} else {
|
|
206
|
+
yield {
|
|
207
|
+
interrupted: serverContent.interrupted,
|
|
208
|
+
...this.modelVersion ? { modelVersion: this.modelVersion } : {}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (message.toolCall) {
|
|
214
|
+
if (this.text) {
|
|
215
|
+
yield this.buildFullTextResponse(this.text, this.isThought);
|
|
216
|
+
this.text = "";
|
|
217
|
+
this.isThought = false;
|
|
218
|
+
}
|
|
219
|
+
if (message.toolCall.functionCalls) {
|
|
220
|
+
this.toolCallParts.push(
|
|
221
|
+
...message.toolCall.functionCalls.map((fc) => ({
|
|
222
|
+
functionCall: fc
|
|
223
|
+
}))
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
const isGemini3x = (0, import_model_name.isGemini3xFlashLive)(this.modelVersion);
|
|
227
|
+
if (isGemini3x && this.toolCallParts.length > 0) {
|
|
228
|
+
yield {
|
|
229
|
+
content: { role: "model", parts: this.toolCallParts },
|
|
230
|
+
...this.modelVersion ? { modelVersion: this.modelVersion } : {}
|
|
231
|
+
};
|
|
232
|
+
this.toolCallParts = [];
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (message.sessionResumptionUpdate) {
|
|
236
|
+
yield {
|
|
237
|
+
liveSessionResumptionUpdate: message.sessionResumptionUpdate,
|
|
238
|
+
...this.modelVersion ? { modelVersion: this.modelVersion } : {}
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
if (message.goAway) {
|
|
242
|
+
yield {
|
|
243
|
+
goAway: message.goAway,
|
|
244
|
+
...this.modelVersion ? { modelVersion: this.modelVersion } : {}
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Flushes any remaining aggregated components when the connection is closed.
|
|
250
|
+
*/
|
|
251
|
+
*close() {
|
|
252
|
+
if (this.toolCallParts.length > 0) {
|
|
253
|
+
yield {
|
|
254
|
+
content: { role: "model", parts: this.toolCallParts },
|
|
255
|
+
...this.modelVersion ? { modelVersion: this.modelVersion } : {}
|
|
256
|
+
};
|
|
257
|
+
this.toolCallParts = [];
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
buildFullTextResponse(text, isThought, groundingMetadata) {
|
|
261
|
+
const part = { text };
|
|
262
|
+
if (isThought) {
|
|
263
|
+
part.thought = true;
|
|
264
|
+
}
|
|
265
|
+
const response = {
|
|
266
|
+
content: {
|
|
267
|
+
role: "model",
|
|
268
|
+
parts: [part]
|
|
269
|
+
},
|
|
270
|
+
partial: false
|
|
271
|
+
};
|
|
272
|
+
if (groundingMetadata !== void 0 && groundingMetadata !== null) {
|
|
273
|
+
response.groundingMetadata = groundingMetadata;
|
|
274
|
+
}
|
|
275
|
+
if (this.modelVersion) {
|
|
276
|
+
response.modelVersion = this.modelVersion;
|
|
277
|
+
}
|
|
278
|
+
return response;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
282
|
+
0 && (module.exports = {
|
|
283
|
+
LiveResponseAggregator
|
|
284
|
+
});
|