@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
@@ -53,13 +53,16 @@ class MCPTool extends import_base_tool.BaseTool {
53
53
  }
54
54
  async runAsync(request) {
55
55
  const session = await this.mcpSessionManager.createSession();
56
- const callRequest = {};
57
- callRequest.params = { name: this.originalName, arguments: request.args };
58
- const result = await session.callTool(callRequest.params, void 0, {
59
- signal: request.toolContext.abortSignal
60
- });
61
- await session.close();
62
- return result;
56
+ try {
57
+ const callRequest = {};
58
+ callRequest.params = { name: this.originalName, arguments: request.args };
59
+ const result = await session.callTool(callRequest.params, void 0, {
60
+ signal: request.toolContext.abortSignal
61
+ });
62
+ return result;
63
+ } finally {
64
+ await this.mcpSessionManager.closeSession(session);
65
+ }
63
66
  }
64
67
  }
65
68
  // Annotate the CommonJS export names for ESM import in node:
@@ -43,8 +43,12 @@ class MCPToolset extends import_base_toolset.BaseToolset {
43
43
  }
44
44
  async getTools(context) {
45
45
  const session = await this.mcpSessionManager.createSession();
46
- const listResult = await session.listTools();
47
- await session.close();
46
+ let listResult;
47
+ try {
48
+ listResult = await session.listTools();
49
+ } finally {
50
+ await this.mcpSessionManager.closeSession(session);
51
+ }
48
52
  import_logger.logger.debug(`number of tools: ${listResult.tools.length}`);
49
53
  for (const tool of listResult.tools) {
50
54
  import_logger.logger.debug(`tool: ${tool.name}`);
@@ -72,6 +76,10 @@ class MCPToolset extends import_base_toolset.BaseToolset {
72
76
  return tools;
73
77
  }
74
78
  async close() {
79
+ const sessions = this.mcpSessionManager.getActiveSessions();
80
+ await Promise.allSettled(
81
+ sessions.map((session) => this.mcpSessionManager.closeSession(session))
82
+ );
75
83
  }
76
84
  }
77
85
  // Annotate the CommonJS export names for ESM import in node:
@@ -0,0 +1,78 @@
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 auth_helpers_exports = {};
26
+ __export(auth_helpers_exports, {
27
+ applyCredential: () => applyCredential,
28
+ createApiKeyScheme: () => createApiKeyScheme,
29
+ createBearerScheme: () => createBearerScheme
30
+ });
31
+ module.exports = __toCommonJS(auth_helpers_exports);
32
+ /**
33
+ * @license
34
+ * Copyright 2026 Google LLC
35
+ * SPDX-License-Identifier: Apache-2.0
36
+ */
37
+ function applyCredential(url, headers, credential, authScheme) {
38
+ if (!credential) return url;
39
+ if (credential.apiKey) {
40
+ let inLocation;
41
+ let name = "key";
42
+ if (authScheme && authScheme.type === "apiKey") {
43
+ const apiKeyScheme = authScheme;
44
+ inLocation = apiKeyScheme.in;
45
+ name = apiKeyScheme.name;
46
+ }
47
+ if (inLocation === "header") {
48
+ headers[name] = credential.apiKey;
49
+ } else if (inLocation === "query") {
50
+ const separator = url.includes("?") ? "&" : "?";
51
+ url += `${separator}${name}=${encodeURIComponent(credential.apiKey)}`;
52
+ } else {
53
+ headers["Authorization"] = credential.apiKey;
54
+ }
55
+ } else if (credential.http && credential.http.credentials && credential.http.credentials.token) {
56
+ headers["Authorization"] = `Bearer ${credential.http.credentials.token}`;
57
+ }
58
+ return url;
59
+ }
60
+ function createApiKeyScheme(name, inLocation) {
61
+ return {
62
+ type: "apiKey",
63
+ name,
64
+ in: inLocation
65
+ };
66
+ }
67
+ function createBearerScheme() {
68
+ return {
69
+ type: "http",
70
+ scheme: "bearer"
71
+ };
72
+ }
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ applyCredential,
76
+ createApiKeyScheme,
77
+ createBearerScheme
78
+ });
@@ -0,0 +1,84 @@
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 __decorateClass = (decorators, target, key, kind) => {
26
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
27
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
28
+ if (decorator = decorators[i])
29
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
30
+ if (kind && result) __defProp(target, key, result);
31
+ return result;
32
+ };
33
+ var auto_auth_credential_exchanger_exports = {};
34
+ __export(auto_auth_credential_exchanger_exports, {
35
+ AutoAuthCredentialExchanger: () => AutoAuthCredentialExchanger
36
+ });
37
+ module.exports = __toCommonJS(auto_auth_credential_exchanger_exports);
38
+ var import_auth_credential = require("../../../../auth/auth_credential.js");
39
+ var import_oauth2_credential_exchanger = require("../../../../auth/oauth2/oauth2_credential_exchanger.js");
40
+ var import_experimental = require("../../../../utils/experimental.js");
41
+ var import_service_account_exchanger = require("./service_account_exchanger.js");
42
+ /**
43
+ * @license
44
+ * Copyright 2026 Google LLC
45
+ * SPDX-License-Identifier: Apache-2.0
46
+ */
47
+ let AutoAuthCredentialExchanger = class {
48
+ constructor() {
49
+ this.exchangers = /* @__PURE__ */ new Map();
50
+ this.exchangers.set(
51
+ import_auth_credential.AuthCredentialTypes.OAUTH2,
52
+ new import_oauth2_credential_exchanger.OAuth2CredentialExchanger()
53
+ );
54
+ this.exchangers.set(
55
+ import_auth_credential.AuthCredentialTypes.OPEN_ID_CONNECT,
56
+ new import_oauth2_credential_exchanger.OAuth2CredentialExchanger()
57
+ );
58
+ this.exchangers.set(
59
+ import_auth_credential.AuthCredentialTypes.SERVICE_ACCOUNT,
60
+ new import_service_account_exchanger.ServiceAccountCredentialExchanger()
61
+ );
62
+ }
63
+ async exchange(params) {
64
+ const { authCredential, authScheme } = params;
65
+ const exchanger = this.exchangers.get(authCredential.authType);
66
+ if (!exchanger) {
67
+ return {
68
+ credential: authCredential,
69
+ wasExchanged: false
70
+ };
71
+ }
72
+ return exchanger.exchange({ authScheme, authCredential });
73
+ }
74
+ };
75
+ __decorateClass([
76
+ import_experimental.experimental
77
+ ], AutoAuthCredentialExchanger.prototype, "exchange", 1);
78
+ AutoAuthCredentialExchanger = __decorateClass([
79
+ import_experimental.experimental
80
+ ], AutoAuthCredentialExchanger);
81
+ // Annotate the CommonJS export names for ESM import in node:
82
+ 0 && (module.exports = {
83
+ AutoAuthCredentialExchanger
84
+ });
@@ -0,0 +1,133 @@
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 __decorateClass = (decorators, target, key, kind) => {
26
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
27
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
28
+ if (decorator = decorators[i])
29
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
30
+ if (kind && result) __defProp(target, key, result);
31
+ return result;
32
+ };
33
+ var service_account_exchanger_exports = {};
34
+ __export(service_account_exchanger_exports, {
35
+ ServiceAccountCredentialExchanger: () => ServiceAccountCredentialExchanger
36
+ });
37
+ module.exports = __toCommonJS(service_account_exchanger_exports);
38
+ var import_google_auth_library = require("google-auth-library");
39
+ var import_auth_credential = require("../../../../auth/auth_credential.js");
40
+ var import_base_credential_exchanger = require("../../../../auth/exchanger/base_credential_exchanger.js");
41
+ var import_experimental = require("../../../../utils/experimental.js");
42
+ /**
43
+ * @license
44
+ * Copyright 2026 Google LLC
45
+ * SPDX-License-Identifier: Apache-2.0
46
+ */
47
+ const DEFAULT_SCOPES = ["https://www.googleapis.com/auth/cloud-platform"];
48
+ let ServiceAccountCredentialExchanger = class {
49
+ async exchange(params) {
50
+ const { authCredential } = params;
51
+ if (authCredential.authType !== import_auth_credential.AuthCredentialTypes.SERVICE_ACCOUNT || !authCredential.serviceAccount) {
52
+ throw new import_base_credential_exchanger.CredentialExchangeError(
53
+ "Invalid credential type for ServiceAccountCredentialExchanger"
54
+ );
55
+ }
56
+ const saConfig = authCredential.serviceAccount;
57
+ if (saConfig.useDefaultCredential) {
58
+ return this.exchangeForDefaultCredential(saConfig);
59
+ }
60
+ return this.exchangeForExplicitCredential(saConfig);
61
+ }
62
+ async exchangeForDefaultCredential(saConfig) {
63
+ try {
64
+ const auth = new import_google_auth_library.GoogleAuth({
65
+ scopes: saConfig.scopes || DEFAULT_SCOPES
66
+ });
67
+ const client = await auth.getClient();
68
+ const tokenResponse = await client.getAccessToken();
69
+ const token = tokenResponse.token;
70
+ if (!token) {
71
+ throw new Error("Failed to get access token from default credentials");
72
+ }
73
+ return {
74
+ credential: {
75
+ authType: import_auth_credential.AuthCredentialTypes.HTTP,
76
+ http: {
77
+ scheme: "bearer",
78
+ credentials: { token }
79
+ }
80
+ },
81
+ wasExchanged: true
82
+ };
83
+ } catch (error) {
84
+ throw new import_base_credential_exchanger.CredentialExchangeError(
85
+ `Failed to exchange default service account token: ${error.message}`
86
+ );
87
+ }
88
+ }
89
+ async exchangeForExplicitCredential(saConfig) {
90
+ const creds = saConfig.serviceAccountCredential;
91
+ if (!creds) {
92
+ throw new import_base_credential_exchanger.CredentialExchangeError(
93
+ "Service account credentials are missing."
94
+ );
95
+ }
96
+ try {
97
+ const client = new import_google_auth_library.JWT({
98
+ email: creds.clientEmail,
99
+ key: creds.privateKey,
100
+ scopes: saConfig.scopes
101
+ });
102
+ const tokens = await client.authorize();
103
+ const token = tokens.access_token;
104
+ if (!token) {
105
+ throw new Error("Failed to get access token from explicit credentials");
106
+ }
107
+ return {
108
+ credential: {
109
+ authType: import_auth_credential.AuthCredentialTypes.HTTP,
110
+ http: {
111
+ scheme: "bearer",
112
+ credentials: { token }
113
+ }
114
+ },
115
+ wasExchanged: true
116
+ };
117
+ } catch (error) {
118
+ throw new import_base_credential_exchanger.CredentialExchangeError(
119
+ `Failed to exchange explicit service account token: ${error.message}`
120
+ );
121
+ }
122
+ }
123
+ };
124
+ __decorateClass([
125
+ import_experimental.experimental
126
+ ], ServiceAccountCredentialExchanger.prototype, "exchange", 1);
127
+ ServiceAccountCredentialExchanger = __decorateClass([
128
+ import_experimental.experimental
129
+ ], ServiceAccountCredentialExchanger);
130
+ // Annotate the CommonJS export names for ESM import in node:
131
+ 0 && (module.exports = {
132
+ ServiceAccountCredentialExchanger
133
+ });
@@ -48,6 +48,7 @@ module.exports = __toCommonJS(load_skill_resource_tool_exports);
48
48
  var import_genai = require("@google/genai");
