@google/adk 1.0.0 → 1.2.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.
Files changed (166) hide show
  1. package/dist/cjs/agents/functions.js +4 -0
  2. package/dist/cjs/auth/oauth2/oauth2_discovery.js +26 -2
  3. package/dist/cjs/code_executors/agent_engine_sandbox_code_executor.js +305 -0
  4. package/dist/cjs/code_executors/code_execution_utils.js +1 -1
  5. package/dist/cjs/common.js +19 -0
  6. package/dist/cjs/events/event.js +3 -1
  7. package/dist/cjs/index.js +97 -125
  8. package/dist/cjs/integrations/agent_registry/agent_registry.js +362 -0
  9. package/dist/cjs/integrations/agent_registry/agent_registry_mcp_toolset.js +103 -0
  10. package/dist/cjs/integrations/agent_registry/helpers.js +57 -0
  11. package/dist/cjs/integrations/agent_registry/types.js +50 -0
  12. package/dist/cjs/memory/vertex_ai_memory_bank_service.js +496 -0
  13. package/dist/cjs/runner/in_memory_runner.js +10 -5
  14. package/dist/cjs/runner/runner.js +32 -2
  15. package/dist/cjs/sessions/database_session_service.js +49 -3
  16. package/dist/cjs/sessions/in_memory_session_service.js +70 -14
  17. package/dist/cjs/sessions/registry.js +4 -0
  18. package/dist/cjs/sessions/vertex_ai_session_service.js +428 -0
  19. package/dist/cjs/tools/agent_tool.js +11 -6
  20. package/dist/cjs/tools/exit_loop_tool.js +9 -0
  21. package/dist/cjs/tools/function_tool.js +7 -2
  22. package/dist/cjs/tools/google_maps_grounding_tool.js +80 -0
  23. package/dist/cjs/tools/long_running_tool.js +2 -1
  24. package/dist/cjs/tools/mcp/mcp_session_manager.js +11 -0
  25. package/dist/cjs/tools/mcp/mcp_tool.js +12 -7
  26. package/dist/cjs/tools/mcp/mcp_toolset.js +27 -4
  27. package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +78 -0
  28. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +84 -0
  29. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +133 -0
  30. package/dist/cjs/tools/skill/load_skill_resource_tool.js +2 -25
  31. package/dist/cjs/tools/url_context_tool.js +73 -0
  32. package/dist/cjs/tools/vertex_ai_search_tool.js +127 -0
  33. package/dist/cjs/tools/vertex_rag_retrieval_tool.js +64 -0
  34. package/dist/cjs/utils/file_utils.js +28 -0
  35. package/dist/cjs/utils/gemini_schema_util.js +18 -0
  36. package/dist/cjs/utils/model_name.js +8 -2
  37. package/dist/cjs/utils/partial_copy.js +51 -0
  38. package/dist/cjs/utils/streaming_utils.js +167 -121
  39. package/dist/cjs/utils/vertex_ai_utils.js +50 -0
  40. package/dist/cjs/version.js +1 -1
  41. package/dist/esm/agents/functions.js +4 -0
  42. package/dist/esm/auth/oauth2/oauth2_discovery.js +26 -2
  43. package/dist/esm/code_executors/agent_engine_sandbox_code_executor.js +281 -0
  44. package/dist/esm/code_executors/code_execution_utils.js +1 -1
  45. package/dist/esm/common.js +15 -0
  46. package/dist/esm/events/event.js +3 -1
  47. package/dist/esm/index.js +54 -130
  48. package/dist/esm/integrations/agent_registry/agent_registry.js +333 -0
  49. package/dist/esm/integrations/agent_registry/agent_registry_mcp_toolset.js +77 -0
  50. package/dist/esm/integrations/agent_registry/helpers.js +28 -0
  51. package/dist/esm/integrations/agent_registry/types.js +20 -0
  52. package/dist/esm/memory/vertex_ai_memory_bank_service.js +468 -0
  53. package/dist/esm/runner/in_memory_runner.js +10 -5
  54. package/dist/esm/runner/runner.js +32 -2
  55. package/dist/esm/sessions/database_session_service.js +49 -3
  56. package/dist/esm/sessions/in_memory_session_service.js +70 -14
  57. package/dist/esm/sessions/registry.js +7 -0
  58. package/dist/esm/sessions/vertex_ai_session_service.js +403 -0
  59. package/dist/esm/tools/agent_tool.js +11 -6
  60. package/dist/esm/tools/exit_loop_tool.js +9 -0
  61. package/dist/esm/tools/function_tool.js +7 -2
  62. package/dist/esm/tools/google_maps_grounding_tool.js +54 -0
  63. package/dist/esm/tools/long_running_tool.js +2 -1
  64. package/dist/esm/tools/mcp/mcp_session_manager.js +11 -0
  65. package/dist/esm/tools/mcp/mcp_tool.js +12 -7
  66. package/dist/esm/tools/mcp/mcp_toolset.js +27 -4
  67. package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +48 -0
  68. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +60 -0
  69. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +111 -0
  70. package/dist/esm/tools/skill/load_skill_resource_tool.js +1 -24
  71. package/dist/esm/tools/url_context_tool.js +44 -0
  72. package/dist/esm/tools/vertex_ai_search_tool.js +103 -0
  73. package/dist/esm/tools/vertex_rag_retrieval_tool.js +36 -0
  74. package/dist/esm/utils/file_utils.js +26 -0
  75. package/dist/esm/utils/gemini_schema_util.js +18 -0
  76. package/dist/esm/utils/model_name.js +6 -1
  77. package/dist/esm/utils/partial_copy.js +23 -0
  78. package/dist/esm/utils/streaming_utils.js +165 -120
  79. package/dist/esm/utils/vertex_ai_utils.js +22 -0
  80. package/dist/esm/version.js +1 -1
  81. package/dist/types/a2a/a2a_remote_agent.d.ts +14 -0
  82. package/dist/types/agents/processors/base_llm_processor.d.ts +12 -4
  83. package/dist/types/agents/processors/basic_llm_request_processor.d.ts +5 -0
  84. package/dist/types/agents/processors/identity_llm_request_processor.d.ts +4 -0
  85. package/dist/types/agents/processors/request_confirmation_llm_request_processor.d.ts +5 -0
  86. package/dist/types/agents/run_config.d.ts +15 -0
  87. package/dist/types/code_executors/agent_engine_sandbox_code_executor.d.ts +51 -0
  88. package/dist/types/common.d.ts +7 -0
  89. package/dist/types/events/event_actions.d.ts +24 -6
  90. package/dist/types/events/structured_events.d.ts +13 -0
  91. package/dist/types/examples/example_util.d.ts +25 -0
  92. package/dist/types/index.d.ts +6 -0
  93. package/dist/types/integrations/agent_registry/agent_registry.d.ts +94 -0
  94. package/dist/types/integrations/agent_registry/agent_registry_mcp_toolset.d.ts +43 -0
  95. package/dist/types/integrations/agent_registry/helpers.d.ts +7 -0
  96. package/dist/types/integrations/agent_registry/types.d.ts +101 -0
  97. package/dist/types/memory/vertex_ai_memory_bank_service.d.ts +52 -0
  98. package/dist/types/runner/in_memory_runner.d.ts +28 -1
  99. package/dist/types/runner/runner.d.ts +47 -0
  100. package/dist/types/sessions/base_session_service.d.ts +18 -0
  101. package/dist/types/sessions/database_session_service.d.ts +1 -1
  102. package/dist/types/sessions/in_memory_session_service.d.ts +1 -1
  103. package/dist/types/sessions/vertex_ai_session_service.d.ts +37 -0
  104. package/dist/types/tools/exit_loop_tool.d.ts +9 -0
  105. package/dist/types/tools/function_tool.d.ts +22 -2
  106. package/dist/types/tools/google_maps_grounding_tool.d.ts +22 -0
  107. package/dist/types/tools/long_running_tool.d.ts +11 -1
  108. package/dist/types/tools/mcp/mcp_session_manager.d.ts +3 -0
  109. package/dist/types/tools/mcp/mcp_tool.d.ts +7 -1
  110. package/dist/types/tools/mcp/mcp_toolset.d.ts +7 -1
  111. package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +25 -0
  112. package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +20 -0
  113. package/dist/types/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.d.ts +20 -0
  114. package/dist/types/tools/url_context_tool.d.ts +17 -0
  115. package/dist/types/tools/vertex_ai_search_tool.d.ts +55 -0
  116. package/dist/types/tools/vertex_rag_retrieval_tool.d.ts +42 -0
  117. package/dist/types/utils/file_utils.d.ts +2 -0
  118. package/dist/types/utils/model_name.d.ts +4 -0
  119. package/dist/types/utils/partial_copy.d.ts +13 -0
  120. package/dist/types/utils/streaming_utils.d.ts +8 -17
  121. package/dist/types/utils/vertex_ai_utils.d.ts +14 -0
  122. package/dist/types/version.d.ts +1 -1
  123. package/dist/web/agents/functions.js +4 -0
  124. package/dist/web/auth/oauth2/oauth2_discovery.js +26 -2
  125. package/dist/web/code_executors/agent_engine_sandbox_code_executor.js +281 -0
  126. package/dist/web/code_executors/code_execution_utils.js +1 -1
  127. package/dist/web/common.js +15 -0
  128. package/dist/web/events/event.js +3 -1
  129. package/dist/web/index.js +54 -12
  130. package/dist/web/integrations/agent_registry/agent_registry.js +333 -0
  131. package/dist/web/integrations/agent_registry/agent_registry_mcp_toolset.js +90 -0
  132. package/dist/web/integrations/agent_registry/helpers.js +28 -0
  133. package/dist/web/integrations/agent_registry/types.js +20 -0
  134. package/dist/web/memory/vertex_ai_memory_bank_service.js +475 -0
  135. package/dist/web/runner/in_memory_runner.js +10 -5
  136. package/dist/web/runner/runner.js +32 -2
  137. package/dist/web/sessions/database_session_service.js +49 -3
  138. package/dist/web/sessions/in_memory_session_service.js +70 -14
  139. package/dist/web/sessions/registry.js +7 -0
  140. package/dist/web/sessions/vertex_ai_session_service.js +414 -0
  141. package/dist/web/tools/agent_tool.js +11 -6
  142. package/dist/web/tools/exit_loop_tool.js +9 -0
  143. package/dist/web/tools/function_tool.js +7 -2
  144. package/dist/web/tools/google_maps_grounding_tool.js +54 -0
  145. package/dist/web/tools/long_running_tool.js +2 -1
  146. package/dist/web/tools/mcp/mcp_session_manager.js +11 -0
  147. package/dist/web/tools/mcp/mcp_tool.js +12 -7
  148. package/dist/web/tools/mcp/mcp_toolset.js +27 -4
  149. package/dist/web/tools/openapi_tool/auth/auth_helpers.js +48 -0
  150. package/dist/web/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +60 -0
  151. package/dist/web/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +111 -0
  152. package/dist/web/tools/skill/load_skill_resource_tool.js +1 -24
  153. package/dist/web/tools/url_context_tool.js +44 -0
  154. package/dist/web/tools/vertex_ai_search_tool.js +103 -0
  155. package/dist/web/tools/vertex_rag_retrieval_tool.js +36 -0
  156. package/dist/web/utils/file_utils.js +26 -0
  157. package/dist/web/utils/gemini_schema_util.js +18 -0
  158. package/dist/web/utils/model_name.js +6 -1
  159. package/dist/web/utils/partial_copy.js +23 -0
  160. package/dist/web/utils/streaming_utils.js +219 -121
  161. package/dist/web/utils/vertex_ai_utils.js +22 -0
  162. package/dist/web/version.js +1 -1
  163. package/package.json +3 -2
  164. package/dist/cjs/index.js.map +0 -7
  165. package/dist/esm/index.js.map +0 -7
  166. package/dist/web/index.js.map +0 -7
