@google/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 (150) 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 +11 -0
  6. package/dist/cjs/events/event.js +3 -1
  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 +10 -5
  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 +10 -6
  26. package/dist/cjs/tools/mcp/mcp_toolset.js +26 -3
  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/vertex_rag_retrieval_tool.js +64 -0
  32. package/dist/cjs/utils/file_utils.js +28 -0
  33. package/dist/cjs/utils/gemini_schema_util.js +18 -0
  34. package/dist/cjs/utils/partial_copy.js +51 -0
  35. package/dist/cjs/utils/streaming_utils.js +167 -121
  36. package/dist/cjs/utils/vertex_ai_utils.js +50 -0
  37. package/dist/cjs/version.js +1 -1
  38. package/dist/esm/agents/functions.js +4 -0
  39. package/dist/esm/auth/oauth2/oauth2_discovery.js +26 -2
  40. package/dist/esm/code_executors/agent_engine_sandbox_code_executor.js +281 -0
  41. package/dist/esm/code_executors/code_execution_utils.js +1 -1
  42. package/dist/esm/common.js +10 -0
  43. package/dist/esm/events/event.js +3 -1
  44. package/dist/esm/index.js +11 -0
  45. package/dist/esm/integrations/agent_registry/agent_registry.js +333 -0
  46. package/dist/esm/integrations/agent_registry/agent_registry_mcp_toolset.js +77 -0
  47. package/dist/esm/integrations/agent_registry/helpers.js +28 -0
  48. package/dist/esm/integrations/agent_registry/types.js +20 -0
  49. package/dist/esm/memory/vertex_ai_memory_bank_service.js +468 -0
  50. package/dist/esm/runner/in_memory_runner.js +10 -5
  51. package/dist/esm/runner/runner.js +32 -2
  52. package/dist/esm/sessions/database_session_service.js +49 -3
  53. package/dist/esm/sessions/in_memory_session_service.js +70 -14
  54. package/dist/esm/sessions/registry.js +7 -0
  55. package/dist/esm/sessions/vertex_ai_session_service.js +403 -0
  56. package/dist/esm/tools/agent_tool.js +10 -5
  57. package/dist/esm/tools/exit_loop_tool.js +9 -0
  58. package/dist/esm/tools/function_tool.js +7 -2
  59. package/dist/esm/tools/google_maps_grounding_tool.js +54 -0
  60. package/dist/esm/tools/long_running_tool.js +2 -1
  61. package/dist/esm/tools/mcp/mcp_session_manager.js +11 -0
  62. package/dist/esm/tools/mcp/mcp_tool.js +10 -6
  63. package/dist/esm/tools/mcp/mcp_toolset.js +26 -3
  64. package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +48 -0
  65. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +60 -0
  66. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +111 -0
  67. package/dist/esm/tools/skill/load_skill_resource_tool.js +1 -24
  68. package/dist/esm/tools/vertex_rag_retrieval_tool.js +36 -0
  69. package/dist/esm/utils/file_utils.js +26 -0
  70. package/dist/esm/utils/gemini_schema_util.js +18 -0
  71. package/dist/esm/utils/partial_copy.js +23 -0
  72. package/dist/esm/utils/streaming_utils.js +165 -120
  73. package/dist/esm/utils/vertex_ai_utils.js +22 -0
  74. package/dist/esm/version.js +1 -1
  75. package/dist/types/a2a/a2a_remote_agent.d.ts +14 -0
  76. package/dist/types/agents/processors/base_llm_processor.d.ts +12 -4
  77. package/dist/types/agents/processors/basic_llm_request_processor.d.ts +5 -0
  78. package/dist/types/agents/processors/identity_llm_request_processor.d.ts +4 -0
  79. package/dist/types/agents/processors/request_confirmation_llm_request_processor.d.ts +5 -0
  80. package/dist/types/agents/run_config.d.ts +15 -0
  81. package/dist/types/code_executors/agent_engine_sandbox_code_executor.d.ts +51 -0
  82. package/dist/types/common.d.ts +4 -0
  83. package/dist/types/events/event_actions.d.ts +24 -6
  84. package/dist/types/events/structured_events.d.ts +13 -0
  85. package/dist/types/examples/example_util.d.ts +25 -0
  86. package/dist/types/index.d.ts +6 -0
  87. package/dist/types/integrations/agent_registry/agent_registry.d.ts +94 -0
  88. package/dist/types/integrations/agent_registry/agent_registry_mcp_toolset.d.ts +43 -0
  89. package/dist/types/integrations/agent_registry/helpers.d.ts +7 -0
  90. package/dist/types/integrations/agent_registry/types.d.ts +101 -0
  91. package/dist/types/memory/vertex_ai_memory_bank_service.d.ts +52 -0
  92. package/dist/types/runner/in_memory_runner.d.ts +28 -1
  93. package/dist/types/runner/runner.d.ts +47 -0
  94. package/dist/types/sessions/base_session_service.d.ts +18 -0
  95. package/dist/types/sessions/database_session_service.d.ts +1 -1
  96. package/dist/types/sessions/in_memory_session_service.d.ts +1 -1
  97. package/dist/types/sessions/vertex_ai_session_service.d.ts +37 -0
  98. package/dist/types/tools/exit_loop_tool.d.ts +9 -0
  99. package/dist/types/tools/function_tool.d.ts +22 -2
  100. package/dist/types/tools/google_maps_grounding_tool.d.ts +22 -0
  101. package/dist/types/tools/long_running_tool.d.ts +11 -1
  102. package/dist/types/tools/mcp/mcp_session_manager.d.ts +3 -0
  103. package/dist/types/tools/mcp/mcp_toolset.d.ts +2 -1
  104. package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +25 -0
  105. package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +20 -0
  106. package/dist/types/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.d.ts +20 -0
  107. package/dist/types/tools/vertex_rag_retrieval_tool.d.ts +42 -0
  108. package/dist/types/utils/file_utils.d.ts +2 -0
  109. package/dist/types/utils/partial_copy.d.ts +13 -0
  110. package/dist/types/utils/streaming_utils.d.ts +8 -17
  111. package/dist/types/utils/vertex_ai_utils.d.ts +14 -0
  112. package/dist/types/version.d.ts +1 -1
  113. package/dist/web/agents/functions.js +4 -0
  114. package/dist/web/auth/oauth2/oauth2_discovery.js +26 -2
  115. package/dist/web/code_executors/agent_engine_sandbox_code_executor.js +281 -0
  116. package/dist/web/code_executors/code_execution_utils.js +1 -1
  117. package/dist/web/common.js +10 -0
  118. package/dist/web/events/event.js +3 -1
  119. package/dist/web/index.js +11 -0
  120. package/dist/web/integrations/agent_registry/agent_registry.js +333 -0
  121. package/dist/web/integrations/agent_registry/agent_registry_mcp_toolset.js +90 -0
  122. package/dist/web/integrations/agent_registry/helpers.js +28 -0
  123. package/dist/web/integrations/agent_registry/types.js +20 -0
  124. package/dist/web/memory/vertex_ai_memory_bank_service.js +475 -0
  125. package/dist/web/runner/in_memory_runner.js +10 -5
  126. package/dist/web/runner/runner.js +32 -2
  127. package/dist/web/sessions/database_session_service.js +49 -3
  128. package/dist/web/sessions/in_memory_session_service.js +70 -14
  129. package/dist/web/sessions/registry.js +7 -0
  130. package/dist/web/sessions/vertex_ai_session_service.js +414 -0
  131. package/dist/web/tools/agent_tool.js +10 -5
  132. package/dist/web/tools/exit_loop_tool.js +9 -0
  133. package/dist/web/tools/function_tool.js +7 -2
  134. package/dist/web/tools/google_maps_grounding_tool.js +54 -0
  135. package/dist/web/tools/long_running_tool.js +2 -1
  136. package/dist/web/tools/mcp/mcp_session_manager.js +11 -0
  137. package/dist/web/tools/mcp/mcp_tool.js +10 -6
  138. package/dist/web/tools/mcp/mcp_toolset.js +26 -3
  139. package/dist/web/tools/openapi_tool/auth/auth_helpers.js +48 -0
  140. package/dist/web/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +60 -0
  141. package/dist/web/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +111 -0
  142. package/dist/web/tools/skill/load_skill_resource_tool.js +1 -24
  143. package/dist/web/tools/vertex_rag_retrieval_tool.js +36 -0
  144. package/dist/web/utils/file_utils.js +26 -0
  145. package/dist/web/utils/gemini_schema_util.js +18 -0
  146. package/dist/web/utils/partial_copy.js +23 -0
  147. package/dist/web/utils/streaming_utils.js +219 -121
  148. package/dist/web/utils/vertex_ai_utils.js +22 -0
  149. package/dist/web/version.js +1 -1
  150. package/package.json +2 -1