49
49
  var import_node_path = __toESM(require("node:path"), 1);
50
50
  var import_experimental = require("../../utils/experimental.js");
51
+ var import_file_utils = require("../../utils/file_utils.js");
51
52
  var import_base_tool = require("../base_tool.js");
52
53
  /**
53
54
  * @license
@@ -55,30 +56,6 @@ var import_base_tool = require("../base_tool.js");
55
56
  * SPDX-License-Identifier: Apache-2.0
56
57
  */
57
58
  const BINARY_FILE_DETECTED_MSG = "Binary file detected. The content has been injected into the conversation history for you to analyze.";
58
- const EXTENSION_TO_MIME_TYPE = {
59
- "pdf": "application/pdf",
60
- "jpg": "image/jpeg",
61
- "jpeg": "image/jpeg",
62
- "png": "image/png",
63
- "gif": "image/gif",
64
- "csv": "text/csv",
65
- "json": "application/json",
66
- "xml": "application/xml",
67
- "sh": "text/x-shellscript",
68
- "bash": "text/x-shellscript",
69
- "py": "text/x-python",
70
- "js": "text/javascript",
71
- "cjs": "text/javascript",
72
- "mjs": "text/javascript",
73
- "ts": "text/javascript",
74
- "cts": "text/javascript",
75
- "mts": "text/javascript"
76
- };
77
- function guessMimeType(filePath) {
78
- var _a;
79
- const ext = ((_a = filePath.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
80
- return EXTENSION_TO_MIME_TYPE[ext] || "application/octet-stream";
81
- }
82
59
  let LoadSkillResourceTool = class extends import_base_tool.BaseTool {
83
60
  constructor(toolset) {
84
61
  super({
@@ -197,7 +174,7 @@ let LoadSkillResourceTool = class extends import_base_tool.BaseTool {
197
174
  content = (_b = skillResources.assets) == null ? void 0 : _b[resourcePath.substring("assets/".length)];
198
175
  }
199
176
  if (Buffer.isBuffer(content)) {
200
- const mimeType = guessMimeType(resourcePath);
177
+ const mimeType = (0, import_file_utils.guessMimeType)(resourcePath);
201
178
  llmRequest.contents.push({
202
179
  role: "user",
203
180
  parts: [
@@ -34,6 +34,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
  var file_utils_exports = {};
36
36
  __export(file_utils_exports, {
37
+ EXTENSION_TO_MIME_TYPE: () => EXTENSION_TO_MIME_TYPE,
38
+ guessMimeType: () => guessMimeType,
37
39
  materializeFiles: () => materializeFiles
38
40
  });
39
41
  module.exports = __toCommonJS(file_utils_exports);
@@ -88,7 +90,33 @@ async function materializeFiles(files, dir = process.cwd()) {
88
90
  }
89
91
  return createdFiles;
90
92
  }
93
+ const EXTENSION_TO_MIME_TYPE = {
94
+ "pdf": "application/pdf",
95
+ "jpg": "image/jpeg",
96
+ "jpeg": "image/jpeg",
97
+ "png": "image/png",
98
+ "gif": "image/gif",
99
+ "csv": "text/csv",
100
+ "json": "application/json",
101
+ "xml": "application/xml",
102
+ "sh": "text/x-shellscript",
103
+ "bash": "text/x-shellscript",
104
+ "py": "text/x-python",
105
+ "js": "text/javascript",
106
+ "cjs": "text/javascript",
107
+ "mjs": "text/javascript",
108
+ "ts": "text/javascript",
109
+ "cts": "text/javascript",
110
+ "mts": "text/javascript"
111
+ };
112
+ function guessMimeType(filePath) {
113
+ var _a;
114
+ const ext = ((_a = filePath.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
115
+ return EXTENSION_TO_MIME_TYPE[ext] || "application/octet-stream";
116
+ }
91
117
  // Annotate the CommonJS export names for ESM import in node:
92
118
  0 && (module.exports = {
119
+ EXTENSION_TO_MIME_TYPE,
120
+ guessMimeType,
93
121
  materializeFiles
94
122
  });
@@ -108,6 +108,21 @@ function toGeminiSchema(mcpSchema) {
108
108
  mcp.type = "array";
109
109
  } else if (isNullable) {
110
110
  mcp.type = "null";
111
+ } else if (mcp.enum) {
112
+ const enumTypes = new Set(mcp.enum.map((v) => typeof v));
113
+ if (enumTypes.size === 1) {
114
+ const jsType = [...enumTypes][0];
115
+ if (jsType === "string") mcp.type = "string";
116
+ else if (jsType === "number") mcp.type = "number";
117
+ else if (jsType === "boolean") mcp.type = "boolean";
118
+ }
119
+ } else if (mcp.const !== void 0) {
120
+ const jsType = typeof mcp.const;
121
+ let inferredType;
122
+ if (jsType === "string") inferredType = "string";
123
+ else if (jsType === "number") inferredType = "number";
124
+ else if (jsType === "boolean") inferredType = "boolean";
125
+ mcp = { ...mcp, type: inferredType, enum: [mcp.const] };
111
126
  }
112
127
  }
113
128
  const geminiType = toGeminiType(mcp.type);
@@ -122,6 +137,9 @@ function toGeminiSchema(mcpSchema) {
122
137
  if (mcp.description) {
123
138
  geminiSchema.description = mcp.description;
124
139
  }
140
+ if (mcp.enum) {
141
+ geminiSchema.enum = mcp.enum.map(String);
142
+ }
125
143
  if (isNullable && mcp.type !== "null") {
126
144
  geminiSchema.nullable = true;
127
145
  }
@@ -0,0 +1,51 @@
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 partial_copy_exports = {};
26
+ __export(partial_copy_exports, {
27
+ partialCopy: () => partialCopy
28
+ });
29
+ module.exports = __toCommonJS(partial_copy_exports);
30
+ /**
31
+ * @license
32
+ * Copyright 2026 Google LLC
33
+ * SPDX-License-Identifier: Apache-2.0
34
+ */
35
+ function partialCopy(source, targetKeys) {
36
+ const result = {};
37
+ const sourceAsUnknown = source;
38
+ targetKeys.forEach((key) => {
39
+ const keyStr = key;
40
+ if (keyStr in source) {
41
+ result[key] = sourceAsUnknown[keyStr];
42
+ } else {
43
+ result[key] = void 0;
44
+ }
45
+ });
46
+ return result;
47
+ }
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ partialCopy
51
+ });