@@ -5,6 +5,15 @@
5
5
  */
6
6
  import { FunctionDeclaration } from '@google/genai';
7
7
  import { FunctionTool, ToolInputParameters, ToolOptions } from './function_tool.js';
8
+ /**
9
+ * A {@link FunctionTool} for long-running operations whose result is returned
10
+ * asynchronously.
11
+ *
12
+ * The framework invokes the user-provided function and delivers the response
13
+ * back to the model once it completes, identified by the `function_call_id`.
14
+ * The model is also instructed not to re-invoke the tool while a call is
15
+ * already in flight.
16
+ */
8
17
  export declare class LongRunningFunctionTool<TParameters extends ToolInputParameters = undefined> extends FunctionTool<TParameters> {
9
18
  /**
10
19
  * The constructor acts as the user-friendly factory.
@@ -12,7 +21,8 @@ export declare class LongRunningFunctionTool<TParameters extends ToolInputParame
12
21
  */
13
22
  constructor(options: ToolOptions<TParameters>);
14
23
  /**
15
- * Provide a schema for the function.
24
+ * Returns the function declaration with an appended instruction warning the
25
+ * model not to re-invoke the tool while it is still running.
16
26
  */
17
27
  _getDeclaration(): FunctionDeclaration;
18
28
  }