@@ -14,6 +14,7 @@ import {
14
14
  } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
15
15
  class MCPSessionManager {
16
16
  constructor(connectionParams) {
17
+ this.activeSessions = /* @__PURE__ */ new Set();
17
18
  this.connectionParams = connectionParams;
18
19
  }
19
20
  async createSession() {
@@ -45,8 +46,18 @@ class MCPSessionManager {
45
46
  break;
46
47
  }
47
48
  }
49
+ this.activeSessions.add(client);
48
50
  return client;
49
51
  }
52
+ async closeSession(client) {
53
+ if (this.activeSessions.has(client)) {
54
+ this.activeSessions.delete(client);
55
+ await client.close();
56
+ }
57
+ }
58
+ getActiveSessions() {
59
+ return Array.from(this.activeSessions);
60
+ }
50
61
  }
51
62
  export {
52
63
  MCPSessionManager
@@ -26,12 +26,16 @@ class MCPTool extends BaseTool {
26
26
  }
27
27
  async runAsync(request) {
28
28
  const session = await this.mcpSessionManager.createSession();
29
- const callRequest = {};
30
- callRequest.params = { name: this.originalName, arguments: request.args };
31
- const result = await session.callTool(callRequest.params, void 0, {
32
- signal: request.toolContext.abortSignal
33
- });
34
- return result;
29
+ try {
30
+ const callRequest = {};
31
+ callRequest.params = { name: this.originalName, arguments: request.args };
32
+ const result = await session.callTool(callRequest.params, void 0, {
33
+ signal: request.toolContext.abortSignal
34
+ });
35
+ return result;
36
+ } finally {
37
+ await this.mcpSessionManager.closeSession(session);
38
+ }
35
39
  }
36
40
  }
