@softactivate/adk 1.1.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 (141) 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 +3 -0
  6. package/dist/cjs/events/event.js +2 -0
  7. package/dist/cjs/index.js +14 -0
  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 +17 -8
  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/long_running_tool.js +2 -1
  23. package/dist/cjs/tools/mcp/mcp_session_manager.js +11 -0
  24. package/dist/cjs/tools/mcp/mcp_tool.js +10 -7
  25. package/dist/cjs/tools/mcp/mcp_toolset.js +10 -2
  26. package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +78 -0
  27. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +84 -0
  28. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +133 -0
  29. package/dist/cjs/tools/skill/load_skill_resource_tool.js +2 -25
  30. package/dist/cjs/utils/file_utils.js +28 -0
  31. package/dist/cjs/utils/gemini_schema_util.js +18 -0
  32. package/dist/cjs/utils/partial_copy.js +51 -0
  33. package/dist/cjs/utils/streaming_utils.js +167 -118
  34. package/dist/cjs/utils/vertex_ai_utils.js +50 -0
  35. package/dist/cjs/version.js +1 -1
  36. package/dist/esm/agents/functions.js +4 -0
  37. package/dist/esm/auth/oauth2/oauth2_discovery.js +26 -2
  38. package/dist/esm/code_executors/agent_engine_sandbox_code_executor.js +281 -0
  39. package/dist/esm/code_executors/code_execution_utils.js +1 -1
  40. package/dist/esm/common.js +2 -0
  41. package/dist/esm/events/event.js +2 -0
  42. package/dist/esm/index.js +11 -0
  43. package/dist/esm/integrations/agent_registry/agent_registry.js +333 -0
  44. package/dist/esm/integrations/agent_registry/agent_registry_mcp_toolset.js +77 -0
  45. package/dist/esm/integrations/agent_registry/helpers.js +28 -0
  46. package/dist/esm/integrations/agent_registry/types.js +20 -0
  47. package/dist/esm/memory/vertex_ai_memory_bank_service.js +468 -0
  48. package/dist/esm/runner/in_memory_runner.js +10 -5
  49. package/dist/esm/runner/runner.js +32 -2
  50. package/dist/esm/sessions/database_session_service.js +49 -3
  51. package/dist/esm/sessions/in_memory_session_service.js +70 -14
  52. package/dist/esm/sessions/registry.js +7 -0
  53. package/dist/esm/sessions/vertex_ai_session_service.js +403 -0
  54. package/dist/esm/tools/agent_tool.js +17 -8
  55. package/dist/esm/tools/exit_loop_tool.js +9 -0
  56. package/dist/esm/tools/function_tool.js +7 -2
  57. package/dist/esm/tools/long_running_tool.js +2 -1
  58. package/dist/esm/tools/mcp/mcp_session_manager.js +11 -0
  59. package/dist/esm/tools/mcp/mcp_tool.js +10 -7
  60. package/dist/esm/tools/mcp/mcp_toolset.js +10 -2
  61. package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +48 -0
  62. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +60 -0
  63. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +111 -0
  64. package/dist/esm/tools/skill/load_skill_resource_tool.js +1 -24
  65. package/dist/esm/utils/file_utils.js +26 -0
  66. package/dist/esm/utils/gemini_schema_util.js +18 -0
  67. package/dist/esm/utils/partial_copy.js +23 -0
  68. package/dist/esm/utils/streaming_utils.js +165 -117
  69. package/dist/esm/utils/vertex_ai_utils.js +22 -0
  70. package/dist/esm/version.js +1 -1
  71. package/dist/types/a2a/a2a_remote_agent.d.ts +14 -0
  72. package/dist/types/agents/processors/base_llm_processor.d.ts +12 -4
  73. package/dist/types/agents/processors/basic_llm_request_processor.d.ts +5 -0
  74. package/dist/types/agents/processors/identity_llm_request_processor.d.ts +4 -0
  75. package/dist/types/agents/processors/request_confirmation_llm_request_processor.d.ts +5 -0
  76. package/dist/types/agents/run_config.d.ts +15 -0
  77. package/dist/types/code_executors/agent_engine_sandbox_code_executor.d.ts +51 -0
  78. package/dist/types/common.d.ts +2 -0
  79. package/dist/types/events/event_actions.d.ts +24 -6
  80. package/dist/types/events/structured_events.d.ts +13 -0
  81. package/dist/types/examples/example_util.d.ts +25 -0
  82. package/dist/types/index.d.ts +6 -0
  83. package/dist/types/integrations/agent_registry/agent_registry.d.ts +94 -0
  84. package/dist/types/integrations/agent_registry/agent_registry_mcp_toolset.d.ts +43 -0
  85. package/dist/types/integrations/agent_registry/helpers.d.ts +7 -0
  86. package/dist/types/integrations/agent_registry/types.d.ts +101 -0
  87. package/dist/types/memory/vertex_ai_memory_bank_service.d.ts +52 -0
  88. package/dist/types/runner/in_memory_runner.d.ts +28 -1
  89. package/dist/types/runner/runner.d.ts +47 -0
  90. package/dist/types/sessions/base_session_service.d.ts +18 -0
  91. package/dist/types/sessions/database_session_service.d.ts +1 -1
  92. package/dist/types/sessions/in_memory_session_service.d.ts +1 -1
  93. package/dist/types/sessions/vertex_ai_session_service.d.ts +37 -0
  94. package/dist/types/tools/exit_loop_tool.d.ts +9 -0
  95. package/dist/types/tools/function_tool.d.ts +22 -2
  96. package/dist/types/tools/long_running_tool.d.ts +11 -1
  97. package/dist/types/tools/mcp/mcp_session_manager.d.ts +3 -0
  98. package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +25 -0
  99. package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +20 -0
  100. package/dist/types/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.d.ts +20 -0
  101. package/dist/types/utils/file_utils.d.ts +2 -0
  102. package/dist/types/utils/partial_copy.d.ts +13 -0
  103. package/dist/types/utils/streaming_utils.d.ts +8 -17
  104. package/dist/types/utils/vertex_ai_utils.d.ts +14 -0
  105. package/dist/types/version.d.ts +1 -1
  106. package/dist/web/agents/functions.js +4 -0
  107. package/dist/web/auth/oauth2/oauth2_discovery.js +26 -2
  108. package/dist/web/code_executors/agent_engine_sandbox_code_executor.js +281 -0
  109. package/dist/web/code_executors/code_execution_utils.js +1 -1
  110. package/dist/web/common.js +2 -0
  111. package/dist/web/events/event.js +2 -0
  112. package/dist/web/index.js +11 -0
  113. package/dist/web/integrations/agent_registry/agent_registry.js +333 -0
  114. package/dist/web/integrations/agent_registry/agent_registry_mcp_toolset.js +90 -0
  115. package/dist/web/integrations/agent_registry/helpers.js +28 -0
  116. package/dist/web/integrations/agent_registry/types.js +20 -0
  117. package/dist/web/memory/vertex_ai_memory_bank_service.js +475 -0
  118. package/dist/web/runner/in_memory_runner.js +10 -5
  119. package/dist/web/runner/runner.js +32 -2
  120. package/dist/web/sessions/database_session_service.js +49 -3
  121. package/dist/web/sessions/in_memory_session_service.js +70 -14
  122. package/dist/web/sessions/registry.js +7 -0
  123. package/dist/web/sessions/vertex_ai_session_service.js +414 -0
  124. package/dist/web/tools/agent_tool.js +17 -8
  125. package/dist/web/tools/exit_loop_tool.js +9 -0
  126. package/dist/web/tools/function_tool.js +7 -2
  127. package/dist/web/tools/long_running_tool.js +2 -1
  128. package/dist/web/tools/mcp/mcp_session_manager.js +11 -0
  129. package/dist/web/tools/mcp/mcp_tool.js +10 -7
  130. package/dist/web/tools/mcp/mcp_toolset.js +10 -2
  131. package/dist/web/tools/openapi_tool/auth/auth_helpers.js +48 -0
  132. package/dist/web/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +60 -0
  133. package/dist/web/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +111 -0
  134. package/dist/web/tools/skill/load_skill_resource_tool.js +1 -24
  135. package/dist/web/utils/file_utils.js +26 -0
  136. package/dist/web/utils/gemini_schema_util.js +18 -0
  137. package/dist/web/utils/partial_copy.js +23 -0
  138. package/dist/web/utils/streaming_utils.js +218 -117
  139. package/dist/web/utils/vertex_ai_utils.js +22 -0
  140. package/dist/web/version.js +1 -1
  141. package/package.json +2 -1