@@ -59,6 +59,9 @@ export type MCPConnectionParams = StdioConnectionParams | StreamableHTTPConnecti
59
59
  */
60
60
  export declare class MCPSessionManager {
61
61
  private readonly connectionParams;
62
+ private readonly activeSessions;
62
63
  constructor(connectionParams: MCPConnectionParams);
63
64
  createSession(): Promise<Client>;
65
+ closeSession(client: Client): Promise<void>;
66
+ getActiveSessions(): Client[];
64
67
  }
@@ -20,11 +20,17 @@ import { MCPSessionManager } from './mcp_session_manager.js';
20
20
  * invoked, which in turn establishes an MCP session, sends a `callTool`
21
21
  * request with the provided arguments, and returns the result from the
22
22
  * remote tool.
23
+ *
24
+ * The originalName parameter allows the tool to track the native tool name
25
+ * exposed by the MCP server. This is critical when the toolset applies a
26
+ * prefix to tool names (e.g., for LLM namespace disambiguation), ensuring
27
+ * the correct original name is used when executing on the server.
23
28
  */
24
29
  export declare class MCPTool extends BaseTool {
25
30
  private readonly mcpTool;
26
31
  private readonly mcpSessionManager;
27
- constructor(mcpTool: Tool, mcpSessionManager: MCPSessionManager);
32
+ private readonly originalName;
33
+ constructor(mcpTool: Tool, mcpSessionManager: MCPSessionManager, originalName?: string);
28
34
  _getDeclaration(): FunctionDeclaration;
29
35
  runAsync(request: RunAsyncToolRequest): Promise<unknown>;
30
36
  }
