@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
@@ -0,0 +1,362 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ "use strict";
8
+ var __defProp = Object.defineProperty;
9
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
+ var __getOwnPropNames = Object.getOwnPropertyNames;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __export = (target, all) => {
13
+ for (var name in all)
14
+ __defProp(target, name, { get: all[name], enumerable: true });
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
25
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
26
+ var agent_registry_exports = {};
27
+ __export(agent_registry_exports, {
28
+ AgentRegistry: () => AgentRegistry
29
+ });
30
+ module.exports = __toCommonJS(agent_registry_exports);
31
+ var import_google_auth_library = require("google-auth-library");
32
+ var import_a2a_remote_agent = require("../../a2a/a2a_remote_agent.js");
33
+ var import_logger = require("../../utils/logger.js");
34
+ var import_agent_registry_mcp_toolset = require("./agent_registry_mcp_toolset.js");
35
+ var import_helpers = require("./helpers.js");
36
+ var import_types = require("./types.js");
37
+ __reExport(agent_registry_exports, require("./agent_registry_mcp_toolset.js"), module.exports);
38
+ __reExport(agent_registry_exports, require("./helpers.js"), module.exports);
39
+ __reExport(agent_registry_exports, require("./types.js"), module.exports);
40
+ /**
41
+ * @license
42
+ * Copyright 2026 Google LLC
43
+ * SPDX-License-Identifier: Apache-2.0
44
+ */
45
+ const TRANSPORT_MAPPING = {
46
+ "HTTP_JSON": "HTTP+JSON",
47
+ "JSONRPC": "JSONRPC",
48
+ "GRPC": "GRPC"
49
+ };
50
+ class AgentRegistry {
51
+ constructor(options) {
52
+ if (!options.projectId || !options.location) {
53
+ throw new Error("project_id and location must be provided");
54
+ }
55
+ this.projectId = options.projectId;
56
+ this.location = options.location;
57
+ this.basePath = `projects/${this.projectId}/locations/${this.location}`;
58
+ this.headerProvider = options.headerProvider;
59
+ this.auth = new import_google_auth_library.GoogleAuth({
60
+ scopes: ["https://www.googleapis.com/auth/cloud-platform"]
61
+ });
62
+ }
63
+ /**
64
+ * Resolves default Google Cloud credentials and returns standard headers.
65
+ * Automatically caches, fetches, and handles refreshing expired OAuth tokens.
66
+ * Injects the billing/quota project identifier `x-goog-user-project` if present.
67
+ */
68
+ async getAuthHeaders() {
69
+ try {
70
+ const client = await this.auth.getClient();
71
+ const headers = await client.getRequestHeaders(
72
+ "https://agentregistry.googleapis.com"
73
+ );
74
+ const authHeaders = {};
75
+ const rawHeaders = headers;
76
+ const authKey = Object.keys(rawHeaders).find(
77
+ (k) => k.toLowerCase() === "authorization"
78
+ );
79
+ let token = authKey ? rawHeaders[authKey] : void 0;
80
+ if (!token && client.credentials && client.credentials.access_token) {
81
+ token = `Bearer ${client.credentials.access_token}`;
82
+ }
83
+ if (token) {
84
+ authHeaders["Authorization"] = token;
85
+ }
86
+ authHeaders["Content-Type"] = "application/json";
87
+ const quotaProjectId = client.quotaProjectId || this.auth.quotaProjectId;
88
+ if (quotaProjectId) {
89
+ authHeaders["x-goog-user-project"] = quotaProjectId;
90
+ }
91
+ return authHeaders;
92
+ } catch (err) {
93
+ const msg = err instanceof Error ? err.message : String(err);
94
+ throw new Error(`Failed to refresh Google Cloud credentials: ${msg}`);
95
+ }
96
+ }
97
+ /**
98
+ * Helper function to execute HTTP GET requests against the Agent Registry API.
99
+ * Handles path resolution, search query params compilation, and auth headers fetching.
100
+ */
101
+ async makeRequest(path, params) {
102
+ let url;
103
+ if (path.startsWith("projects/")) {
104
+ url = `${import_types.AGENT_REGISTRY_BASE_URL}/${path}`;
105
+ } else {
106
+ url = `${import_types.AGENT_REGISTRY_BASE_URL}/${this.basePath}/${path}`;
107
+ }
108
+ if (params && Object.keys(params).length > 0) {
109
+ const searchParams = new URLSearchParams(params);
110
+ url += `?${searchParams.toString()}`;
111
+ }
112
+ try {
113
+ const headers = await this.getAuthHeaders();
114
+ const res = await fetch(url, {
115
+ method: "GET",
116
+ headers
117
+ });
118
+ if (!res.ok) {
119
+ const text = await res.text();
120
+ throw new Error(
121
+ `API request failed with status ${res.status}: ${text}`
122
+ );
123
+ }
124
+ return await res.json();
125
+ } catch (err) {
126
+ const msg = err instanceof Error ? err.message : String(err);
127
+ if (msg.includes("API request failed")) {
128
+ throw err;
129
+ }
130
+ throw new Error(`API request failed: ${msg}`);
131
+ }
132
+ }
133
+ /**
134
+ * Parses connection interfaces list from registry metadata and returns the first match
135
+ * corresponding to requested protocol types and binding options.
136
+ */
137
+ getConnectionUri(resourceDetails, filters) {
138
+ const protocols = [];
139
+ if (resourceDetails.protocols) {
140
+ protocols.push(...resourceDetails.protocols);
141
+ }
142
+ if (resourceDetails.interfaces) {
143
+ protocols.push({ interfaces: resourceDetails.interfaces });
144
+ }
145
+ for (const p of protocols) {
146
+ if ((filters == null ? void 0 : filters.protocolType) && p.type !== filters.protocolType) {
147
+ continue;
148
+ }
149
+ const protocolVersion = p.protocolVersion;
150
+ const interfaces = p.interfaces || [];
151
+ for (const i of interfaces) {
152
+ const mappedBinding = i.protocolBinding ? TRANSPORT_MAPPING[i.protocolBinding] : void 0;
153
+ if ((filters == null ? void 0 : filters.protocolBinding) && mappedBinding !== filters.protocolBinding) {
154
+ continue;
155
+ }
156
+ if (i.url) {
157
+ return { url: i.url, protocolVersion, protocolBinding: mappedBinding };
158
+ }
159
+ }
160
+ }
161
+ return {};
162
+ }
163
+ // --- MCP Server Methods ---
164
+ async listMcpServers(options) {
165
+ const params = {};
166
+ if (options == null ? void 0 : options.filterStr) {
167
+ params["filter"] = options.filterStr;
168
+ }
169
+ if (options == null ? void 0 : options.pageSize) {
170
+ params["pageSize"] = String(options.pageSize);
171
+ }
172
+ if (options == null ? void 0 : options.pageToken) {
173
+ params["pageToken"] = options.pageToken;
174
+ }
175
+ return this.makeRequest("mcpServers", params);
176
+ }
177
+ async getMcpServer(name) {
178
+ return this.makeRequest(name);
179
+ }
180
+ async getMcpToolset(mcpServerName, options) {
181
+ var _a, _b;
182
+ const serverDetails = await this.getMcpServer(mcpServerName);
183
+ const name = (0, import_helpers.cleanName)(serverDetails.displayName || mcpServerName);
184
+ const mcpServerId = serverDetails.mcpServerId;
185
+ let endpointUri = this.getConnectionUri(serverDetails, {
186
+ protocolBinding: "JSONRPC"
187
+ }).url;
188
+ if (!endpointUri) {
189
+ endpointUri = this.getConnectionUri(serverDetails, {
190
+ protocolBinding: "HTTP+JSON"
191
+ }).url;
192
+ }
193
+ if (!endpointUri) {
194
+ throw new Error(
195
+ `MCP Server endpoint URI not found for: ${mcpServerName}`
196
+ );
197
+ }
198
+ let authScheme = options == null ? void 0 : options.authScheme;
199
+ if (mcpServerId && !authScheme) {
200
+ try {
201
+ const bindingsData = await this.makeRequest("bindings");
202
+ const bindings = bindingsData.bindings || [];
203
+ for (const b of bindings) {
204
+ const targetId = ((_a = b.target) == null ? void 0 : _a.identifier) || "";
205
+ if (targetId.endsWith(mcpServerId)) {
206
+ const authProvider = (_b = b.authProviderBinding) == null ? void 0 : _b.authProvider;
207
+ if (authProvider) {
208
+ authScheme = {
209
+ type: "gcpAuthProviderScheme",
210
+ name: authProvider,
211
+ continueUri: options == null ? void 0 : options.continueUri
212
+ };
213
+ break;
214
+ }
215
+ }
216
+ }
217
+ } catch (err) {
218
+ const msg = err instanceof Error ? err.message : String(err);
219
+ import_logger.logger.warn(
220
+ `Failed to fetch bindings for MCP Server ${mcpServerName}: ${msg}`
221
+ );
222
+ }
223
+ }
224
+ const connectionParams = {
225
+ type: "StreamableHTTPConnectionParams",
226
+ url: endpointUri
227
+ };
228
+ const combinedHeaderProvider = async (context) => {
229
+ const headers = {};
230
+ if (!authScheme && !(options == null ? void 0 : options.authCredential) && (0, import_helpers.isGoogleApi)(endpointUri)) {
231
+ Object.assign(headers, await this.getAuthHeaders());
232
+ }
233
+ if (this.headerProvider && context) {
234
+ Object.assign(headers, this.headerProvider(context));
235
+ }
236
+ return headers;
237
+ };
238
+ return new import_agent_registry_mcp_toolset.AgentRegistrySingleMCPToolset({
239
+ destinationResourceId: mcpServerId,
240
+ connectionParams,
241
+ prefix: name,
242
+ headerProvider: combinedHeaderProvider,
243
+ authScheme,
244
+ authCredential: options == null ? void 0 : options.authCredential
245
+ });
246
+ }
247
+ // --- Endpoint Methods ---
248
+ async listEndpoints(options) {
249
+ const params = {};
250
+ if (options == null ? void 0 : options.filterStr) {
251
+ params["filter"] = options.filterStr;
252
+ }
253
+ if (options == null ? void 0 : options.pageSize) {
254
+ params["pageSize"] = String(options.pageSize);
255
+ }
256
+ if (options == null ? void 0 : options.pageToken) {
257
+ params["pageToken"] = options.pageToken;
258
+ }
259
+ return this.makeRequest("endpoints", params);
260
+ }
261
+ async getEndpoint(name) {
262
+ return this.makeRequest(name);
263
+ }
264
+ async getModelName(endpointName) {
265
+ const endpointDetails = await this.getEndpoint(endpointName);
266
+ const { url } = this.getConnectionUri(endpointDetails);
267
+ if (!url) {
268
+ throw new Error(`Connection URI not found for endpoint: ${endpointName}`);
269
+ }
270
+ const uri = url.replace(/:\w+$/, "");
271
+ if (uri.startsWith("projects/")) {
272
+ return uri;
273
+ }
274
+ const match = uri.match(/(projects\/.+)/);
275
+ if (match) {
276
+ return match[1];
277
+ }
278
+ return uri;
279
+ }
280
+ // --- Agent Methods ---
281
+ async listAgents(options) {
282
+ const params = {};
283
+ if (options == null ? void 0 : options.filterStr) {
284
+ params["filter"] = options.filterStr;
285
+ }
286
+ if (options == null ? void 0 : options.pageSize) {
287
+ params["pageSize"] = String(options.pageSize);
288
+ }
289
+ if (options == null ? void 0 : options.pageToken) {
290
+ params["pageToken"] = options.pageToken;
291
+ }
292
+ return this.makeRequest("agents", params);
293
+ }
294
+ async getAgentInfo(name) {
295
+ return this.makeRequest(name);
296
+ }
297
+ async getRemoteA2AAgent(agentName, options) {
298
+ const agentInfo = await this.getAgentInfo(agentName);
299
+ const card = agentInfo.card || {};
300
+ const cardContent = card.content;
301
+ if (card.type === "A2A_AGENT_CARD" && cardContent) {
302
+ const agentCard2 = cardContent;
303
+ const name2 = (0, import_helpers.cleanName)(agentCard2.name);
304
+ return new import_a2a_remote_agent.RemoteA2AAgent({
305
+ name: name2,
306
+ agentCard: agentCard2,
307
+ description: agentCard2.description,
308
+ client: options == null ? void 0 : options.client,
309
+ clientFactory: options == null ? void 0 : options.clientFactory
310
+ });
311
+ }
312
+ const name = (0, import_helpers.cleanName)(agentInfo.displayName || agentName);
313
+ const description = agentInfo.description || "";
314
+ const version = agentInfo.version || "";
315
+ const { url, protocolVersion, protocolBinding } = this.getConnectionUri(
316
+ agentInfo,
317
+ {
318
+ protocolType: import_types.ProtocolType.A2A_AGENT
319
+ }
320
+ );
321
+ if (!url) {
322
+ throw new Error(`A2A connection URI not found for Agent: ${agentName}`);
323
+ }
324
+ const skills = (agentInfo.skills || []).map(
325
+ (s) => ({
326
+ id: s.id,
327
+ name: s.name,
328
+ description: s.description || "",
329
+ tags: s.tags || [],
330
+ examples: s.examples || []
331
+ })
332
+ );
333
+ const agentCard = {
334
+ name,
335
+ description,
336
+ version,
337
+ preferredTransport: protocolBinding || "HTTP+JSON",
338
+ protocolVersion: protocolVersion || "0.3.0",
339
+ url,
340
+ skills,
341
+ capabilities: {
342
+ streaming: false
343
+ },
344
+ defaultInputModes: ["text"],
345
+ defaultOutputModes: ["text"]
346
+ };
347
+ return new import_a2a_remote_agent.RemoteA2AAgent({
348
+ name,
349
+ agentCard,
350
+ description,
351
+ client: options == null ? void 0 : options.client,
352
+ clientFactory: options == null ? void 0 : options.clientFactory
353
+ });
354
+ }
355
+ }
356
+ // Annotate the CommonJS export names for ESM import in node:
357
+ 0 && (module.exports = {
358
+ AgentRegistry,
359
+ ...require("./agent_registry_mcp_toolset.js"),
360
+ ...require("./helpers.js"),
361
+ ...require("./types.js")
362
+ });
@@ -0,0 +1,103 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ "use strict";
8
+ var __defProp = Object.defineProperty;
9
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
+ var __getOwnPropNames = Object.getOwnPropertyNames;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __export = (target, all) => {
13
+ for (var name in all)
14
+ __defProp(target, name, { get: all[name], enumerable: true });
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var agent_registry_mcp_toolset_exports = {};
26
+ __export(agent_registry_mcp_toolset_exports, {
27
+ AgentRegistrySingleMCPToolset: () => AgentRegistrySingleMCPToolset
28
+ });
29
+ module.exports = __toCommonJS(agent_registry_mcp_toolset_exports);
30
+ var import_base_toolset = require("../../tools/base_toolset.js");
31
+ var import_mcp_session_manager = require("../../tools/mcp/mcp_session_manager.js");
32
+ var import_mcp_tool = require("../../tools/mcp/mcp_tool.js");
33
+ var import_types2 = require("./types.js");
34
+ /**
35
+ * @license
36
+ * Copyright 2026 Google LLC
37
+ * SPDX-License-Identifier: Apache-2.0
38
+ */
39
+ class AgentRegistrySingleMCPToolset extends import_base_toolset.BaseToolset {
40
+ constructor(options) {
41
+ super(options.toolFilter || [], options.prefix);
42
+ this.destinationResourceId = options.destinationResourceId;
43
+ this.connectionParams = options.connectionParams;
44
+ this.headerProvider = options.headerProvider;
45
+ this.authScheme = options.authScheme;
46
+ this.authCredential = options.authCredential;
47
+ }
48
+ /**
49
+ * Connects to the underlying MCP server, retrieves tool definitions, prefixes tool names,
50
+ * and injects destination telemetry metadata.
51
+ */
52
+ async getTools(context) {
53
+ var _a, _b, _c;
54
+ const headers = {};
55
+ if (this.headerProvider) {
56
+ const providerHeaders = await this.headerProvider(context);
57
+ Object.assign(headers, providerHeaders);
58
+ }
59
+ const connectionParamsCopy = {
60
+ ...this.connectionParams,
61
+ transportOptions: {
62
+ ...this.connectionParams.transportOptions,
63
+ requestInit: {
64
+ ...(_a = this.connectionParams.transportOptions) == null ? void 0 : _a.requestInit,
65
+ headers: {
66
+ ...(_c = (_b = this.connectionParams.transportOptions) == null ? void 0 : _b.requestInit) == null ? void 0 : _c.headers,
67
+ ...headers
68
+ }
69
+ }
70
+ }
71
+ };
72
+ const sessionManager = new import_mcp_session_manager.MCPSessionManager(connectionParamsCopy);
73
+ const session = await sessionManager.createSession();
74
+ const listResult = await session.listTools();
75
+ const tools = listResult.tools.map((tool) => {
76
+ const prefixedName = this.prefix ? `${this.prefix}_${tool.name}` : tool.name;
77
+ const mcpTool = new import_mcp_tool.MCPTool(
78
+ { ...tool, name: prefixedName },
79
+ sessionManager,
80
+ tool.name
81
+ );
82
+ const toolWithMetadata = mcpTool;
83
+ if (this.destinationResourceId) {
84
+ if (!toolWithMetadata.customMetadata) {
85
+ toolWithMetadata.customMetadata = {};
86
+ }
87
+ toolWithMetadata.customMetadata[import_types2.GCP_MCP_SERVER_DESTINATION_ID] = this.destinationResourceId;
88
+ }
89
+ return mcpTool;
90
+ });
91
+ const filter = this.toolFilter;
92
+ if (!filter || Array.isArray(filter) && filter.length === 0) {
93
+ return tools;
94
+ }
95
+ return tools.filter((t) => this.isToolSelected(t, context));
96
+ }
97
+ async close() {
98
+ }
99
+ }
100
+ // Annotate the CommonJS export names for ESM import in node:
101
+ 0 && (module.exports = {
102
+ AgentRegistrySingleMCPToolset
103
+ });
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ "use strict";
8
+ var __defProp = Object.defineProperty;
9
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
+ var __getOwnPropNames = Object.getOwnPropertyNames;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __export = (target, all) => {
13
+ for (var name in all)
14
+ __defProp(target, name, { get: all[name], enumerable: true });
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var helpers_exports = {};
26
+ __export(helpers_exports, {
27
+ cleanName: () => cleanName,
28
+ isGoogleApi: () => isGoogleApi
29
+ });
30
+ module.exports = __toCommonJS(helpers_exports);
31
+ /**
32
+ * @license
33
+ * Copyright 2026 Google LLC
34
+ * SPDX-License-Identifier: Apache-2.0
35
+ */
36
+ function isGoogleApi(url) {
37
+ try {
38
+ const parsed = new URL(url);
39
+ return parsed.hostname === "googleapis.com" || parsed.hostname.endsWith(".googleapis.com");
40
+ } catch {
41
+ return false;
42
+ }
43
+ }
44
+ function cleanName(name) {
45
+ let clean = name.replace(/[^a-zA-Z0-9_]/g, "_");
46
+ clean = clean.replace(/_+/g, "_");
47
+ clean = clean.replace(/^_+|_+$/g, "");
48
+ if (clean && !/^[a-zA-Z_]/.test(clean)) {
49
+ clean = "_" + clean;
50
+ }
51
+ return clean;
52
+ }
53
+ // Annotate the CommonJS export names for ESM import in node:
54
+ 0 && (module.exports = {
55
+ cleanName,
56
+ isGoogleApi
57
+ });
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ "use strict";
8
+ var __defProp = Object.defineProperty;
9
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
+ var __getOwnPropNames = Object.getOwnPropertyNames;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __export = (target, all) => {
13
+ for (var name in all)
14
+ __defProp(target, name, { get: all[name], enumerable: true });
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var types_exports = {};
26
+ __export(types_exports, {
27
+ AGENT_REGISTRY_BASE_URL: () => AGENT_REGISTRY_BASE_URL,
28
+ GCP_MCP_SERVER_DESTINATION_ID: () => GCP_MCP_SERVER_DESTINATION_ID,
29
+ ProtocolType: () => ProtocolType
30
+ });
31
+ module.exports = __toCommonJS(types_exports);
32
+ /**
33
+ * @license
34
+ * Copyright 2026 Google LLC
35
+ * SPDX-License-Identifier: Apache-2.0
36
+ */
37
+ const AGENT_REGISTRY_BASE_URL = "https://agentregistry.googleapis.com/v1alpha";
38
+ const GCP_MCP_SERVER_DESTINATION_ID = "gcp.mcp.server.destination.id";
39
+ var ProtocolType = /* @__PURE__ */ ((ProtocolType2) => {
40
+ ProtocolType2["TYPE_UNSPECIFIED"] = "TYPE_UNSPECIFIED";
41
+ ProtocolType2["A2A_AGENT"] = "A2A_AGENT";
42
+ ProtocolType2["CUSTOM"] = "CUSTOM";
43
+ return ProtocolType2;
44
+ })(ProtocolType || {});
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ AGENT_REGISTRY_BASE_URL,
48
+ GCP_MCP_SERVER_DESTINATION_ID,
49
+ ProtocolType
50
+ });