@@ -11,16 +11,22 @@ export type { AfterEventCallback, AfterExecuteCallback, AgentExecutorConfig, Bef
11
11
  export { toA2a } from './a2a/agent_to_a2a.js';
12
12
  export type { ToA2aOptions } from './a2a/agent_to_a2a.js';
13
13
  export type { ExecutorContext } from './a2a/executor_context.js';
14
+ export { InvocationContext } from './agents/invocation_context.js';
14
15
  export { FileArtifactService } from './artifacts/file_artifact_service.js';
15
16
  export { GcsArtifactService } from './artifacts/gcs_artifact_service.js';
16
17
  export { getArtifactServiceFromUri } from './artifacts/registry.js';
18
+ export { AgentEngineSandboxCodeExecutor, type AgentEngineSandboxCodeExecutorOptions, } from './code_executors/agent_engine_sandbox_code_executor.js';
19
+ export { CodeExecutionLanguage } from './code_executors/code_execution_utils.js';
17
20
  export { UnsafeLocalCodeExecutor, type UnsafeLocalCodeExecutorOptions, } from './code_executors/unsafe_local_code_executor.js';
18
21
  export * from './common.js';
19
22
  export { DatabaseSessionService } from './sessions/database_session_service.js';
20
23
  export { getSessionServiceFromUri } from './sessions/registry.js';
24
+ export { VertexAiSessionService } from './sessions/vertex_ai_session_service.js';
25
+ export type { VertexAiSessionServiceOptions } from './sessions/vertex_ai_session_service.js';
21
26
  export { loadAllSkillsInDir, loadSkillFromDir, validateSkillDir, } from './skills/loader.js';
22
27
  export { RunSkillInlineScriptTool } from './tools/skill/run_skill_inline_script_tool.js';
23
28
  export { RunSkillScriptTool } from './tools/skill/run_skill_script_tool.js';
29
+ export * from './integrations/agent_registry/agent_registry.js';
24
30
  export * from './telemetry/google_cloud.js';
25
31
  export * from './telemetry/setup.js';
26
32
  export * from './tools/mcp/mcp_session_manager.js';
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Client, ClientFactory } from '@a2a-js/sdk/client';
7
+ import { RemoteA2AAgent } from '../../a2a/a2a_remote_agent.js';
8
+ import { ReadonlyContext } from '../../agents/readonly_context.js';
9
+ import { AuthCredential } from '../../auth/auth_credential.js';
10
+ import { AuthScheme } from '../../auth/auth_schemes.js';
11
+ import { AgentRegistrySingleMCPToolset } from './agent_registry_mcp_toolset.js';
12
+ import { AgentInfo, ConnectionUriFilter, ConnectionUriResult, Endpoint, ListAgentsResponse, ListEndpointsResponse, ListMcpServersResponse, McpServer, ProtocolType } from './types.js';
13
+ export * from './agent_registry_mcp_toolset.js';
14
+ export * from './helpers.js';
15
+ export * from './types.js';
16
+ /**
17
+ * Client for interacting with the Google Cloud Agent Registry service.
18
+ *
19
+ * Unlike a standard REST client library, this class provides higher-level
20
+ * abstractions for ADK integration. It surfaces the agent registry service
21
+ * methods along with helper methods like `getMcpToolset` and
22
+ * `getRemoteA2AAgent` that automatically resolve connection details,
23
+ * manage OAuth authentication schemes, and handle GCP credentials to produce
24
+ * ready-to-use ADK components.
25
+ */
26
+ export declare class AgentRegistry {
27
+ readonly projectId: string;
28
+ readonly location: string;
29
+ private readonly basePath;
30
+ private readonly headerProvider?;
31
+ private readonly auth;
32
+ constructor(options: {
33
+ projectId?: string | null;
34
+ location?: string | null;
35
+ headerProvider?: (context: ReadonlyContext) => Record<string, string>;
36
+ });
37
+ /**
38
+ * Resolves default Google Cloud credentials and returns standard headers.
39
+ * Automatically caches, fetches, and handles refreshing expired OAuth tokens.
40
+ * Injects the billing/quota project identifier `x-goog-user-project` if present.
41
+ */
42
+ getAuthHeaders(): Promise<Record<string, string>>;
43
+ /**
44
+ * Helper function to execute HTTP GET requests against the Agent Registry API.
45
+ * Handles path resolution, search query params compilation, and auth headers fetching.
46
+ */
47
+ makeRequest<T = unknown>(path: string, params?: Record<string, string>): Promise<T>;
48
+ /**
49
+ * Parses connection interfaces list from registry metadata and returns the first match
50
+ * corresponding to requested protocol types and binding options.
51
+ */
52
+ getConnectionUri(resourceDetails: {
53
+ interfaces?: Array<{
54
+ url?: string;
55
+ protocolBinding?: string;
56
+ }>;
57
+ protocols?: Array<{
58
+ type?: ProtocolType;
59
+ protocolVersion?: string;
60
+ interfaces?: Array<{
61
+ url?: string;
62
+ protocolBinding?: string;
63
+ }>;
64
+ }>;
65
+ }, filters?: ConnectionUriFilter): ConnectionUriResult;
66
+ listMcpServers(options?: {
67
+ filterStr?: string;
68
+ pageSize?: number;
69
+ pageToken?: string;
70
+ }): Promise<ListMcpServersResponse>;
71
+ getMcpServer(name: string): Promise<McpServer>;
72
+ getMcpToolset(mcpServerName: string, options?: {
73
+ authScheme?: AuthScheme;
74
+ authCredential?: AuthCredential;
75
+ continueUri?: string;
76
+ }): Promise<AgentRegistrySingleMCPToolset>;
77
+ listEndpoints(options?: {
78
+ filterStr?: string;
79
+ pageSize?: number;
80
+ pageToken?: string;
81
+ }): Promise<ListEndpointsResponse>;
82
+ getEndpoint(name: string): Promise<Endpoint>;
83
+ getModelName(endpointName: string): Promise<string>;
84
+ listAgents(options?: {
85
+ filterStr?: string;
86
+ pageSize?: number;
87
+ pageToken?: string;
88
+ }): Promise<ListAgentsResponse>;
89
+ getAgentInfo(name: string): Promise<AgentInfo>;
90
+ getRemoteA2AAgent(agentName: string, options?: {
91
+ client?: Client;
92
+ clientFactory?: ClientFactory;
93
+ }): Promise<RemoteA2AAgent>;
94
+ }
@@ -0,0 +1,43 @@
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 { AuthCredential } from '../../auth/auth_credential.js';
8
+ import { AuthScheme } from '../../auth/auth_schemes.js';
9
+ import { BaseTool } from '../../tools/base_tool.js';
10
+ import { BaseToolset, ToolPredicate } from '../../tools/base_toolset.js';
11
+ import { StreamableHTTPConnectionParams } from '../../tools/mcp/mcp_session_manager.js';
12
+ /**
13
+ * A specialized BaseToolset subclass designed to represent a single registered MCP server.
14
+ *
15
+ * Unlike a standard MCPToolset, this class:
16
+ * 1. Supports a dynamic `headerProvider` to fetch/refresh authorization and custom headers
17
+ * immediately before establishing the MCP connection session.
18
+ * 2. Automatically injects the special `gcp.mcp.server.destination.id` telemetry metadata
19
+ * identifier into all resolved tools' custom metadata, allowing downstream execute_tool
20
+ * traces to be correctly attributed.
21
+ */
22
+ export declare class AgentRegistrySingleMCPToolset extends BaseToolset {
23
+ readonly destinationResourceId?: string;
24
+ readonly connectionParams: StreamableHTTPConnectionParams;
25
+ readonly headerProvider?: (context?: ReadonlyContext) => Promise<Record<string, string>> | Record<string, string>;
26
+ readonly authScheme?: AuthScheme;
27
+ readonly authCredential?: AuthCredential;
28
+ constructor(options: {
29
+ destinationResourceId?: string;
30
+ connectionParams: StreamableHTTPConnectionParams;
31
+ toolFilter?: ToolPredicate | string[];
32
+ prefix?: string;
33
+ headerProvider?: (context?: ReadonlyContext) => Promise<Record<string, string>> | Record<string, string>;
34
+ authScheme?: AuthScheme;
35
+ authCredential?: AuthCredential;
36
+ });
37
+ /**
38
+ * Connects to the underlying MCP server, retrieves tool definitions, prefixes tool names,
39
+ * and injects destination telemetry metadata.
40
+ */
41
+ getTools(context?: ReadonlyContext): Promise<BaseTool[]>;
42
+ close(): Promise<void>;
43
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export declare function isGoogleApi(url: string): boolean;
7
+ export declare function cleanName(name: string): string;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { AgentCard, TransportProtocol } from '@a2a-js/sdk';
7
+ export declare const AGENT_REGISTRY_BASE_URL = "https://agentregistry.googleapis.com/v1alpha";
8
+ export declare const GCP_MCP_SERVER_DESTINATION_ID = "gcp.mcp.server.destination.id";
9
+ export declare enum ProtocolType {
10
+ TYPE_UNSPECIFIED = "TYPE_UNSPECIFIED",
11
+ A2A_AGENT = "A2A_AGENT",
12
+ CUSTOM = "CUSTOM"
13
+ }
14
+ export interface Interface {
15
+ url?: string;
16
+ protocolBinding?: string;
17
+ }
18
+ export interface Endpoint {
19
+ name?: string;
20
+ endpointId?: string;
21
+ displayName?: string;
22
+ description?: string;
23
+ interfaces?: Interface[];
24
+ createTime?: string;
25
+ updateTime?: string;
26
+ attributes?: Record<string, unknown>;
27
+ }
28
+ export interface GcpAuthProviderScheme {
29
+ type: 'gcpAuthProviderScheme';
30
+ name: string;
31
+ scopes?: string[];
32
+ continueUri?: string;
33
+ }
34
+ export interface McpServer {
35
+ name?: string;
36
+ displayName?: string;
37
+ mcpServerId?: string;
38
+ interfaces?: Interface[];
39
+ protocols?: Array<{
40
+ type?: ProtocolType;
41
+ protocolVersion?: string;
42
+ interfaces?: Interface[];
43
+ }>;
44
+ [key: string]: unknown;
45
+ }
46
+ export interface Binding {
47
+ target?: {
48
+ identifier?: string;
49
+ };
50
+ authProviderBinding?: {
51
+ authProvider?: string;
52
+ };
53
+ }
54
+ export interface ListBindingsResponse {
55
+ bindings?: Binding[];
56
+ }
57
+ export interface ListMcpServersResponse {
58
+ mcpServers?: Array<Record<string, unknown>>;
59
+ nextPageToken?: string;
60
+ }
61
+ export interface ListEndpointsResponse {
62
+ endpoints?: Array<Endpoint>;
63
+ nextPageToken?: string;
64
+ }
65
+ export interface ListAgentsResponse {
66
+ agents?: Array<Record<string, unknown>>;
67
+ nextPageToken?: string;
68
+ }
69
+ export interface AgentSkillMetadata {
70
+ id?: string;
71
+ name?: string;
72
+ description?: string;
73
+ tags?: string[];
74
+ examples?: unknown[];
75
+ }
76
+ export interface AgentInfo {
77
+ displayName?: string;
78
+ description?: string;
79
+ version?: string;
80
+ card?: {
81
+ type?: string;
82
+ content?: AgentCard;
83
+ };
84
+ interfaces?: Interface[];
85
+ protocols?: Array<{
86
+ type?: ProtocolType;
87
+ protocolVersion?: string;
88
+ interfaces?: Interface[];
89
+ }>;
90
+ skills?: AgentSkillMetadata[];
91
+ [key: string]: unknown;
92
+ }
93
+ export interface ConnectionUriFilter {
94
+ protocolType?: ProtocolType;
95
+ protocolBinding?: string;
96
+ }
97
+ export interface ConnectionUriResult {
98
+ url?: string;
99
+ protocolVersion?: string;
100
+ protocolBinding?: TransportProtocol;
101
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Client } from '@google-cloud/vertexai';
7
+ import { Event } from '../events/event.js';
8
+ import { Session } from '../sessions/session.js';
9
+ import { BaseMemoryService, SearchMemoryRequest, SearchMemoryResponse } from './base_memory_service.js';
10
+ import { MemoryEntry } from './memory_entry.js';
11
+ export interface VertexAiMemoryBankServiceOptions {
12
+ projectId?: string;
13
+ location?: string;
14
+ agentEngineId: string;
15
+ expressModeApiKey?: string;
16
+ client?: Client;
17
+ }
18
+ /**
19
+ * Implementation of the BaseMemoryService using Vertex AI Memory Bank.
20
+ */
21
+ export declare class VertexAiMemoryBankService implements BaseMemoryService {
22
+ private readonly projectId?;
23
+ private readonly location?;
24
+ private readonly agentEngineId;
25
+ private readonly expressModeApiKey?;
26
+ private readonly memories;
27
+ constructor(options: VertexAiMemoryBankServiceOptions);
28
+ addSessionToMemory(session: Session): Promise<void>;
29
+ /**
30
+ * Adds events to Vertex AI Memory Bank via memories.generate.
31
+ */
32
+ addEventsToMemory(request: {
33
+ appName: string;
34
+ userId: string;
35
+ events: Event[];
36
+ sessionId?: string;
37
+ customMetadata?: Record<string, unknown>;
38
+ }): Promise<void>;
39
+ /**
40
+ * Adds explicit memory items using Vertex Memory Bank.
41
+ */
42
+ addMemory(request: {
43
+ appName: string;
44
+ userId: string;
45
+ memories: MemoryEntry[];
46
+ customMetadata?: Record<string, unknown>;
47
+ }): Promise<void>;
48
+ searchMemory(request: SearchMemoryRequest): Promise<SearchMemoryResponse>;
49
+ private addEventsToMemoryFromEvents;
50
+ private addMemoriesViaCreate;
51
+ private addMemoriesViaGenerateDirectMemoriesSource;
52
+ }
@@ -6,8 +6,35 @@
6
6
  import { BaseAgent } from '../agents/base_agent.js';
7
7
  import { BasePlugin } from '../plugins/base_plugin.js';
8
8
  import { Runner } from './runner.js';
9
+ /**
10
+ * A {@link Runner} pre-configured with in-memory services.
11
+ *
12
+ * Suitable for local development, testing, and prototyping. All session,
13
+ * artifact, and memory data is stored in-process and is not persisted between
14
+ * runs.
15
+ *
16
+ * Example:
17
+ * ```typescript
18
+ * const runner = new InMemoryRunner({agent: myAgent});
19
+ *
20
+ * for await (const event of runner.runEphemeral({
21
+ * userId: 'user1',
22
+ * newMessage: {parts: [{text: 'Hello'}]},
23
+ * })) {
24
+ * console.log(event);
25
+ * }
26
+ * ```
27
+ */
9
28
  export declare class InMemoryRunner extends Runner {
10
- constructor({ agent, appName, plugins, }: {
29
+ /**
30
+ * Creates a new InMemoryRunner instance.
31
+ *
32
+ * @param params The configuration for the runner.
33
+ * @param params.agent The root agent to run.
34
+ * @param params.appName The application name. Defaults to `'InMemoryRunner'`.
35
+ * @param params.plugins An optional list of plugins.
36
+ */
37
+ constructor(params: {
11
38
  agent: BaseAgent;
12
39
  appName?: string;
13
40
  plugins?: BasePlugin[];
@@ -25,10 +25,25 @@ export interface RunnerConfig {
25
25
  * The agent to run.
26
26
  */
27
27
  agent: BaseAgent;
28
+ /**
29
+ * An optional list of plugins to apply globally across all agents.
30
+ */
28
31
  plugins?: BasePlugin[];
32
+ /**
33
+ * An optional service for storing and retrieving artifacts.
34
+ */
29
35
  artifactService?: BaseArtifactService;
36
+ /**
37
+ * The service for managing sessions.
38
+ */
30
39
  sessionService: BaseSessionService;
40
+ /**
41
+ * An optional service for storing and querying agent memory.
42
+ */
31
43
  memoryService?: BaseMemoryService;
44
+ /**
45
+ * An optional service for managing authentication credentials.
46
+ */
32
47
  credentialService?: BaseCredentialService;
33
48
  }
34
49
  /**
@@ -42,6 +57,31 @@ declare const RUNNER_SIGNATURE_SYMBOL: unique symbol;
42
57
  * @returns True if the object is an instance of Runner, false otherwise.
43
58
  */
44
59
  export declare function isRunner(obj: unknown): obj is Runner;
60
+ /**
61
+ * Orchestrates agent execution for a given application.
62
+ *
63
+ * The Runner manages the full lifecycle of an agent invocation: it loads the
64
+ * session, invokes plugin callbacks, runs the root agent, and yields the
65
+ * resulting events. Use {@link InMemoryRunner} for quick prototyping without
66
+ * external services.
67
+ *
68
+ * Example:
69
+ * ```typescript
70
+ * const runner = new Runner({
71
+ * appName: 'my_app',
72
+ * agent: myAgent,
73
+ * sessionService: new InMemorySessionService(),
74
+ * });
75
+ *
76
+ * for await (const event of runner.runAsync({
77
+ * userId: 'user1',
78
+ * sessionId: 'session1',
79
+ * newMessage: {parts: [{text: 'Hello'}]},
80
+ * })) {
81
+ * console.log(event);
82
+ * }
83
+ * ```
84
+ */
45
85
  export declare class Runner {
46
86
  readonly [RUNNER_SIGNATURE_SYMBOL] = true;
47
87
  readonly appName: string;
@@ -51,6 +91,11 @@ export declare class Runner {
51
91
  readonly sessionService: BaseSessionService;
52
92
  readonly memoryService?: BaseMemoryService;
53
93
  readonly credentialService?: BaseCredentialService;
94
+ /**
95
+ * Creates a new Runner instance.
96
+ *
97
+ * @param input The configuration for the runner.
98
+ */
54
99
  constructor(input: RunnerConfig);
55
100
  /**
56
101
  * Runs the agent with a new, ephemeral session.
@@ -66,6 +111,7 @@ export declare class Runner {
66
111
  newMessage: Content;
67
112
  stateDelta?: Record<string, unknown>;
68
113
  runConfig?: RunConfig;
114
+ customMetadata?: Record<string, unknown>;
69
115
  }): AsyncGenerator<Event, void, undefined>;
70
116
  /**
71
117
  * Runs the agent with the given message, and returns an async generator of
@@ -85,6 +131,7 @@ export declare class Runner {
85
131
  stateDelta?: Record<string, unknown>;
86
132
  runConfig?: RunConfig;
87
133
  abortSignal?: AbortSignal;
134
+ customMetadata?: Record<string, unknown>;
88
135
  }): AsyncGenerator<Event, void, undefined>;
89
136
  /**
90
137
  * Saves artifacts from the message parts and replaces the inline data with
@@ -48,6 +48,14 @@ export interface ListSessionsRequest {
48
48
  appName: string;
49
49
  /** The ID of the user. */
50
50
  userId: string;
51
+ /** Maximum number of sessions to return. */
52
+ limit?: number;
53
+ /** Zero-based index of the first session to return. Ignored if `page` is set. */
54
+ offset?: number;
55
+ /** 1-based page number. Requires `limit`. Takes precedence over `offset`. */
56
+ page?: number;
57
+ /** Sort direction by last update time. No ordering is applied if omitted. */
58
+ order?: 'asc' | 'desc';
51
59
  }
52
60
  /**
53
61
  * The parameters for `deleteSession`.
@@ -73,10 +81,20 @@ export interface AppendEventRequest {
73
81
  * The response of listing sessions.
74
82
  *
75
83
  * The events and states are not set within each Session object.
84
+ * When no pagination params were requested, `page` is 1, `limit` equals
85
+ * `totalItems`, and `totalPages` is 1 (or 0 when there are no sessions).
76
86
  */
77
87
  export interface ListSessionsResponse {
78
88
  /** A list of sessions. */
79
89
  sessions: Session[];
90
+ /** Current page number (1-based). */
91
+ page: number;
92
+ /** Page size used. Equals `totalItems` when no limit was requested. */
93
+ limit: number;
94
+ /** Total number of sessions matching the request. */
95
+ totalItems: number;
96
+ /** Total number of pages. */
97
+ totalPages: number;
80
98
  }
81
99
  /**
82
100
  * Base class for session services.
@@ -26,7 +26,7 @@ export declare class DatabaseSessionService extends BaseSessionService {
26
26
  init(): Promise<void>;
27
27
  createSession({ appName, userId, state, sessionId, }: CreateSessionRequest): Promise<Session>;
28
28
  getSession({ appName, userId, sessionId, config, }: GetSessionRequest): Promise<Session | undefined>;
29
- listSessions({ appName, userId, }: ListSessionsRequest): Promise<ListSessionsResponse>;
29
+ listSessions({ appName, userId, limit, offset, page, order, }: ListSessionsRequest): Promise<ListSessionsResponse>;
30
30
  deleteSession({ appName, userId, sessionId, }: DeleteSessionRequest): Promise<void>;
31
31
  appendEvent({ session, event, }: AppendEventRequest): Promise<Event>;
32
32
  }
@@ -24,7 +24,7 @@ export declare class InMemorySessionService extends BaseSessionService {
24
24
  private appState;
25
25
  createSession({ appName, userId, state, sessionId, }: CreateSessionRequest): Promise<Session>;
26
26
  getSession({ appName, userId, sessionId, config, }: GetSessionRequest): Promise<Session | undefined>;
27
- listSessions({ appName, userId, }: ListSessionsRequest): Promise<ListSessionsResponse>;
27
+ listSessions({ appName, userId, limit, offset, page, order, }: ListSessionsRequest): Promise<ListSessionsResponse>;
28
28
  deleteSession({ appName, userId, sessionId, }: DeleteSessionRequest): Promise<void>;
29
29
  appendEvent({ session, event, }: AppendEventRequest): Promise<Event>;
30
30
  }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Sessions } from '@google-cloud/vertexai/build/src/genai/sessions.js';
7
+ import { Event } from '../events/event.js';
8
+ import { AppendEventRequest, BaseSessionService, CreateSessionRequest, DeleteSessionRequest, GetSessionRequest, ListSessionsRequest, ListSessionsResponse } from './base_session_service.js';
9
+ import { Session } from './session.js';
10
+ /**
11
+ * Checks if the given URI is a Vertex AI session service URI.
12
+ */
13
+ export declare function isVertexAiConnectionString(uri?: string): boolean;
14
+ export interface VertexAiSessionServiceOptions {
15
+ projectId?: string;
16
+ location?: string;
17
+ agentEngineId?: string;
18
+ expressModeApiKey?: string;
19
+ sessions?: Sessions;
20
+ }
21
+ /**
22
+ * A session service implementation that integrates with Vertex AI Agent Engine Sessions.
23
+ */
24
+ export declare class VertexAiSessionService extends BaseSessionService {
25
+ private sessions;
26
+ private agentEngineId?;
27
+ private expressModeApiKey?;
28
+ private projectId?;
29
+ private location?;
30
+ constructor(options: VertexAiSessionServiceOptions);
31
+ private getReasoningEngineId;
32
+ createSession({ appName, userId, state, sessionId, }: CreateSessionRequest): Promise<Session>;
33
+ getSession({ appName, userId, sessionId, config, }: GetSessionRequest): Promise<Session | undefined>;
34
+ listSessions({ appName, userId, limit, offset, page, order, }: ListSessionsRequest): Promise<ListSessionsResponse>;
35
+ deleteSession({ appName, userId: _userId, sessionId, }: DeleteSessionRequest): Promise<void>;
36
+ appendEvent({ session, event, }: AppendEventRequest): Promise<Event>;
37
+ }
@@ -14,8 +14,17 @@ import { BaseTool, RunAsyncToolRequest } from './base_tool.js';
14
14
  *
15
15
  */
16
16
  export declare class ExitLoopTool extends BaseTool {
17
+ /** Creates an ExitLoopTool with its fixed name and description. */
17
18
  constructor();
19
+ /** Returns the function declaration for this tool. */
18
20
  _getDeclaration(): FunctionDeclaration;
21
+ /**
22
+ * Sets `escalate` and `skipSummarization` on the event actions, signalling
23
+ * the {@link LoopAgent} to stop iterating.
24
+ *
25
+ * @param request The tool request containing the current tool context.
26
+ * @returns An empty string response.
27
+ */
19
28
  runAsync({ toolContext, }: RunAsyncToolRequest): Promise<unknown>;
20
29
  }
21
30
  /**
@@ -12,7 +12,14 @@ import { BaseTool, RunAsyncToolRequest } from './base_tool.js';
12
12
  * Input parameters of the function tool.
13
13
  */
14
14
  export type ToolInputParameters = z3.ZodObject<z3.ZodRawShape> | z4.ZodObject<z4.ZodRawShape> | Schema | undefined;
15
+ /**
16
+ * The arguments passed to the function tool's `execute` callback, inferred
17
+ * from the `parameters` schema type.
18
+ */
15
19
  export type ToolExecuteArgument<TParameters extends ToolInputParameters> = TParameters extends z3.ZodObject<infer T, infer U, infer V> ? z3.infer<z3.ZodObject<T, U, V>> : TParameters extends z4.ZodObject<infer T> ? z4.infer<z4.ZodObject<T>> : TParameters extends Schema ? unknown : string;
20
+ /**
21
+ * The signature of the user-provided function executed by a {@link FunctionTool}.
22
+ */
16
23
  export type ToolExecuteFunction<TParameters extends ToolInputParameters> = (input: ToolExecuteArgument<TParameters>, tool_context?: Context) => Promise<unknown> | unknown;
17
24
  /**
18
25
  * The configuration options for creating a function-based tool.
@@ -40,6 +47,14 @@ declare const FUNCTION_TOOL_SIGNATURE_SYMBOL: unique symbol;
40
47
  * @returns True if the object is an instance of BaseTool, false otherwise.
41
48
  */
42
49
  export declare function isFunctionTool(obj: unknown): obj is FunctionTool;
50
+ /**
51
+ * A tool that wraps a user-defined function, making it callable by an LLM.
52
+ *
53
+ * The function's name, description, and parameter schema are exposed to the
54
+ * model as a function declaration. When the model requests a call, the
55
+ * framework validates the arguments and invokes the user-provided `execute`
56
+ * callback.
57
+ */
43
58
  export declare class FunctionTool<TParameters extends ToolInputParameters = undefined> extends BaseTool {
44
59
  /** A unique symbol to identify ADK function tool class. */
45
60
  readonly [FUNCTION_TOOL_SIGNATURE_SYMBOL] = true;
@@ -51,11 +66,16 @@ export declare class FunctionTool<TParameters extends ToolInputParameters = unde
51
66
  */
52
67
  constructor(options: ToolOptions<TParameters>);
53
68
  /**
54
- * Provide a schema for the function.
69
+ * Returns the function declaration derived from the tool's name, description,
70
+ * and parameter schema.
55
71
  */
56
72
  _getDeclaration(): FunctionDeclaration;
57
73
  /**
58
- * Logic for running the tool.
74
+ * Validates the model-provided arguments against the parameter schema and
75
+ * invokes the user-defined `execute` function.
76
+ *
77
+ * @param req The tool request containing arguments and tool context.
78
+ * @returns A promise resolving to the function's return value.
59
79
  */
60
80
  runAsync(req: RunAsyncToolRequest): Promise<unknown>;
61
81
  }
@@ -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
  }
@@ -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;