@@ -3,6 +3,7 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ import { ReadonlyContext } from '../../agents/readonly_context.js';
6
7
  import { BaseTool } from '../base_tool.js';
7
8
  import { BaseToolset, ToolPredicate } from '../base_toolset.js';
8
9
  import { MCPConnectionParams } from './mcp_session_manager.js';
@@ -17,6 +18,11 @@ import { MCPConnectionParams } from './mcp_session_manager.js';
17
18
  * The toolset can be configured with a filter to selectively expose a subset
18
19
  * of the tools provided by the MCP server.
19
20
  *
21
+ * It can also be configured with a prefix. If provided, all tools discovered
22
+ * from the MCP server will have their names prefixed with `${prefix}_`. When the
23
+ * LLM invokes the prefixed tool, this toolset transparently strips the prefix
24
+ * before sending the request to the underlying MCP server.
25
+ *
20
26
  * Usage:
21
27
  * import { MCPToolset } from '@google/adk';
22
28
  * import { StreamableHTTPConnectionParamsSchema } from '@google/adk';
@@ -33,6 +39,6 @@ import { MCPConnectionParams } from './mcp_session_manager.js';
33
39
  export declare class MCPToolset extends BaseToolset {
34
40
  private readonly mcpSessionManager;
35
41
  constructor(connectionParams: MCPConnectionParams, toolFilter?: ToolPredicate | string[], prefix?: string);
36
- getTools(): Promise<BaseTool[]>;
42
+ getTools(context?: ReadonlyContext): Promise<BaseTool[]>;
37
43
  close(): Promise<void>;
38
44
  }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { OpenAPIV3 } from 'openapi-types';
