@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
@@ -46,7 +46,8 @@ class FunctionTool extends (_b = BaseTool, _a = FUNCTION_TOOL_SIGNATURE_SYMBOL,
46
46
  this.parameters = options.parameters;
47
47
  }
48
48
  /**
49
- * Provide a schema for the function.
49
+ * Returns the function declaration derived from the tool's name, description,
50
+ * and parameter schema.
50
51
  */
51
52
  _getDeclaration() {
52
53
  return {
@@ -56,7 +57,11 @@ class FunctionTool extends (_b = BaseTool, _a = FUNCTION_TOOL_SIGNATURE_SYMBOL,
56
57
  };
57
58
  }
58
59
  /**
59
- * Logic for running the tool.
60
+ * Validates the model-provided arguments against the parameter schema and
61
+ * invokes the user-defined `execute` function.
62
+ *
63
+ * @param req The tool request containing arguments and tool context.
64
+ * @returns A promise resolving to the function's return value.
60
65
  */
61
66
  async runAsync(req) {
62
67
  try {
@@ -20,7 +20,8 @@ class LongRunningFunctionTool extends FunctionTool {
20
20
  super({ ...options, isLongRunning: true });
21
21
  }
22
22
  /**
23
- * Provide a schema for the function.
23
+ * Returns the function declaration with an appended instruction warning the
24
+ * model not to re-invoke the tool while it is still running.
24
25
  */
25
26
  _getDeclaration() {
26
27
  const declaration = super._getDeclaration();
@@ -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,13 +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
- await session.close();
35
- 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
+ }
36
39
  }
37
40
  }
38
41
  export {
@@ -16,8 +16,12 @@ class MCPToolset extends BaseToolset {
16
16
  }
17
17
  async getTools(context) {
18
18
  const session = await this.mcpSessionManager.createSession();
19
- const listResult = await session.listTools();
20
- await session.close();
19
+ let listResult;
20
+ try {
21
+ listResult = await session.listTools();
22
+ } finally {
23
+ await this.mcpSessionManager.closeSession(session);
24
+ }
21
25
  logger.debug(`number of tools: ${listResult.tools.length}`);
22
26
  for (const tool of listResult.tools) {
23
27
  logger.debug(`tool: ${tool.name}`);
@@ -45,6 +49,10 @@ class MCPToolset extends BaseToolset {
45
49
  return tools;
46
50
  }
47
51
  async close() {
52
+ const sessions = this.mcpSessionManager.getActiveSessions();
53
+ await Promise.allSettled(
54
+ sessions.map((session) => this.mcpSessionManager.closeSession(session))
55
+ );
48
56
  }
49
57
  }
50
58
  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 += `${separator}${name}=${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 ${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: ${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: ${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({
@@ -51,6 +51,32 @@ async function materializeFiles(files, dir = process.cwd()) {
51
51
  }
52
52
  return createdFiles;
53
53
  }
54
+ const EXTENSION_TO_MIME_TYPE = {
55
+ "pdf": "application/pdf",
56
+ "jpg": "image/jpeg",
57
+ "jpeg": "image/jpeg",
58
+ "png": "image/png",
59
+ "gif": "image/gif",
60
+ "csv": "text/csv",
61
+ "json": "application/json",
62
+ "xml": "application/xml",
63
+ "sh": "text/x-shellscript",
64
+ "bash": "text/x-shellscript",
65
+ "py": "text/x-python",
66
+ "js": "text/javascript",
67
+ "cjs": "text/javascript",
68
+ "mjs": "text/javascript",
69
+ "ts": "text/javascript",
70
+ "cts": "text/javascript",
71
+ "mts": "text/javascript"
72
+ };
73
+ function guessMimeType(filePath) {
74
+ var _a;
75
+ const ext = ((_a = filePath.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
76
+ return EXTENSION_TO_MIME_TYPE[ext] || "application/octet-stream";
77
+ }
54
78
  export {
79
+ EXTENSION_TO_MIME_TYPE,
80
+ guessMimeType,
55
81
  materializeFiles
56
82
  };
@@ -81,6 +81,21 @@ function toGeminiSchema(mcpSchema) {
81
81
  mcp.type = "array";
82
82
  } else if (isNullable) {
83
83
  mcp.type = "null";
84
+ } else if (mcp.enum) {
85
+ const enumTypes = new Set(mcp.enum.map((v) => typeof v));
86
+ if (enumTypes.size === 1) {
87
+ const jsType = [...enumTypes][0];
88
+ if (jsType === "string") mcp.type = "string";
89
+ else if (jsType === "number") mcp.type = "number";
90
+ else if (jsType === "boolean") mcp.type = "boolean";
91
+ }
92
+ } else if (mcp.const !== void 0) {
93
+ const jsType = typeof mcp.const;
94
+ let inferredType;
95
+ if (jsType === "string") inferredType = "string";
96
+ else if (jsType === "number") inferredType = "number";
97
+ else if (jsType === "boolean") inferredType = "boolean";
98
+ mcp = { ...mcp, type: inferredType, enum: [mcp.const] };
84
99
  }
85
100
  }
86
101
  const geminiType = toGeminiType(mcp.type);
@@ -95,6 +110,9 @@ function toGeminiSchema(mcpSchema) {
95
110
  if (mcp.description) {
96
111
  geminiSchema.description = mcp.description;
97
112
  }
113
+ if (mcp.enum) {
114
+ geminiSchema.enum = mcp.enum.map(String);
115
+ }
98
116
  if (isNullable && mcp.type !== "null") {
99
117
  geminiSchema.nullable = true;
100
118
  }
@@ -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
+ };