37
41
  export {
@@ -33,21 +33,44 @@ class MCPToolset extends BaseToolset {
33
33
  super(toolFilter, prefix);
34
34
  this.mcpSessionManager = new MCPSessionManager(connectionParams);
35
35
  }
36
- async getTools() {
36
+ async getTools(context) {
37
37
  const session = await this.mcpSessionManager.createSession();
38
- const listResult = await session.listTools();
38
+ let listResult;
39
+ try {
40
+ listResult = await session.listTools();
41
+ } finally {
42
+ await this.mcpSessionManager.closeSession(session);
43
+ }
39
44
  logger.debug("number of tools: ".concat(listResult.tools.length));
40
45
  for (const tool of listResult.tools) {
41
46
  logger.debug("tool: ".concat(tool.name));
42
47
  }
43
- return listResult.tools.map((tool) => {
48
+ const tools = listResult.tools.map((tool) => {
44
49
  const toolWithPrefix = __spreadProps(__spreadValues({}, tool), {
45
50
  name: this.prefix ? "".concat(this.prefix, "_").concat(tool.name) : tool.name
46
51
  });
47
52
  return new MCPTool(toolWithPrefix, this.mcpSessionManager, tool.name);
48
53
  });
54
+ const filter = this.toolFilter;
55
+ if (!filter || Array.isArray(filter) && filter.length === 0) {
56
+ return tools;
57
+ }
58
+ if (Array.isArray(filter)) {
59
+ return tools.filter((tool) => filter.includes(tool.name));
60
+ }
61
+ if (context) {
62
+ return tools.filter((tool) => filter(tool, context));
63
+ }
64
+ logger.warn(
65
+ "MCPToolset: a ToolPredicate toolFilter was provided but getTools() was called without a ReadonlyContext. The filter will not be applied."
66
+ );
67
+ return tools;
49
68
  }
50
69
  async close() {
70
+ const sessions = this.mcpSessionManager.getActiveSessions();
71
+ await Promise.allSettled(
72
+ sessions.map((session) => this.mcpSessionManager.closeSession(session))
73
+ );
51
74
  }
52
75
  }
53
76
  export {
@@ -0,0 +1,48 @@
1
+ import {createRequire as topLevelCreateRequire} from 'module';
2
+ const require = topLevelCreateRequire(import.meta.url);
3
+ /**
4
+ * @license
5
+ * Copyright 2026 Google LLC
6
+ * SPDX-License-Identifier: Apache-2.0
7
+ */
8
+ function applyCredential(url, headers, credential, authScheme) {
9
+ if (!credential) return url;
10
+ if (credential.apiKey) {
11
+ let inLocation;
12
+ let name = "key";
13
+ if (authScheme && authScheme.type === "apiKey") {
14
+ const apiKeyScheme = authScheme;
15
+ inLocation = apiKeyScheme.in;
16
+ name = apiKeyScheme.name;
17
+ }
18
+ if (inLocation === "header") {
19
+ headers[name] = credential.apiKey;
20
+ } else if (inLocation === "query") {
21
+ const separator = url.includes("?") ? "&" : "?";
22
+ url += "".concat(separator).concat(name, "=").concat(encodeURIComponent(credential.apiKey));
23
+ } else {
24
+ headers["Authorization"] = credential.apiKey;
25
+ }
26
+ } else if (credential.http && credential.http.credentials && credential.http.credentials.token) {
27
+ headers["Authorization"] = "Bearer ".concat(credential.http.credentials.token);
28
+ }
29
+ return url;
30
+ }
31
+ function createApiKeyScheme(name, inLocation) {
32
+ return {
33
+ type: "apiKey",
34
+ name,
35
+ in: inLocation
36
+ };
37
+ }
38
+ function createBearerScheme() {
39
+ return {
40
+ type: "http",
41
+ scheme: "bearer"
42
+ };
43
+ }
44
+ export {
45
+ applyCredential,
46
+ createApiKeyScheme,
47
+ createBearerScheme
48
+ };
@@ -0,0 +1,60 @@
1
+ import {createRequire as topLevelCreateRequire} from 'module';
2
+ const require = topLevelCreateRequire(import.meta.url);
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __decorateClass = (decorators, target, key, kind) => {
6
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
7
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
8
+ if (decorator = decorators[i])
9
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
10
+ if (kind && result) __defProp(target, key, result);
11
+ return result;
12
+ };
13
+ /**
14
+ * @license
15
+ * Copyright 2026 Google LLC
16
+ * SPDX-License-Identifier: Apache-2.0
17
+ */
18
+ import {
19
+ AuthCredentialTypes
20
+ } from "../../../../auth/auth_credential.js";
21
+ import { OAuth2CredentialExchanger } from "../../../../auth/oauth2/oauth2_credential_exchanger.js";
22
+ import { experimental } from "../../../../utils/experimental.js";
23
+ import { ServiceAccountCredentialExchanger } from "./service_account_exchanger.js";
24
+ let AutoAuthCredentialExchanger = class {
25
+ constructor() {
26
+ this.exchangers = /* @__PURE__ */ new Map();
27
+ this.exchangers.set(
28
+ AuthCredentialTypes.OAUTH2,
29
+ new OAuth2CredentialExchanger()
30
+ );
31
+ this.exchangers.set(
32
+ AuthCredentialTypes.OPEN_ID_CONNECT,
33
+ new OAuth2CredentialExchanger()
34
+ );
35
+ this.exchangers.set(
36
+ AuthCredentialTypes.SERVICE_ACCOUNT,
37
+ new ServiceAccountCredentialExchanger()
38
+ );
39
+ }
40
+ async exchange(params) {
41
+ const { authCredential, authScheme } = params;
42
+ const exchanger = this.exchangers.get(authCredential.authType);
43
+ if (!exchanger) {
44
+ return {
45
+ credential: authCredential,
46
+ wasExchanged: false
47
+ };
48
+ }
49
+ return exchanger.exchange({ authScheme, authCredential });
50
+ }
51
+ };
52
+ __decorateClass([
53
+ experimental
54
+ ], AutoAuthCredentialExchanger.prototype, "exchange", 1);
55
+ AutoAuthCredentialExchanger = __decorateClass([
56
+ experimental
57
+ ], AutoAuthCredentialExchanger);
58
+ export {
59
+ AutoAuthCredentialExchanger
60
+ };
@@ -0,0 +1,111 @@
1
+ import {createRequire as topLevelCreateRequire} from 'module';
2
+ const require = topLevelCreateRequire(import.meta.url);
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __decorateClass = (decorators, target, key, kind) => {
6
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
7
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
8
+ if (decorator = decorators[i])
9
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
10
+ if (kind && result) __defProp(target, key, result);
11
+ return result;
12
+ };
13
+ /**
14
+ * @license
15
+ * Copyright 2026 Google LLC
16
+ * SPDX-License-Identifier: Apache-2.0
17
+ */
18
+ import { GoogleAuth, JWT } from "google-auth-library";
19
+ import {
20
+ AuthCredentialTypes
21
+ } from "../../../../auth/auth_credential.js";
22
+ import {
23
+ CredentialExchangeError
24
+ } from "../../../../auth/exchanger/base_credential_exchanger.js";
25
+ import { experimental } from "../../../../utils/experimental.js";
26
+ const DEFAULT_SCOPES = ["https://www.googleapis.com/auth/cloud-platform"];
27
+ let ServiceAccountCredentialExchanger = class {
28
+ async exchange(params) {
29
+ const { authCredential } = params;
30
+ if (authCredential.authType !== AuthCredentialTypes.SERVICE_ACCOUNT || !authCredential.serviceAccount) {
31
+ throw new CredentialExchangeError(
32
+ "Invalid credential type for ServiceAccountCredentialExchanger"
33
+ );
34
+ }
35
+ const saConfig = authCredential.serviceAccount;
36
+ if (saConfig.useDefaultCredential) {
37
+ return this.exchangeForDefaultCredential(saConfig);
38
+ }
39
+ return this.exchangeForExplicitCredential(saConfig);
40
+ }
41
+ async exchangeForDefaultCredential(saConfig) {
42
+ try {
43
+ const auth = new GoogleAuth({
44
+ scopes: saConfig.scopes || DEFAULT_SCOPES
45
+ });
46
+ const client = await auth.getClient();
47
+ const tokenResponse = await client.getAccessToken();
48
+ const token = tokenResponse.token;
49
+ if (!token) {
50
+ throw new Error("Failed to get access token from default credentials");
51
+ }
52
+ return {
53
+ credential: {
54
+ authType: AuthCredentialTypes.HTTP,
55
+ http: {
56
+ scheme: "bearer",
57
+ credentials: { token }
58
+ }
59
+ },
60
+ wasExchanged: true
61
+ };
62
+ } catch (error) {
63
+ throw new CredentialExchangeError(
64
+ "Failed to exchange default service account token: ".concat(error.message)
65
+ );
66
+ }
67
+ }
68
+ async exchangeForExplicitCredential(saConfig) {
69
+ const creds = saConfig.serviceAccountCredential;
70
+ if (!creds) {
71
+ throw new CredentialExchangeError(
72
+ "Service account credentials are missing."
73
+ );
74
+ }
75
+ try {
76
+ const client = new JWT({
77
+ email: creds.clientEmail,
78
+ key: creds.privateKey,
79
+ scopes: saConfig.scopes
80
+ });
81
+ const tokens = await client.authorize();
82
+ const token = tokens.access_token;
83
+ if (!token) {
84
+ throw new Error("Failed to get access token from explicit credentials");
85
+ }
86
+ return {
87
+ credential: {
88
+ authType: AuthCredentialTypes.HTTP,
89
+ http: {
90
+ scheme: "bearer",
91
+ credentials: { token }
92
+ }
93
+ },
94
+ wasExchanged: true
95
+ };
96
+ } catch (error) {
97
+ throw new CredentialExchangeError(
98
+ "Failed to exchange explicit service account token: ".concat(error.message)
99
+ );
100
+ }
101
+ }
102
+ };
103
+ __decorateClass([
104
+ experimental
105
+ ], ServiceAccountCredentialExchanger.prototype, "exchange", 1);
106
+ ServiceAccountCredentialExchanger = __decorateClass([
107
+ experimental
108
+ ], ServiceAccountCredentialExchanger);
109
+ export {
110
+ ServiceAccountCredentialExchanger
111
+ };
@@ -18,34 +18,11 @@ var __decorateClass = (decorators, target, key, kind) => {
18
18
  import { Type } from "@google/genai";
19
19
  import path from "node:path";
20
20
  import { experimental } from "../../utils/experimental.js";
21
+ import { guessMimeType } from "../../utils/file_utils.js";
21
22
  import {
22
23
  BaseTool
23
24
  } from "../base_tool.js";
24
25
  const BINARY_FILE_DETECTED_MSG = "Binary file detected. The content has been injected into the conversation history for you to analyze.";
25
- const EXTENSION_TO_MIME_TYPE = {
26
- "pdf": "application/pdf",
27
- "jpg": "image/jpeg",
28
- "jpeg": "image/jpeg",
29
- "png": "image/png",
30
- "gif": "image/gif",
31
- "csv": "text/csv",
32
- "json": "application/json",
33
- "xml": "application/xml",
34
- "sh": "text/x-shellscript",
35
- "bash": "text/x-shellscript",
36
- "py": "text/x-python",
37
- "js": "text/javascript",
38
- "cjs": "text/javascript",
39
- "mjs": "text/javascript",
40
- "ts": "text/javascript",
41
- "cts": "text/javascript",
42
- "mts": "text/javascript"
43
- };
44
- function guessMimeType(filePath) {
45
- var _a;
46
- const ext = ((_a = filePath.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
47
- return EXTENSION_TO_MIME_TYPE[ext] || "application/octet-stream";
48
- }
49
26
  let LoadSkillResourceTool = class extends BaseTool {
50
27
  constructor(toolset) {
51
28
  super({
@@ -0,0 +1,36 @@
1
+ import {createRequire as topLevelCreateRequire} from 'module';
2
+ const require = topLevelCreateRequire(import.meta.url);
3
+ /**
4
+ * @license
5
+ * Copyright 2026 Google LLC
6
+ * SPDX-License-Identifier: Apache-2.0
7
+ */
8
+ import { BaseTool } from "./base_tool.js";
9
+ class VertexRagRetrievalTool extends BaseTool {
10
+ constructor(config) {
11
+ super({
12
+ name: "vertex_rag_retrieval",
13
+ description: "Vertex AI RAG Retrieval Tool"
14
+ });
15
+ this.vertexRagStore = config;
16
+ }
17
+ /**
18
+ * This tool is executed server-side by the Vertex AI RAG Engine.
19
+ * Local execution is not required.
20
+ */
21
+ runAsync() {
22
+ return Promise.resolve();
23
+ }
24
+ async processLlmRequest({
25
+ llmRequest
26
+ }) {
27
+ llmRequest.config = llmRequest.config || {};
28
+ llmRequest.config.tools = llmRequest.config.tools || [];
29
+ llmRequest.config.tools.push({
30
+ retrieval: { vertexRagStore: this.vertexRagStore }
31
+ });
32
+ }
33
+ }
34
+ export {
35
+ VertexRagRetrievalTool
36
+ };
@@ -69,6 +69,32 @@ async function materializeFiles(files, dir = process.cwd()) {
69
69
  }
70
70
  return createdFiles;
71
71
  }
72
+ const EXTENSION_TO_MIME_TYPE = {
73
+ "pdf": "application/pdf",
74
+ "jpg": "image/jpeg",
75
+ "jpeg": "image/jpeg",
76
+ "png": "image/png",
77
+ "gif": "image/gif",
78
+ "csv": "text/csv",
79
+ "json": "application/json",
80
+ "xml": "application/xml",
81
+ "sh": "text/x-shellscript",
82
+ "bash": "text/x-shellscript",
83
+ "py": "text/x-python",
84
+ "js": "text/javascript",
85
+ "cjs": "text/javascript",
86
+ "mjs": "text/javascript",
87
+ "ts": "text/javascript",
88
+ "cts": "text/javascript",
89
+ "mts": "text/javascript"
90
+ };
91
+ function guessMimeType(filePath) {
92
+ var _a;
93
+ const ext = ((_a = filePath.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
94
+ return EXTENSION_TO_MIME_TYPE[ext] || "application/octet-stream";
95
+ }
72
96
  export {
97
+ EXTENSION_TO_MIME_TYPE,
98
+ guessMimeType,
73
99
  materializeFiles
74
100
  };
@@ -112,6 +112,21 @@ function toGeminiSchema(mcpSchema) {
112
112
  mcp.type = "array";
113
113
  } else if (isNullable) {
114
114
  mcp.type = "null";
115
+ } else if (mcp.enum) {
116
+ const enumTypes = new Set(mcp.enum.map((v) => typeof v));
117
+ if (enumTypes.size === 1) {
118
+ const jsType = [...enumTypes][0];
119
+ if (jsType === "string") mcp.type = "string";
120
+ else if (jsType === "number") mcp.type = "number";
121
+ else if (jsType === "boolean") mcp.type = "boolean";
122
+ }
123
+ } else if (mcp.const !== void 0) {
124
+ const jsType = typeof mcp.const;
125
+ let inferredType;
126
+ if (jsType === "string") inferredType = "string";
127
+ else if (jsType === "number") inferredType = "number";
128
+ else if (jsType === "boolean") inferredType = "boolean";
129
+ mcp = __spreadProps(__spreadValues({}, mcp), { type: inferredType, enum: [mcp.const] });
115
130
  }
116
131
  }
117
132
  const geminiType = toGeminiType(mcp.type);
@@ -126,6 +141,9 @@ function toGeminiSchema(mcpSchema) {
126
141
  if (mcp.description) {
127
142
  geminiSchema.description = mcp.description;
128
143
  }
144
+ if (mcp.enum) {
145
+ geminiSchema.enum = mcp.enum.map(String);
146
+ }
129
147
  if (isNullable && mcp.type !== "null") {
130
148
  geminiSchema.nullable = true;
131
149
  }
@@ -0,0 +1,23 @@
1
+ import {createRequire as topLevelCreateRequire} from 'module';
2
+ const require = topLevelCreateRequire(import.meta.url);
3
+ /**
4
+ * @license
5
+ * Copyright 2026 Google LLC
6
+ * SPDX-License-Identifier: Apache-2.0
7
+ */
8
+ function partialCopy(source, targetKeys) {
9
+ const result = {};
10
+ const sourceAsUnknown = source;
11
+ targetKeys.forEach((key) => {
12
+ const keyStr = key;
13
+ if (keyStr in source) {
14
+ result[key] = sourceAsUnknown[keyStr];
15
+ } else {
16
+ result[key] = void 0;
17
+ }
18
+ });
19
+ return result;
20
+ }
21
+ export {
22
+ partialCopy
23
+ };