7
+ import { AuthCredential } from '../../../auth/auth_credential.js';
8
+ /**
9
+ * Applies the given credential to the request headers and URL.
10
+ *
11
+ * @param url The target URL.
12
+ * @param headers The request headers.
13
+ * @param credential The auth credential.
14
+ * @param authScheme The auth scheme from OpenAPI spec.
15
+ * @returns The updated URL (if modified by query params).
16
+ */
17
+ export declare function applyCredential(url: string, headers: Record<string, string>, credential?: AuthCredential, authScheme?: OpenAPIV3.SecuritySchemeObject): string;
18
+ /**
19
+ * Helper to create a simple API Key auth scheme.
20
+ */
21
+ export declare function createApiKeyScheme(name: string, inLocation: 'header' | 'query' | 'cookie'): OpenAPIV3.SecuritySchemeObject;
22
+ /**
23
+ * Helper to create a simple Bearer Token auth scheme.
24
+ */
25
+ export declare function createBearerScheme(): OpenAPIV3.SecuritySchemeObject;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { AuthCredential } from '../../../../auth/auth_credential.js';
7
+ import { AuthScheme } from '../../../../auth/auth_schemes.js';
8
+ import { BaseCredentialExchanger, ExchangeResult } from '../../../../auth/exchanger/base_credential_exchanger.js';
9
+ /**
10
+ * Automatically selects the appropriate credential exchanger based on the auth scheme.
11
+ * Ported from Python implementation.
12
+ */
13
+ export declare class AutoAuthCredentialExchanger implements BaseCredentialExchanger {
14
+ private exchangers;
15
+ constructor();
16
+ exchange(params: {
17
+ authScheme?: AuthScheme;
18
+ authCredential: AuthCredential;
19
+ }): Promise<ExchangeResult>;
20
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { AuthCredential } from '../../../../auth/auth_credential.js';
7
+ import { AuthScheme } from '../../../../auth/auth_schemes.js';
8
+ import { BaseCredentialExchanger, ExchangeResult } from '../../../../auth/exchanger/base_credential_exchanger.js';
9
+ /**
10
+ * Fetches credentials for Google Service Account.
11
+ * Ported from Python implementation.
12
+ */
13
+ export declare class ServiceAccountCredentialExchanger implements BaseCredentialExchanger {
14
+ exchange(params: {
15
+ authScheme?: AuthScheme;
16
+ authCredential: AuthCredential;
17
+ }): Promise<ExchangeResult>;
18
+ private exchangeForDefaultCredential;
19
+ private exchangeForExplicitCredential;
20
+ }
@@ -0,0 +1,17 @@
1
+ import { BaseTool, ToolProcessLlmRequest } from './base_tool.js';
2
+ /**
3
+ * A built-in tool that allows Gemini 2+ models to retrieve content from URLs
4
+ * provided in the conversation.
5
+ *
6
+ * This tool operates internally within the model and does not require or
7
+ * perform local code execution.
8
+ */
9
+ export declare class UrlContextTool extends BaseTool {
10
+ constructor();
11
+ runAsync(): Promise<unknown>;
12
+ processLlmRequest({ llmRequest, }: ToolProcessLlmRequest): Promise<void>;
13
+ }
14
+ /**
15
+ * A global instance of {@link UrlContextTool}.
16
+ */
17
+ export declare const URL_CONTEXT: UrlContextTool;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { ReadonlyContext } from '../agents/readonly_context.js';
7
+ import { BaseTool, ToolProcessLlmRequest } from './base_tool.js';
8
+ export interface VertexAISearchDataStoreSpec {
9
+ dataStore?: string;
10
+ }
11
+ export interface VertexAISearchConfig {
12
+ datastore?: string;
13
+ dataStoreSpecs?: VertexAISearchDataStoreSpec[];
14
+ engine?: string;
15
+ filter?: string;
16
+ maxResults?: number;
17
+ }
18
+ export interface BaseVertexAiSearchToolParams {
19
+ filter?: string;
20
+ maxResults?: number;
21
+ bypassMultiToolsLimit?: boolean;
22
+ }
23
+ export interface DataStoreParams extends BaseVertexAiSearchToolParams {
24
+ dataStoreId: string;
25
+ searchEngineId?: never;
26
+ dataStoreSpecs?: never;
27
+ }
28
+ export interface SearchEngineParams extends BaseVertexAiSearchToolParams {
29
+ searchEngineId: string;
30
+ dataStoreId?: never;
31
+ dataStoreSpecs?: VertexAISearchDataStoreSpec[];
32
+ }
33
+ export type VertexAiSearchToolParams = DataStoreParams | SearchEngineParams;
34
+ /**
35
+ * A built-in tool using Vertex AI Search.
36
+ */
37
+ export declare class VertexAiSearchTool extends BaseTool {
38
+ readonly dataStoreId?: string;
39
+ readonly dataStoreSpecs?: VertexAISearchDataStoreSpec[];
40
+ readonly searchEngineId?: string;
41
+ readonly filter?: string;
42
+ readonly maxResults?: number;
43
+ readonly bypassMultiToolsLimit: boolean;
44
+ constructor(params: VertexAiSearchToolParams);
45
+ runAsync(): Promise<unknown>;
46
+ /**
47
+ * Builds the VertexAISearch configuration.
48
+ *
49
+ * Override this method in a subclass to dynamically customize the search
50
+ * configuration based on the context (e.g., set filter based on session
51
+ * state).
52
+ */
53
+ protected buildVertexAiSearchConfig(_readonlyContext: ReadonlyContext): VertexAISearchConfig;
54
+ processLlmRequest({ toolContext, llmRequest, }: ToolProcessLlmRequest): Promise<void>;
55
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { VertexRagStore } from '@google/genai';
7
+ import { BaseTool, ToolProcessLlmRequest } from './base_tool.js';
8
+ /**
9
+ * A tool that retrieves relevant content from a Vertex AI RAG corpus to ground
10
+ * model responses.
11
+ *
12
+ * This tool operates server-side; it modifies the LLM request config to enable
13
+ * RAG retrieval via the `retrieval.vertexRagStore` field and does not perform
14
+ * local code execution.
15
+ *
16
+ * **Note:** The Vertex AI RAG Engine only supports one corpus per
17
+ * `ragResources` array. Create one `VertexRagRetrievalTool` instance per
18
+ * corpus.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { VertexRagRetrievalTool } from '@google/adk';
23
+ * import { VertexRagStore } from '@google/genai';
24
+ *
25
+ * const ragTool = new VertexRagRetrievalTool({
26
+ * ragResources: [{ragCorpus: 'projects/my-project/locations/us-central1/ragCorpora/my-corpus'}],
27
+ * similarityTopK: 5,
28
+ * });
29
+ *
30
+ * const agent = new LlmAgent({ tools: [ragTool], ... });
31
+ * ```
32
+ */
33
+ export declare class VertexRagRetrievalTool extends BaseTool {
34
+ private readonly vertexRagStore;
35
+ constructor(config: VertexRagStore);
36
+ /**
37
+ * This tool is executed server-side by the Vertex AI RAG Engine.
38
+ * Local execution is not required.
39
+ */
40
+ runAsync(): Promise<unknown>;
41
+ processLlmRequest({ llmRequest, }: ToolProcessLlmRequest): Promise<void>;
42
+ }
@@ -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;
@@ -32,3 +32,7 @@ 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
+ * Returns True when Gemini model-id validation should be bypassed.
37
+ */
38
+ export declare function isGeminiModelIdCheckDisabled(): boolean;
@@ -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,15 @@ 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 currentFcName?;
27
- private currentFcArgs;
28
- private currentFcId?;
29
- private currentThoughtSignature?;
30
- private lastThoughtSignature?;
21
+ private lastThoughtSignature;
22
+ private sawFunctionCall;
23
+ private readonly strategy;
31
24
  constructor(isProgressiveMode?: boolean);
32
- private flushTextBufferToSequence;
33
- private getValueFromPartialArg;
34
- private setValueByJsonPath;
35
- private flushFunctionCallToSequence;
36
- private processStreamingFunctionCall;
37
- private processFunctionCallPart;
38
25
  processResponse(response: GenerateContentResponse): AsyncGenerator<LlmResponse, void, void>;
39
26
  close(): LlmResponse | undefined;
40
27
  }
28
+ /**
29
+ * Checks if a response part has no meaningful content (empty text, no tool calls, etc.)
30
+ */
31
+ 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;
@@ -3,4 +3,4 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- export declare const version = "1.0.0";
6
+ export declare const version = "1.2.0";
@@ -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,
@@ -123,6 +123,18 @@ class OAuth2DiscoveryManager {
123
123
  return void 0;
124
124
  }
125
125
  }
