@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
|
@@ -9,3 +9,5 @@ import { File } from '../code_executors/code_execution_utils.js';
|
|
|
9
9
|
* @param files The files to materialize.
|
|
10
10
|
*/
|
|
11
11
|
export declare function materializeFiles(files: File[], dir?: string): Promise<File[]>;
|
|
12
|
+
export declare const EXTENSION_TO_MIME_TYPE: Record<string, string>;
|
|
13
|
+
export declare function guessMimeType(filePath: string): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { LiveServerMessage } from '@google/genai';
|
|
7
|
+
import { LlmResponse } from '../models/llm_response.js';
|
|
8
|
+
/**
|
|
9
|
+
* Aggregator and mapper for Gemini Live WebSocket server messages.
|
|
10
|
+
*
|
|
11
|
+
* Translates incoming raw WebSocket server messages (push stream) into unified
|
|
12
|
+
* agent-consumable LlmResponse objects (pull stream), managing transcription buffers,
|
|
13
|
+
* grounding metadata, text segments, and tool calls.
|
|
14
|
+
*/
|
|
15
|
+
export declare class LiveResponseAggregator {
|
|
16
|
+
private readonly modelVersion?;
|
|
17
|
+
private text;
|
|
18
|
+
private isThought;
|
|
19
|
+
private toolCallParts;
|
|
20
|
+
private pendingGroundingMetadata;
|
|
21
|
+
private inputTranscriptionText;
|
|
22
|
+
private outputTranscriptionText;
|
|
23
|
+
constructor(modelVersion?: string | undefined);
|
|
24
|
+
processMessage(message: LiveServerMessage): Generator<LlmResponse, void, void>;
|
|
25
|
+
/**
|
|
26
|
+
* Flushes any remaining aggregated components when the connection is closed.
|
|
27
|
+
*/
|
|
28
|
+
close(): Generator<LlmResponse, void, void>;
|
|
29
|
+
private buildFullTextResponse;
|
|
30
|
+
}
|
|
@@ -32,6 +32,13 @@ export declare function isGemini1Model(modelString: string): boolean;
|
|
|
32
32
|
* @return true if it's a Gemini 2.x model, false otherwise.
|
|
33
33
|
*/
|
|
34
34
|
export declare function isGemini2OrAbove(modelString: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Check if the model is a Gemini 3.x Flash Live model.
|
|
37
|
+
*
|
|
38
|
+
* @param modelString Either a simple model name or path-based model name
|
|
39
|
+
* @return true if it's a Gemini 3.x Flash Live model, false otherwise.
|
|
40
|
+
*/
|
|
41
|
+
export declare function isGemini3xFlashLive(modelString: string | undefined): boolean;
|
|
35
42
|
/**
|
|
36
43
|
* Returns True when Gemini model-id validation should be bypassed.
|
|
37
44
|
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Copies a set of keys from one object to another.
|
|
8
|
+
*
|
|
9
|
+
* @param source The source object.
|
|
10
|
+
* @param targetKeys The keys to copy.
|
|
11
|
+
* @returns A new object with the specified keys copied from source.
|
|
12
|
+
*/
|
|
13
|
+
export declare function partialCopy<TDest extends object>(source: object, targetKeys: (keyof TDest)[]): TDest;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { GenerateContentResponse } from '@google/genai';
|
|
6
|
+
import { GenerateContentResponse, Part } from '@google/genai';
|
|
7
7
|
import { LlmResponse } from '../models/llm_response.js';
|
|
8
8
|
/**
|
|
9
9
|
* Aggregates partial streaming responses.
|
|
@@ -17,24 +17,14 @@ export declare class StreamingResponseAggregator {
|
|
|
17
17
|
private groundingMetadata?;
|
|
18
18
|
private citationMetadata?;
|
|
19
19
|
private response?;
|
|
20
|
-
private text;
|
|
21
|
-
private thoughtText;
|
|
22
|
-
private partsSequence;
|
|
23
|
-
private currentTextBuffer;
|
|
24
|
-
private currentTextIsThought?;
|
|
25
20
|
private finishReason?;
|
|
26
|
-
private
|
|
27
|
-
private
|
|
28
|
-
private currentFcId?;
|
|
29
|
-
private currentThoughtSignature?;
|
|
30
|
-
private lastThoughtSignature?;
|
|
21
|
+
private lastThoughtSignature;
|
|
22
|
+
private readonly strategy;
|
|
31
23
|
constructor(isProgressiveMode?: boolean);
|
|
32
|
-
private flushTextBufferToSequence;
|
|
33
|
-
private getValueFromPartialArg;
|
|
34
|
-
private setValueByJsonPath;
|
|
35
|
-
private flushFunctionCallToSequence;
|
|
36
|
-
private processStreamingFunctionCall;
|
|
37
|
-
private processFunctionCallPart;
|
|
38
24
|
processResponse(response: GenerateContentResponse): AsyncGenerator<LlmResponse, void, void>;
|
|
39
25
|
close(): LlmResponse | undefined;
|
|
40
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Checks if a response part has no meaningful content (empty text, no tool calls, etc.)
|
|
29
|
+
*/
|
|
30
|
+
export declare function isEmptyContentPart(part: Part): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Validates and returns the API key for Express Mode.
|
|
8
|
+
*
|
|
9
|
+
* @param project The project id.
|
|
10
|
+
* @param location The location.
|
|
11
|
+
* @param expressModeApiKey The API key for Express Mode.
|
|
12
|
+
* @returns The resolved API key or undefined.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getExpressModeApiKey(project?: string, location?: string, expressModeApiKey?: string): string | undefined;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -184,10 +184,40 @@ class BaseAgent {
|
|
|
184
184
|
this,
|
|
185
185
|
function() {
|
|
186
186
|
return __asyncGenerator(this, null, function* () {
|
|
187
|
+
var _a2, _b;
|
|
188
|
+
const context2 = this.createInvocationContext(parentContext);
|
|
189
|
+
const beforeAgentCallbackEvent = yield new __await(this.handleBeforeAgentCallback(context2));
|
|
190
|
+
if (beforeAgentCallbackEvent) {
|
|
191
|
+
yield beforeAgentCallbackEvent;
|
|
192
|
+
}
|
|
193
|
+
if (context2.endInvocation || ((_a2 = parentContext.abortSignal) == null ? void 0 : _a2.aborted)) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
try {
|
|
197
|
+
for (var iter = __forAwait(this.runLiveImpl(context2)), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
198
|
+
const event = temp.value;
|
|
199
|
+
yield event;
|
|
200
|
+
}
|
|
201
|
+
} catch (temp) {
|
|
202
|
+
error = [temp];
|
|
203
|
+
} finally {
|
|
204
|
+
try {
|
|
205
|
+
more && (temp = iter.return) && (yield new __await(temp.call(iter)));
|
|
206
|
+
} finally {
|
|
207
|
+
if (error)
|
|
208
|
+
throw error[0];
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (context2.endInvocation || ((_b = parentContext.abortSignal) == null ? void 0 : _b.aborted)) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const afterAgentCallbackEvent = yield new __await(this.handleAfterAgentCallback(context2));
|
|
215
|
+
if (afterAgentCallbackEvent) {
|
|
216
|
+
yield afterAgentCallbackEvent;
|
|
217
|
+
}
|
|
187
218
|
});
|
|
188
219
|
}
|
|
189
220
|
));
|
|
190
|
-
throw new Error("Live mode is not implemented yet.");
|
|
191
221
|
} finally {
|
|
192
222
|
span.end();
|
|
193
223
|
}
|
|
@@ -159,6 +159,8 @@ function buildResponseEvent(tool, functionResult, toolContext, invocationContext
|
|
|
159
159
|
let responseResult;
|
|
160
160
|
if (typeof functionResult !== "object" || functionResult == null) {
|
|
161
161
|
responseResult = { result: functionResult };
|
|
162
|
+
} else if (Array.isArray(functionResult)) {
|
|
163
|
+
responseResult = { results: functionResult };
|
|
162
164
|
} else {
|
|
163
165
|
responseResult = functionResult;
|
|
164
166
|
}
|
|
@@ -297,6 +299,8 @@ async function handleFunctionCallList({
|
|
|
297
299
|
functionResponse = { error: functionResponseError };
|
|
298
300
|
} else if (typeof functionResponse !== "object" || functionResponse == null) {
|
|
299
301
|
functionResponse = { result: functionResponse };
|
|
302
|
+
} else if (Array.isArray(functionResponse)) {
|
|
303
|
+
functionResponse = { results: functionResponse };
|
|
300
304
|
}
|
|
301
305
|
const functionResponseEvent = createEvent({
|
|
302
306
|
invocationId: invocationContext.invocationId,
|
|
@@ -6,50 +6,98 @@ const require = topLevelCreateRequire(import.meta.url);
|
|
|
6
6
|
* SPDX-License-Identifier: Apache-2.0
|
|
7
7
|
*/
|
|
8
8
|
import { State } from "../sessions/state.js";
|
|
9
|
-
|
|
9
|
+
const ARTIFACT_PREFIX = "artifact.";
|
|
10
|
+
async function resolveKey(key, isOptional, rawMatch, readonlyContext) {
|
|
10
11
|
const invocationContext = readonlyContext.invocationContext;
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
if (key.startsWith(ARTIFACT_PREFIX)) {
|
|
13
|
+
const fileName = key.substring(ARTIFACT_PREFIX.length);
|
|
14
|
+
if (invocationContext.artifactService === void 0) {
|
|
15
|
+
throw new Error("Artifact service is not initialized.");
|
|
16
|
+
}
|
|
17
|
+
const artifact = await invocationContext.artifactService.loadArtifact({
|
|
18
|
+
appName: invocationContext.session.appName,
|
|
19
|
+
userId: invocationContext.session.userId,
|
|
20
|
+
sessionId: invocationContext.session.id,
|
|
21
|
+
filename: fileName
|
|
22
|
+
});
|
|
23
|
+
if (!artifact) {
|
|
24
|
+
if (isOptional) {
|
|
25
|
+
return "";
|
|
26
|
+
}
|
|
27
|
+
throw new Error("Artifact ".concat(fileName, " not found."));
|
|
28
|
+
}
|
|
29
|
+
return String(artifact);
|
|
30
|
+
}
|
|
31
|
+
if (!isValidStateName(key)) {
|
|
32
|
+
return rawMatch;
|
|
33
|
+
}
|
|
34
|
+
if (key in invocationContext.session.state) {
|
|
35
|
+
return String(invocationContext.session.state[key]);
|
|
36
|
+
}
|
|
37
|
+
if (isOptional) {
|
|
38
|
+
return "";
|
|
39
|
+
}
|
|
40
|
+
throw new Error("Context variable not found: `".concat(key, "`."));
|
|
41
|
+
}
|
|
42
|
+
async function injectSessionState(template, readonlyContext) {
|
|
43
|
+
const pattern = /\{+[^{}]*}+/g;
|
|
44
|
+
const matches = Array.from(template.matchAll(pattern));
|
|
45
|
+
if (matches.length === 0) {
|
|
46
|
+
return template;
|
|
47
|
+
}
|
|
48
|
+
const parsedMatches = matches.map((match) => {
|
|
49
|
+
const raw = match[0];
|
|
50
|
+
let key = raw.replace(/^\{+/, "").replace(/\}+$/, "").trim();
|
|
13
51
|
const isOptional = key.endsWith("?");
|
|
14
52
|
if (isOptional) {
|
|
15
53
|
key = key.slice(0, -1);
|
|
16
54
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
55
|
+
const isValid = key.startsWith(ARTIFACT_PREFIX) || isValidStateName(key);
|
|
56
|
+
return {
|
|
57
|
+
raw,
|
|
58
|
+
key,
|
|
59
|
+
isOptional,
|
|
60
|
+
isValid,
|
|
61
|
+
index: match.index
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
const uniqueKeys = /* @__PURE__ */ new Map();
|
|
65
|
+
for (const pm of parsedMatches) {
|
|
66
|
+
if (!pm.isValid) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const existing = uniqueKeys.get(pm.key);
|
|
70
|
+
if (existing) {
|
|
71
|
+
if (existing.isOptional && !pm.isOptional) {
|
|
72
|
+
existing.isOptional = false;
|
|
21
73
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
74
|
+
} else {
|
|
75
|
+
uniqueKeys.set(pm.key, {
|
|
76
|
+
key: pm.key,
|
|
77
|
+
isOptional: pm.isOptional,
|
|
78
|
+
raw: pm.raw
|
|
27
79
|
});
|
|
28
|
-
if (!artifact) {
|
|
29
|
-
throw new Error("Artifact ".concat(fileName, " not found."));
|
|
30
|
-
}
|
|
31
|
-
return String(artifact);
|
|
32
|
-
}
|
|
33
|
-
if (!isValidStateName(key)) {
|
|
34
|
-
return match[0];
|
|
35
|
-
}
|
|
36
|
-
if (key in invocationContext.session.state) {
|
|
37
|
-
return String(invocationContext.session.state[key]);
|
|
38
80
|
}
|
|
39
|
-
if (isOptional) {
|
|
40
|
-
return "";
|
|
41
|
-
}
|
|
42
|
-
throw new Error("Context variable not found: `".concat(key, "`."));
|
|
43
81
|
}
|
|
44
|
-
const
|
|
82
|
+
const resolutions = /* @__PURE__ */ new Map();
|
|
83
|
+
for (const info of uniqueKeys.values()) {
|
|
84
|
+
resolutions.set(
|
|
85
|
+
info.key,
|
|
86
|
+
resolveKey(info.key, info.isOptional, info.raw, readonlyContext)
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
await Promise.all(resolutions.values());
|
|
45
90
|
const result = [];
|
|
46
91
|
let lastEnd = 0;
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
92
|
+
for (const pm of parsedMatches) {
|
|
93
|
+
result.push(template.slice(lastEnd, pm.index));
|
|
94
|
+
if (pm.isValid) {
|
|
95
|
+
const replacement = await resolutions.get(pm.key);
|
|
96
|
+
result.push(replacement);
|
|
97
|
+
} else {
|
|
98
|
+
result.push(pm.raw);
|
|
99
|
+
}
|
|
100
|
+
lastEnd = pm.index + pm.raw.length;
|
|
53
101
|
}
|
|
54
102
|
result.push(template.slice(lastEnd));
|
|
55
103
|
return result.join("");
|
|
@@ -46,7 +46,6 @@ class InvocationContext {
|
|
|
46
46
|
this.endInvocation = params.endInvocation || false;
|
|
47
47
|
this.transcriptionCache = params.transcriptionCache;
|
|
48
48
|
this.runConfig = params.runConfig;
|
|
49
|
-
this.liveRequestQueue = params.liveRequestQueue;
|
|
50
49
|
this.activeStreamingTools = params.activeStreamingTools;
|
|
51
50
|
this.pluginManager = params.pluginManager;
|
|
52
51
|
this.abortSignal = params.abortSignal;
|
|
@@ -71,10 +71,12 @@ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")])
|
|
|
71
71
|
*/
|
|
72
72
|
var _a, _b;
|
|
73
73
|
import { context, trace } from "@opentelemetry/api";
|
|
74
|
+
import { FunctionTool } from "../tools/function_tool.js";
|
|
74
75
|
import {
|
|
75
76
|
createEvent,
|
|
76
77
|
createNewEventId,
|
|
77
78
|
getFunctionCalls,
|
|
79
|
+
getFunctionResponses,
|
|
78
80
|
isFinalResponse
|
|
79
81
|
} from "../events/event.js";
|
|
80
82
|
import { isBaseLlm } from "../models/base_llm.js";
|
|
@@ -96,6 +98,7 @@ import {
|
|
|
96
98
|
handleFunctionCallsAsync,
|
|
97
99
|
populateClientFunctionCallId
|
|
98
100
|
} from "./functions.js";
|
|
101
|
+
import { AUTH_PREPROCESSOR } from "../auth/auth_preprocessor.js";
|
|
99
102
|
import { AGENT_TRANSFER_LLM_REQUEST_PROCESSOR } from "./processors/agent_transfer_llm_request_processor.js";
|
|
100
103
|
import { BASIC_LLM_REQUEST_PROCESSOR } from "./processors/basic_llm_request_processor.js";
|
|
101
104
|
import { CODE_EXECUTION_REQUEST_PROCESSOR } from "./processors/code_execution_request_processor.js";
|
|
@@ -142,6 +145,7 @@ class LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNATURE_SYMBOL, _b) {
|
|
|
142
145
|
this.codeExecutor = config.codeExecutor;
|
|
143
146
|
this.requestProcessors = (_g = config.requestProcessors) != null ? _g : [
|
|
144
147
|
BASIC_LLM_REQUEST_PROCESSOR,
|
|
148
|
+
AUTH_PREPROCESSOR,
|
|
145
149
|
IDENTITY_LLM_REQUEST_PROCESSOR,
|
|
146
150
|
INSTRUCTIONS_LLM_REQUEST_PROCESSOR,
|
|
147
151
|
REQUEST_CONFIRMATION_LLM_REQUEST_PROCESSOR,
|
|
@@ -368,9 +372,10 @@ class LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNATURE_SYMBOL, _b) {
|
|
|
368
372
|
}
|
|
369
373
|
runAsyncImpl(context2) {
|
|
370
374
|
return __asyncGenerator(this, null, function* () {
|
|
371
|
-
var _a2;
|
|
375
|
+
var _a2, _b2;
|
|
372
376
|
while (true) {
|
|
373
377
|
let lastEvent = void 0;
|
|
378
|
+
let stepHadToolCalls = false;
|
|
374
379
|
try {
|
|
375
380
|
for (var iter = __forAwait(this.runOneStepAsync(context2)), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
|
|
376
381
|
const event = temp.value;
|
|
@@ -378,6 +383,9 @@ class LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNATURE_SYMBOL, _b) {
|
|
|
378
383
|
return;
|
|
379
384
|
}
|
|
380
385
|
lastEvent = event;
|
|
386
|
+
if (getFunctionCalls(event).length > 0 || getFunctionResponses(event).length > 0) {
|
|
387
|
+
stepHadToolCalls = true;
|
|
388
|
+
}
|
|
381
389
|
this.maybeSaveOutputToState(event);
|
|
382
390
|
yield event;
|
|
383
391
|
}
|
|
@@ -391,7 +399,11 @@ class LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNATURE_SYMBOL, _b) {
|
|
|
391
399
|
throw error[0];
|
|
392
400
|
}
|
|
393
401
|
}
|
|
394
|
-
if (!lastEvent
|
|
402
|
+
if (!lastEvent) {
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
const isEmptyMetadataEvent = lastEvent.author === this.name && !lastEvent.partial && (!((_b2 = lastEvent.content) == null ? void 0 : _b2.parts) || lastEvent.content.parts.length === 0);
|
|
406
|
+
if (isFinalResponse(lastEvent) && !(isEmptyMetadataEvent && stepHadToolCalls)) {
|
|
395
407
|
break;
|
|
396
408
|
}
|
|
397
409
|
if (lastEvent.partial) {
|
|
@@ -431,6 +443,20 @@ class LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNATURE_SYMBOL, _b) {
|
|
|
431
443
|
// --------------------------------------------------------------------------
|
|
432
444
|
// #START LlmFlow Logic
|
|
433
445
|
// --------------------------------------------------------------------------
|
|
446
|
+
/**
|
|
447
|
+
* Runs the bidirectional (live) flow for this agent.
|
|
448
|
+
*
|
|
449
|
+
* Establishes a live connection to the model, drains the invocation's
|
|
450
|
+
* `liveRequestQueue` into the connection on a parallel task, and yields
|
|
451
|
+
* events derived from server messages until the queue closes, the model
|
|
452
|
+
* finishes, or an agent transfer occurs.
|
|
453
|
+
*
|
|
454
|
+
* If the live connection drops (network failure, server `goAway`) and a
|
|
455
|
+
* session resumption handle has been observed, the flow transparently
|
|
456
|
+
* reconnects using that handle up to {@link MAX_LIVE_RECONNECT_ATTEMPTS}
|
|
457
|
+
* times. Subsequent reconnects skip `sendHistory` because the server
|
|
458
|
+
* already holds the conversation state associated with the handle.
|
|
459
|
+
*/
|
|
434
460
|
// eslint-disable-next-line require-yield
|
|
435
461
|
runLiveFlow(_invocationContext) {
|
|
436
462
|
return __asyncGenerator(this, null, function* () {
|
|
@@ -469,13 +495,28 @@ class LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNATURE_SYMBOL, _b) {
|
|
|
469
495
|
}
|
|
470
496
|
}
|
|
471
497
|
}
|
|
472
|
-
|
|
498
|
+
const allTools = [...this.tools];
|
|
499
|
+
if (this.outputSchema && allTools.length > 0) {
|
|
500
|
+
const setModelResponseTool = new FunctionTool({
|
|
501
|
+
name: "set_model_response",
|
|
502
|
+
description: "Call this tool to submit your final response conforming to the output schema. Use this tool only when you have collected all the information and are ready to return the final answer.",
|
|
503
|
+
parameters: this.outputSchema,
|
|
504
|
+
execute: async (args, toolContext) => {
|
|
505
|
+
if (toolContext) {
|
|
506
|
+
toolContext.actions.skipSummarization = true;
|
|
507
|
+
}
|
|
508
|
+
return JSON.stringify(args);
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
allTools.push(setModelResponseTool);
|
|
512
|
+
}
|
|
513
|
+
for (const toolUnion of allTools) {
|
|
473
514
|
const toolContext = new Context({ invocationContext });
|
|
474
515
|
const tools = (yield new __await(convertToolUnionToTools(
|
|
475
516
|
toolUnion,
|
|
476
517
|
new ReadonlyContext(invocationContext)
|
|
477
518
|
))).filter((tool) => {
|
|
478
|
-
return !llmRequest.allowedTools || llmRequest.allowedTools.includes(tool.name);
|
|
519
|
+
return !llmRequest.allowedTools || llmRequest.allowedTools.includes(tool.name) || tool.name === "set_model_response";
|
|
479
520
|
});
|
|
480
521
|
for (const tool of tools) {
|
|
481
522
|
yield new __await(tool.processLlmRequest({ toolContext, llmRequest }));
|
|
@@ -594,7 +635,14 @@ class LlmAgent extends (_b = BaseAgent, _a = LLM_AGENT_SIGNATURE_SYMBOL, _b) {
|
|
|
594
635
|
const mergedEvent = createEvent(__spreadValues(__spreadValues({}, modelResponseEvent), llmResponse));
|
|
595
636
|
if (mergedEvent.content) {
|
|
596
637
|
const functionCalls = getFunctionCalls(mergedEvent);
|
|
597
|
-
|
|
638
|
+
const setModelResponseCall = functionCalls.find(
|
|
639
|
+
(call) => call.name === "set_model_response"
|
|
640
|
+
);
|
|
641
|
+
if (setModelResponseCall) {
|
|
642
|
+
const args = setModelResponseCall.args;
|
|
643
|
+
mergedEvent.content.parts = [{ text: JSON.stringify(args) }];
|
|
644
|
+
mergedEvent.actions.skipSummarization = true;
|
|
645
|
+
} else if (functionCalls && functionCalls.length) {
|
|
598
646
|
populateClientFunctionCallId(mergedEvent);
|
|
599
647
|
mergedEvent.longRunningToolIds = Array.from(
|
|
600
648
|
getLongRunningFunctionCalls(functionCalls, llmRequest.toolsDict)
|
|
@@ -46,6 +46,13 @@ class AgentTransferLlmRequestProcessor extends BaseLlmRequestProcessor {
|
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Appends transfer instructions and registers the `transfer_to_agent` tool
|
|
51
|
+
* when the agent has reachable transfer targets.
|
|
52
|
+
*
|
|
53
|
+
* @param invocationContext - The current invocation context.
|
|
54
|
+
* @param llmRequest - The request to augment with transfer instructions and the transfer tool.
|
|
55
|
+
*/
|
|
49
56
|
// eslint-disable-next-line require-yield
|
|
50
57
|
runAsync(invocationContext, llmRequest) {
|
|
51
58
|
return __asyncGenerator(this, null, function* () {
|
|
@@ -41,6 +41,13 @@ import { setOutputSchema } from "../../models/llm_request.js";
|
|
|
41
41
|
import { isLlmAgent } from "../llm_agent.js";
|
|
42
42
|
import { BaseLlmRequestProcessor } from "./base_llm_processor.js";
|
|
43
43
|
class BasicLlmRequestProcessor extends BaseLlmRequestProcessor {
|
|
44
|
+
/**
|
|
45
|
+
* Populates model name, generation config, output schema, and live connect
|
|
46
|
+
* settings on the request from the agent and run config.
|
|
47
|
+
*
|
|
48
|
+
* @param invocationContext - The current invocation context.
|
|
49
|
+
* @param llmRequest - The request object to populate in place.
|
|
50
|
+
*/
|
|
44
51
|
// eslint-disable-next-line require-yield
|
|
45
52
|
runAsync(invocationContext, llmRequest) {
|
|
46
53
|
return __asyncGenerator(this, null, function* () {
|
|
@@ -51,7 +58,7 @@ class BasicLlmRequestProcessor extends BaseLlmRequestProcessor {
|
|
|
51
58
|
}
|
|
52
59
|
llmRequest.model = agent.canonicalModel.model;
|
|
53
60
|
llmRequest.config = __spreadValues({}, (_a = agent.generateContentConfig) != null ? _a : {});
|
|
54
|
-
if (agent.outputSchema) {
|
|
61
|
+
if (agent.outputSchema && (!agent.tools || agent.tools.length === 0)) {
|
|
55
62
|
setOutputSchema(llmRequest, agent.outputSchema);
|
|
56
63
|
}
|
|
57
64
|
if (invocationContext.runConfig) {
|