126
+ function normaliseHostname(raw) {
127
+ const stripped = raw.replace(/^\[|\]$/g, "");
128
+ const m = stripped.match(/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i);
129
+ if (m) {
130
+ const hi = parseInt(m[1], 16);
131
+ const lo = parseInt(m[2], 16);
132
+ return [hi >> 8 & 255, hi & 255, lo >> 8 & 255, lo & 255].join(".");
133
+ }
134
+ const mDot = stripped.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i);
135
+ if (mDot) return mDot[1];
136
+ return raw;
137
+ }
126
138
  function validateDiscoveryUrl(urlStr) {
127
139
  try {
128
140
  const url = new URL(urlStr);
@@ -130,8 +142,8 @@ function validateDiscoveryUrl(urlStr) {
130
142
  logger.warn("Unsafe protocol for discovery URL: ".concat(url.protocol));
131
143
  return false;
132
144
  }
133
- const host = url.hostname.toLowerCase();
134
- if (host === "localhost" || host === "127.0.0.1" || host === "[::1]" || host.startsWith("10.") || host.startsWith("192.168.") || host.startsWith("169.254.")) {
145
+ const host = normaliseHostname(url.hostname.toLowerCase());
146
+ if (host === "localhost" || host === "127.0.0.1" || host === "[::1]" || host === "0.0.0.0" || host.startsWith("10.") || host.startsWith("192.168.") || host.startsWith("169.254.")) {
135
147
  logger.warn("Unsafe host for discovery URL: ".concat(host));
136
148
  return false;
137
149
  }
@@ -143,6 +155,18 @@ function validateDiscoveryUrl(urlStr) {
143
155
  return false;
144
156
  }
145
157
  }
158
+ const cgnatMatch = host.match(/^100\.(\d+)\./);
159
+ if (cgnatMatch) {
160
+ const secondOctet = parseInt(cgnatMatch[1], 10);
161
+ if (secondOctet >= 64 && secondOctet <= 127) {
162
+ logger.warn("Unsafe host for discovery URL: ".concat(host));
163
+ return false;
164
+ }
165
+ }
166
+ if (/^\[(f[cd][0-9a-f]{2}|fe[89ab][0-9a-f]):/i.test(url.hostname)) {
167
+ logger.warn("Unsafe host for discovery URL: ".concat(url.hostname));
168
+ return false;
169
+ }
146
170
  return true;
147
171
  } catch (e) {
148
172
  logger.warn("Failed to parse URL for validation ".concat(urlStr, ": ").concat(e));