@google/adk 0.2.5 → 0.4.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 (264) hide show
  1. package/dist/cjs/a2a/part_converter_utils.js +210 -0
  2. package/dist/cjs/agents/active_streaming_tool.js +1 -1
  3. package/dist/cjs/agents/base_agent.js +46 -24
  4. package/dist/cjs/agents/base_llm_processor.js +1 -1
  5. package/dist/cjs/agents/callback_context.js +5 -2
  6. package/dist/cjs/agents/content_processor_utils.js +16 -8
  7. package/dist/cjs/agents/functions.js +81 -30
  8. package/dist/cjs/agents/instructions.js +1 -1
  9. package/dist/cjs/agents/invocation_context.js +1 -1
  10. package/dist/cjs/agents/live_request_queue.js +1 -1
  11. package/dist/cjs/agents/llm_agent.js +106 -62
  12. package/dist/cjs/agents/loop_agent.js +3 -2
  13. package/dist/cjs/agents/parallel_agent.js +4 -5
  14. package/dist/cjs/agents/readonly_context.js +13 -1
  15. package/dist/cjs/agents/run_config.js +2 -1
  16. package/dist/cjs/agents/sequential_agent.js +1 -1
  17. package/dist/cjs/agents/transcription_entry.js +1 -1
  18. package/dist/cjs/artifacts/base_artifact_service.js +1 -1
  19. package/dist/cjs/artifacts/file_artifact_service.js +491 -0
  20. package/dist/cjs/artifacts/gcs_artifact_service.js +145 -58
  21. package/dist/cjs/artifacts/in_memory_artifact_service.js +72 -10
  22. package/dist/cjs/artifacts/registry.js +55 -0
  23. package/dist/cjs/auth/auth_credential.js +1 -1
  24. package/dist/cjs/auth/auth_handler.js +4 -2
  25. package/dist/cjs/auth/auth_schemes.js +1 -1
  26. package/dist/cjs/auth/auth_tool.js +1 -1
  27. package/dist/cjs/auth/credential_service/base_credential_service.js +1 -1
  28. package/dist/cjs/auth/credential_service/in_memory_credential_service.js +1 -1
  29. package/dist/cjs/auth/exchanger/base_credential_exchanger.js +1 -1
  30. package/dist/cjs/auth/exchanger/credential_exchanger_registry.js +1 -1
  31. package/dist/cjs/code_executors/base_code_executor.js +4 -2
  32. package/dist/cjs/code_executors/built_in_code_executor.js +8 -4
  33. package/dist/cjs/code_executors/code_execution_utils.js +1 -1
  34. package/dist/cjs/code_executors/code_executor_context.js +6 -6
  35. package/dist/cjs/common.js +18 -1
  36. package/dist/cjs/events/event.js +34 -7
  37. package/dist/cjs/events/event_actions.js +2 -2
  38. package/dist/cjs/events/structured_events.js +105 -0
  39. package/dist/cjs/examples/base_example_provider.js +1 -1
  40. package/dist/cjs/examples/example.js +1 -1
  41. package/dist/cjs/examples/example_util.js +1 -1
  42. package/dist/cjs/index.js +54 -83
  43. package/dist/cjs/index_web.js +1 -1
  44. package/dist/cjs/memory/base_memory_service.js +1 -1
  45. package/dist/cjs/memory/in_memory_memory_service.js +4 -2
  46. package/dist/cjs/memory/memory_entry.js +1 -1
  47. package/dist/cjs/models/apigee_llm.js +182 -0
  48. package/dist/cjs/models/base_llm.js +9 -5
  49. package/dist/cjs/models/base_llm_connection.js +1 -1
  50. package/dist/cjs/models/gemini_llm_connection.js +2 -1
  51. package/dist/cjs/models/google_llm.js +73 -54
  52. package/dist/cjs/models/llm_request.js +1 -1
  53. package/dist/cjs/models/llm_response.js +1 -1
  54. package/dist/cjs/models/registry.js +3 -1
  55. package/dist/cjs/plugins/base_plugin.js +13 -1
  56. package/dist/cjs/plugins/logging_plugin.js +51 -14
  57. package/dist/cjs/plugins/plugin_manager.js +57 -25
  58. package/dist/cjs/plugins/security_plugin.js +2 -2
  59. package/dist/cjs/runner/in_memory_runner.js +1 -1
  60. package/dist/cjs/runner/runner.js +142 -96
  61. package/dist/cjs/sessions/base_session_service.js +53 -3
  62. package/dist/cjs/sessions/database_session_service.js +364 -0
  63. package/dist/cjs/sessions/db/operations.js +114 -0
  64. package/dist/cjs/sessions/db/schema.js +204 -0
  65. package/dist/cjs/sessions/in_memory_session_service.js +60 -34
  66. package/dist/cjs/sessions/registry.js +49 -0
  67. package/dist/cjs/sessions/session.js +1 -1
  68. package/dist/cjs/sessions/state.js +1 -1
  69. package/dist/cjs/telemetry/google_cloud.js +8 -10
  70. package/dist/cjs/telemetry/setup.js +16 -8
  71. package/dist/cjs/telemetry/tracing.js +38 -16
  72. package/dist/cjs/tools/agent_tool.js +9 -5
  73. package/dist/cjs/tools/base_tool.js +5 -3
  74. package/dist/cjs/tools/base_toolset.js +1 -1
  75. package/dist/cjs/tools/forwarding_artifact_service.js +18 -2
  76. package/dist/cjs/tools/function_tool.js +2 -3
  77. package/dist/cjs/tools/google_search_tool.js +2 -3
  78. package/dist/cjs/tools/long_running_tool.js +1 -1
  79. package/dist/cjs/tools/mcp/mcp_session_manager.js +17 -11
  80. package/dist/cjs/tools/mcp/mcp_tool.js +2 -4
  81. package/dist/cjs/tools/mcp/mcp_toolset.js +2 -2
  82. package/dist/cjs/tools/tool_confirmation.js +1 -1
  83. package/dist/cjs/tools/tool_context.js +1 -1
  84. package/dist/cjs/utils/client_labels.js +1 -1
  85. package/dist/cjs/utils/env_aware_utils.js +11 -2
  86. package/dist/cjs/utils/gemini_schema_util.js +10 -5
  87. package/dist/cjs/utils/logger.js +48 -4
  88. package/dist/cjs/utils/model_name.js +1 -1
  89. package/dist/cjs/utils/object_notation_utils.js +78 -0
  90. package/dist/cjs/utils/simple_zod_to_json.js +101 -142
  91. package/dist/cjs/utils/variant_utils.js +3 -9
  92. package/dist/cjs/version.js +2 -2
  93. package/dist/esm/a2a/part_converter_utils.js +171 -0
  94. package/dist/esm/agents/base_agent.js +50 -24
  95. package/dist/esm/agents/callback_context.js +4 -1
  96. package/dist/esm/agents/content_processor_utils.js +25 -9
  97. package/dist/esm/agents/functions.js +84 -29
  98. package/dist/esm/agents/llm_agent.js +110 -62
  99. package/dist/esm/agents/loop_agent.js +2 -1
  100. package/dist/esm/agents/parallel_agent.js +3 -4
  101. package/dist/esm/agents/readonly_context.js +12 -0
  102. package/dist/esm/agents/run_config.js +1 -0
  103. package/dist/esm/artifacts/file_artifact_service.js +451 -0
  104. package/dist/esm/artifacts/gcs_artifact_service.js +144 -57
  105. package/dist/esm/artifacts/in_memory_artifact_service.js +69 -8
  106. package/dist/esm/artifacts/registry.js +28 -0
  107. package/dist/esm/auth/auth_handler.js +3 -1
  108. package/dist/esm/code_executors/base_code_executor.js +3 -1
  109. package/dist/esm/code_executors/built_in_code_executor.js +7 -3
  110. package/dist/esm/code_executors/code_executor_context.js +5 -5
  111. package/dist/esm/common.js +12 -2
  112. package/dist/esm/events/event.js +30 -5
  113. package/dist/esm/events/event_actions.js +1 -1
  114. package/dist/esm/events/structured_events.js +74 -0
  115. package/dist/esm/index.js +18 -88
  116. package/dist/esm/memory/in_memory_memory_service.js +3 -1
  117. package/dist/esm/models/apigee_llm.js +152 -0
  118. package/dist/esm/models/base_llm.js +8 -4
  119. package/dist/esm/models/gemini_llm_connection.js +1 -0
  120. package/dist/esm/models/google_llm.js +75 -53
  121. package/dist/esm/models/registry.js +2 -0
  122. package/dist/esm/plugins/base_plugin.js +12 -0
  123. package/dist/esm/plugins/logging_plugin.js +55 -14
  124. package/dist/esm/plugins/plugin_manager.js +56 -24
  125. package/dist/esm/plugins/security_plugin.js +1 -1
  126. package/dist/esm/runner/runner.js +145 -96
  127. package/dist/esm/sessions/base_session_service.js +49 -1
  128. package/dist/esm/sessions/database_session_service.js +350 -0
  129. package/dist/esm/sessions/db/operations.js +87 -0
  130. package/dist/esm/sessions/db/schema.js +172 -0
  131. package/dist/esm/sessions/in_memory_session_service.js +61 -33
  132. package/dist/esm/sessions/registry.js +25 -0
  133. package/dist/esm/telemetry/google_cloud.js +7 -9
  134. package/dist/esm/telemetry/setup.js +23 -9
  135. package/dist/esm/telemetry/tracing.js +37 -15
  136. package/dist/esm/tools/agent_tool.js +8 -4
  137. package/dist/esm/tools/base_tool.js +4 -2
  138. package/dist/esm/tools/forwarding_artifact_service.js +17 -1
  139. package/dist/esm/tools/function_tool.js +1 -2
  140. package/dist/esm/tools/google_search_tool.js +2 -5
  141. package/dist/esm/tools/long_running_tool.js +3 -1
  142. package/dist/esm/tools/mcp/mcp_session_manager.js +22 -12
  143. package/dist/esm/tools/mcp/mcp_tool.js +1 -3
  144. package/dist/esm/tools/mcp/mcp_toolset.js +1 -1
  145. package/dist/esm/utils/env_aware_utils.js +9 -1
  146. package/dist/esm/utils/gemini_schema_util.js +9 -4
  147. package/dist/esm/utils/logger.js +43 -2
  148. package/dist/esm/utils/object_notation_utils.js +47 -0
  149. package/dist/esm/utils/simple_zod_to_json.js +102 -141
  150. package/dist/esm/utils/variant_utils.js +1 -7
  151. package/dist/esm/version.js +1 -1
  152. package/dist/types/a2a/part_converter_utils.d.ts +47 -0
  153. package/dist/types/agents/base_agent.d.ts +2 -1
  154. package/dist/types/agents/callback_context.d.ts +1 -1
  155. package/dist/types/agents/llm_agent.d.ts +12 -12
  156. package/dist/types/agents/loop_agent.d.ts +1 -1
  157. package/dist/types/agents/parallel_agent.d.ts +1 -1
  158. package/dist/types/agents/readonly_context.d.ts +8 -0
  159. package/dist/types/agents/run_config.d.ts +6 -0
  160. package/dist/types/artifacts/base_artifact_service.d.ts +31 -0
  161. package/dist/types/artifacts/file_artifact_service.d.ts +43 -0
  162. package/dist/types/artifacts/gcs_artifact_service.d.ts +3 -1
  163. package/dist/types/artifacts/in_memory_artifact_service.d.ts +8 -5
  164. package/dist/types/artifacts/registry.d.ts +7 -0
  165. package/dist/types/code_executors/built_in_code_executor.d.ts +1 -1
  166. package/dist/types/code_executors/code_executor_context.d.ts +2 -4
  167. package/dist/types/common.d.ts +13 -3
  168. package/dist/types/events/event.d.ts +15 -1
  169. package/dist/types/events/event_actions.d.ts +1 -1
  170. package/dist/types/events/structured_events.d.ts +106 -0
  171. package/dist/types/index.d.ts +7 -3
  172. package/dist/types/models/apigee_llm.d.ts +59 -0
  173. package/dist/types/models/base_llm_connection.d.ts +1 -1
  174. package/dist/types/models/google_llm.d.ts +5 -2
  175. package/dist/types/models/llm_response.d.ts +1 -1
  176. package/dist/types/plugins/logging_plugin.d.ts +12 -12
  177. package/dist/types/plugins/plugin_manager.d.ts +12 -12
  178. package/dist/types/plugins/security_plugin.d.ts +1 -1
  179. package/dist/types/runner/runner.d.ts +16 -1
  180. package/dist/types/sessions/base_session_service.d.ts +20 -0
  181. package/dist/types/sessions/database_session_service.d.ts +31 -0
  182. package/dist/types/sessions/db/operations.d.ts +29 -0
  183. package/dist/types/sessions/db/schema.d.ts +45 -0
  184. package/dist/types/sessions/in_memory_session_service.d.ts +9 -6
  185. package/dist/types/sessions/registry.d.ts +7 -0
  186. package/dist/types/telemetry/setup.d.ts +1 -1
  187. package/dist/types/telemetry/tracing.d.ts +7 -6
  188. package/dist/types/tools/agent_tool.d.ts +1 -1
  189. package/dist/types/tools/base_tool.d.ts +1 -1
  190. package/dist/types/tools/base_toolset.d.ts +2 -1
  191. package/dist/types/tools/forwarding_artifact_service.d.ts +4 -2
  192. package/dist/types/tools/function_tool.d.ts +4 -3
  193. package/dist/types/tools/google_search_tool.d.ts +3 -3
  194. package/dist/types/tools/mcp/mcp_session_manager.d.ts +10 -3
  195. package/dist/types/tools/mcp/mcp_toolset.d.ts +1 -2
  196. package/dist/types/utils/env_aware_utils.d.ts +7 -0
  197. package/dist/types/utils/gemini_schema_util.d.ts +4 -12
  198. package/dist/types/utils/logger.d.ts +11 -10
  199. package/dist/types/utils/object_notation_utils.d.ts +21 -0
  200. package/dist/types/utils/simple_zod_to_json.d.ts +5 -4
  201. package/dist/types/version.d.ts +1 -1
  202. package/dist/web/a2a/part_converter_utils.js +171 -0
  203. package/dist/web/agents/base_agent.js +96 -35
  204. package/dist/web/agents/callback_context.js +4 -1
  205. package/dist/web/agents/content_processor_utils.js +25 -9
  206. package/dist/web/agents/functions.js +84 -29
  207. package/dist/web/agents/llm_agent.js +166 -83
  208. package/dist/web/agents/loop_agent.js +2 -1
  209. package/dist/web/agents/parallel_agent.js +3 -4
  210. package/dist/web/agents/readonly_context.js +12 -0
  211. package/dist/web/agents/run_config.js +2 -1
  212. package/dist/web/artifacts/file_artifact_service.js +506 -0
  213. package/dist/web/artifacts/gcs_artifact_service.js +139 -54
  214. package/dist/web/artifacts/in_memory_artifact_service.js +69 -8
  215. package/dist/web/artifacts/registry.js +28 -0
  216. package/dist/web/auth/auth_handler.js +3 -1
  217. package/dist/web/code_executors/base_code_executor.js +3 -1
  218. package/dist/web/code_executors/built_in_code_executor.js +7 -3
  219. package/dist/web/code_executors/code_executor_context.js +5 -5
  220. package/dist/web/common.js +12 -2
  221. package/dist/web/events/event.js +30 -5
  222. package/dist/web/events/event_actions.js +1 -1
  223. package/dist/web/events/structured_events.js +74 -0
  224. package/dist/web/index.js +18 -8
  225. package/dist/web/memory/in_memory_memory_service.js +3 -1
  226. package/dist/web/models/apigee_llm.js +219 -0
  227. package/dist/web/models/base_llm.js +8 -4
  228. package/dist/web/models/gemini_llm_connection.js +1 -0
  229. package/dist/web/models/google_llm.js +75 -50
  230. package/dist/web/models/registry.js +2 -0
  231. package/dist/web/plugins/base_plugin.js +12 -0
  232. package/dist/web/plugins/logging_plugin.js +55 -14
  233. package/dist/web/plugins/plugin_manager.js +56 -24
  234. package/dist/web/plugins/security_plugin.js +1 -1
  235. package/dist/web/runner/runner.js +192 -108
  236. package/dist/web/sessions/base_session_service.js +49 -1
  237. package/dist/web/sessions/database_session_service.js +368 -0
  238. package/dist/web/sessions/db/operations.js +87 -0
  239. package/dist/web/sessions/db/schema.js +172 -0
  240. package/dist/web/sessions/in_memory_session_service.js +61 -33
  241. package/dist/web/sessions/registry.js +25 -0
  242. package/dist/web/telemetry/google_cloud.js +7 -9
  243. package/dist/web/telemetry/setup.js +23 -9
  244. package/dist/web/telemetry/tracing.js +37 -15
  245. package/dist/web/tools/agent_tool.js +8 -4
  246. package/dist/web/tools/base_tool.js +4 -2
  247. package/dist/web/tools/forwarding_artifact_service.js +17 -1
  248. package/dist/web/tools/function_tool.js +1 -2
  249. package/dist/web/tools/google_search_tool.js +2 -5
  250. package/dist/web/tools/long_running_tool.js +3 -1
  251. package/dist/web/tools/mcp/mcp_session_manager.js +22 -12
  252. package/dist/web/tools/mcp/mcp_tool.js +1 -3
  253. package/dist/web/tools/mcp/mcp_toolset.js +1 -1
  254. package/dist/web/utils/env_aware_utils.js +9 -1
  255. package/dist/web/utils/gemini_schema_util.js +9 -4
  256. package/dist/web/utils/logger.js +43 -2
  257. package/dist/web/utils/object_notation_utils.js +47 -0
  258. package/dist/web/utils/simple_zod_to_json.js +102 -155
  259. package/dist/web/utils/variant_utils.js +1 -7
  260. package/dist/web/version.js +1 -1
  261. package/package.json +16 -5
  262. package/dist/cjs/index.js.map +0 -7
  263. package/dist/esm/index.js.map +0 -7
  264. package/dist/web/index.js.map +0 -7
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -41,8 +41,7 @@ class MCPTool extends import_base_tool.BaseTool {
41
41
  this.mcpSessionManager = mcpSessionManager;
42
42
  }
43
43
  _getDeclaration() {
44
- let declaration;
45
- declaration = {
44
+ return {
46
45
  name: this.mcpTool.name,
47
46
  description: this.mcpTool.description,
48
47
  parameters: (0, import_gemini_schema_util.toGeminiSchema)(this.mcpTool.inputSchema),
@@ -50,7 +49,6 @@ class MCPTool extends import_base_tool.BaseTool {
50
49
  // https://modelcontextprotocol.io/specification/2025-06-18/server/tools#tool-result
51
50
  response: (0, import_gemini_schema_util.toGeminiSchema)(this.mcpTool.outputSchema)
52
51
  };
53
- return declaration;
54
52
  }
55
53
  async runAsync(request) {
56
54
  const session = await this.mcpSessionManager.createSession();
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -41,7 +41,7 @@ class MCPToolset extends import_base_toolset.BaseToolset {
41
41
  super(toolFilter);
42
42
  this.mcpSessionManager = new import_mcp_session_manager.MCPSessionManager(connectionParams);
43
43
  }
44
- async getTools(context) {
44
+ async getTools() {
45
45
  const session = await this.mcpSessionManager.createSession();
46
46
  const listResult = await session.listTools();
47
47
  import_logger.logger.debug(`number of tools: ${listResult.tools.length}`);
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -26,6 +26,7 @@ var env_aware_utils_exports = {};
26
26
  __export(env_aware_utils_exports, {
27
27
  base64Decode: () => base64Decode,
28
28
  base64Encode: () => base64Encode,
29
+ getBooleanEnvVar: () => getBooleanEnvVar,
29
30
  isBase64Encoded: () => isBase64Encoded,
30
31
  isBrowser: () => isBrowser,
31
32
  randomUUID: () => randomUUID
@@ -69,14 +70,22 @@ function base64Decode(data) {
69
70
  function isBase64Encoded(data) {
70
71
  try {
71
72
  return base64Encode(base64Decode(data)) === data;
72
- } catch (e) {
73
+ } catch (_e) {
73
74
  return false;
74
75
  }
75
76
  }
77
+ function getBooleanEnvVar(envVar) {
78
+ if (!process.env) {
79
+ return false;
80
+ }
81
+ const envVarValue = (process.env[envVar] || "").toLowerCase();
82
+ return ["true", "1"].includes(envVarValue);
83
+ }
76
84
  // Annotate the CommonJS export names for ESM import in node:
77
85
  0 && (module.exports = {
78
86
  base64Decode,
79
87
  base64Encode,
88
+ getBooleanEnvVar,
80
89
  isBase64Encoded,
81
90
  isBrowser,
82
91
  randomUUID
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -34,9 +34,9 @@ var import_zod = require("zod");
34
34
  * Copyright 2025 Google LLC
35
35
  * SPDX-License-Identifier: Apache-2.0
36
36
  */
37
- const MCPToolSchema = import_zod.z.object({
37
+ const MCPToolSchemaObject = import_zod.z.object({
38
38
  type: import_zod.z.literal("object"),
39
- properties: import_zod.z.record(import_zod.z.unknown()).optional(),
39
+ properties: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional(),
40
40
  required: import_zod.z.string().array().optional()
41
41
  });
42
42
  function toGeminiType(mcpType) {
@@ -81,12 +81,17 @@ function toGeminiSchema(mcpSchema) {
81
81
  }
82
82
  }
83
83
  const geminiType = toGeminiType(mcp.type);
84
- const geminiSchema = { type: geminiType, description: mcp.description };
84
+ const geminiSchema = {
85
+ type: geminiType,
86
+ description: mcp.description
87
+ };
85
88
  if (geminiType === import_genai.Type.OBJECT) {
86
89
  geminiSchema.properties = {};
87
90
  if (mcp.properties) {
88
91
  for (const name in mcp.properties) {
89
- geminiSchema.properties[name] = recursiveConvert(mcp.properties[name]);
92
+ geminiSchema.properties[name] = recursiveConvert(
93
+ mcp.properties[name]
94
+ );
90
95
  }
91
96
  }
92
97
  geminiSchema.required = mcp.required;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -25,8 +25,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
25
25
  var logger_exports = {};
26
26
  __export(logger_exports, {
27
27
  LogLevel: () => LogLevel,
28
+ getLogger: () => getLogger,
28
29
  logger: () => logger,
29
- setLogLevel: () => setLogLevel
30
+ resetLogger: () => resetLogger,
31
+ setLogLevel: () => setLogLevel,
32
+ setLogger: () => setLogger
30
33
  });
31
34
  module.exports = __toCommonJS(logger_exports);
32
35
  /**
@@ -92,6 +95,18 @@ class SimpleLogger {
92
95
  console.error(getColoredPrefix(3 /* ERROR */), ...args);
93
96
  }
94
97
  }
98
+ class NoOpLogger {
99
+ log(_level, ..._args) {
100
+ }
101
+ debug(..._args) {
102
+ }
103
+ info(..._args) {
104
+ }
105
+ warn(..._args) {
106
+ }
107
+ error(..._args) {
108
+ }
109
+ }
95
110
  const LOG_LEVEL_STR = {
96
111
  [0 /* DEBUG */]: "DEBUG",
97
112
  [1 /* INFO */]: "INFO",
@@ -112,10 +127,39 @@ const RESET_COLOR = "\x1B[0m";
112
127
  function getColoredPrefix(level) {
113
128
  return `${CONSOLE_COLOR_MAP[level]}[ADK ${LOG_LEVEL_STR[level]}]:${RESET_COLOR}`;
114
129
  }
115
- const logger = new SimpleLogger();
130
+ let currentLogger = new SimpleLogger();
131
+ function setLogger(customLogger) {
132
+ currentLogger = customLogger != null ? customLogger : new NoOpLogger();
133
+ }
134
+ function getLogger() {
135
+ return currentLogger;
136
+ }
137
+ function resetLogger() {
138
+ currentLogger = new SimpleLogger();
139
+ }
140
+ const logger = {
141
+ log(level, ...args) {
142
+ currentLogger.log(level, ...args);
143
+ },
144
+ debug(...args) {
145
+ currentLogger.debug(...args);
146
+ },
147
+ info(...args) {
148
+ currentLogger.info(...args);
149
+ },
150
+ warn(...args) {
151
+ currentLogger.warn(...args);
152
+ },
153
+ error(...args) {
154
+ currentLogger.error(...args);
155
+ }
156
+ };
116
157
  // Annotate the CommonJS export names for ESM import in node:
117
158
  0 && (module.exports = {
118
159
  LogLevel,
160
+ getLogger,
119
161
  logger,
120
- setLogLevel
162
+ resetLogger,
163
+ setLogLevel,
164
+ setLogger
121
165
  });
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -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 object_notation_utils_exports = {};
26
+ __export(object_notation_utils_exports, {
27
+ toCamelCase: () => toCamelCase,
28
+ toSnakeCase: () => toSnakeCase
29
+ });
30
+ module.exports = __toCommonJS(object_notation_utils_exports);
31
+ /**
32
+ * @license
33
+ * Copyright 2026 Google LLC
34
+ * SPDX-License-Identifier: Apache-2.0
35
+ */
36
+ function toCamelCase(obj, preserveKeys = []) {
37
+ return toNotation(obj, toCamelCaseKey, "", preserveKeys);
38
+ }
39
+ function toSnakeCase(obj, preserveKeys = []) {
40
+ return toNotation(obj, toSnakeCaseKey, "", preserveKeys);
41
+ }
42
+ const toCamelCaseKey = (key) => key.replace(
43
+ /_([a-z])/g,
44
+ (_match, letter) => letter.toUpperCase()
45
+ );
46
+ const toSnakeCaseKey = (key) => key.replace(/[A-Z]/g, (g) => "_" + g.toLowerCase());
47
+ function toNotation(obj, converter, parentKey = "", preserveKeys = []) {
48
+ if (Array.isArray(obj)) {
49
+ return obj.map(
50
+ (item) => toNotation(item, converter, parentKey, preserveKeys)
51
+ );
52
+ }
53
+ if (typeof obj === "object" && obj !== null) {
54
+ const source = obj;
55
+ const result = {};
56
+ for (const key of Object.keys(source)) {
57
+ const convertedKey = converter(key);
58
+ const fullPath = parentKey !== "" ? parentKey + "." + key : key;
59
+ if (preserveKeys.includes(fullPath)) {
60
+ result[convertedKey] = source[key];
61
+ } else {
62
+ result[convertedKey] = toNotation(
63
+ source[key],
64
+ converter,
65
+ fullPath,
66
+ preserveKeys
67
+ );
68
+ }
69
+ }
70
+ return result;
71
+ }
72
+ return obj;
73
+ }
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ toCamelCase,
77
+ toSnakeCase
78
+ });
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -29,160 +29,119 @@ __export(simple_zod_to_json_exports, {
29
29
  });
30
30
  module.exports = __toCommonJS(simple_zod_to_json_exports);
31
31
  var import_genai = require("@google/genai");
32
- var import_zod = require("zod");
32
+ var import_zod_to_json_schema = require("zod-to-json-schema");
33
+ var import_v4 = require("zod/v4");
33
34
  /**
34
35
  * @license
35
36
  * Copyright 2025 Google LLC
36
37
  * SPDX-License-Identifier: Apache-2.0
37
38
  */
38
- function isZodObject(obj) {
39
- var _a;
40
- return obj !== null && typeof obj === "object" && ((_a = obj._def) == null ? void 0 : _a.typeName) === "ZodObject";
39
+ function isZodSchema(obj) {
40
+ return obj !== null && typeof obj === "object" && "parse" in obj && typeof obj.parse === "function" && "safeParse" in obj && typeof obj.safeParse === "function";
41
+ }
42
+ function isZodV3Schema(obj) {
43
+ return isZodSchema(obj) && !("_zod" in obj);
44
+ }
45
+ function isZodV4Schema(obj) {
46
+ return isZodSchema(obj) && "_zod" in obj;
41
47
  }
42
- function parseZodType(zodType) {
43
- const def = zodType._def;
44
- if (!def) {
45
- return {};
48
+ function getZodTypeName(schema) {
49
+ var _a, _b;
50
+ const schemaAny = schema;
51
+ if ((_a = schemaAny._def) == null ? void 0 : _a.typeName) {
52
+ return schemaAny._def.typeName;
46
53
  }
47
- const description = def.description;
48
- const result = {};
49
- if (description) result.description = description;
50
- const returnResult = (result2) => {
51
- if (result2.description === void 0) {
52
- delete result2.description;
53
- }
54
- return result2;
55
- };
56
- switch (def.typeName) {
57
- case import_zod.z.ZodFirstPartyTypeKind.ZodString:
58
- result.type = import_genai.Type.STRING;
59
- for (const check of def.checks || []) {
60
- if (check.kind === "min")
61
- result.minLength = check.value.toString();
62
- else if (check.kind === "max")
63
- result.maxLength = check.value.toString();
64
- else if (check.kind === "email")
65
- result.format = "email";
66
- else if (check.kind === "uuid")
67
- result.format = "uuid";
68
- else if (check.kind === "url")
69
- result.format = "uri";
70
- else if (check.kind === "regex")
71
- result.pattern = check.regex.source;
72
- }
73
- return returnResult(result);
74
- case import_zod.z.ZodFirstPartyTypeKind.ZodNumber:
75
- result.type = import_genai.Type.NUMBER;
76
- for (const check of def.checks || []) {
77
- if (check.kind === "min")
78
- result.minimum = check.value;
79
- else if (check.kind === "max")
80
- result.maximum = check.value;
81
- else if (check.kind === "int")
82
- result.type = import_genai.Type.INTEGER;
83
- }
84
- return returnResult(result);
85
- case import_zod.z.ZodFirstPartyTypeKind.ZodBoolean:
86
- result.type = import_genai.Type.BOOLEAN;
87
- return returnResult(result);
88
- case import_zod.z.ZodFirstPartyTypeKind.ZodArray:
89
- result.type = import_genai.Type.ARRAY;
90
- result.items = parseZodType(def.type);
91
- if (def.minLength) result.minItems = def.minLength.value.toString();
92
- if (def.maxLength) result.maxItems = def.maxLength.value.toString();
93
- return returnResult(result);
94
- case import_zod.z.ZodFirstPartyTypeKind.ZodObject: {
95
- const nestedSchema = zodObjectToSchema(zodType);
96
- return nestedSchema;
97
- }
98
- case import_zod.z.ZodFirstPartyTypeKind.ZodLiteral:
99
- const literalType = typeof def.value;
100
- result.enum = [def.value.toString()];
101
- if (literalType === "string") {
102
- result.type = import_genai.Type.STRING;
103
- } else if (literalType === "number") {
104
- result.type = import_genai.Type.NUMBER;
105
- } else if (literalType === "boolean") {
106
- result.type = import_genai.Type.BOOLEAN;
107
- } else if (def.value === null) {
108
- result.type = import_genai.Type.NULL;
109
- } else {
110
- throw new Error(`Unsupported ZodLiteral value type: ${literalType}`);
111
- }
112
- return returnResult(result);
113
- case import_zod.z.ZodFirstPartyTypeKind.ZodEnum:
114
- result.type = import_genai.Type.STRING;
115
- result.enum = def.values;
116
- return returnResult(result);
117
- case import_zod.z.ZodFirstPartyTypeKind.ZodNativeEnum:
118
- result.type = import_genai.Type.STRING;
119
- result.enum = Object.values(def.values);
120
- return returnResult(result);
121
- case import_zod.z.ZodFirstPartyTypeKind.ZodUnion:
122
- result.anyOf = def.options.map(parseZodType);
123
- return returnResult(result);
124
- case import_zod.z.ZodFirstPartyTypeKind.ZodOptional:
125
- return parseZodType(def.innerType);
126
- case import_zod.z.ZodFirstPartyTypeKind.ZodNullable:
127
- const nullableInner = parseZodType(def.innerType);
128
- return nullableInner ? returnResult({
129
- anyOf: [nullableInner, { type: import_genai.Type.NULL }],
130
- ...description && { description }
131
- }) : returnResult({ type: import_genai.Type.NULL, ...description && { description } });
132
- case import_zod.z.ZodFirstPartyTypeKind.ZodDefault:
133
- const defaultInner = parseZodType(def.innerType);
134
- if (defaultInner) defaultInner.default = def.defaultValue();
135
- return defaultInner;
136
- case import_zod.z.ZodFirstPartyTypeKind.ZodBranded:
137
- return parseZodType(def.type);
138
- case import_zod.z.ZodFirstPartyTypeKind.ZodReadonly:
139
- return parseZodType(def.innerType);
140
- case import_zod.z.ZodFirstPartyTypeKind.ZodNull:
141
- result.type = import_genai.Type.NULL;
142
- return returnResult(result);
143
- case import_zod.z.ZodFirstPartyTypeKind.ZodAny:
144
- case import_zod.z.ZodFirstPartyTypeKind.ZodUnknown:
145
- return returnResult({ ...description && { description } });
146
- default:
147
- throw new Error(`Unsupported Zod type: ${def.typeName}`);
54
+ const zod4Type = (_b = schemaAny._def) == null ? void 0 : _b.type;
55
+ if (typeof zod4Type === "string" && zod4Type) {
56
+ return "Zod" + zod4Type.charAt(0).toUpperCase() + zod4Type.slice(1);
148
57
  }
58
+ return void 0;
59
+ }
60
+ function isZodObject(obj) {
61
+ return isZodSchema(obj) && getZodTypeName(obj) === "ZodObject";
149
62
  }
150
63
  function zodObjectToSchema(schema) {
151
- if (schema._def.typeName !== import_zod.z.ZodFirstPartyTypeKind.ZodObject) {
152
- throw new Error("Expected a ZodObject");
64
+ if (!isZodObject(schema)) {
65
+ throw new Error("Expected a Zod Object");
153
66
  }
154
- const shape = schema.shape;
155
- const properties = {};
156
- const required = [];
157
- for (const key in shape) {
158
- const fieldSchema = shape[key];
159
- const parsedField = parseZodType(fieldSchema);
160
- if (parsedField) {
161
- properties[key] = parsedField;
162
- }
163
- let currentSchema = fieldSchema;
164
- let isOptional = false;
165
- while (currentSchema._def.typeName === import_zod.z.ZodFirstPartyTypeKind.ZodOptional || currentSchema._def.typeName === import_zod.z.ZodFirstPartyTypeKind.ZodDefault) {
166
- isOptional = true;
167
- currentSchema = currentSchema._def.innerType;
168
- }
169
- if (!isOptional) {
170
- required.push(key);
171
- }
67
+ if (isZodV4Schema(schema)) {
68
+ return (0, import_v4.toJSONSchema)(schema, {
69
+ target: "openapi-3.0",
70
+ io: "input",
71
+ override: (ctx) => {
72
+ var _a;
73
+ const { jsonSchema } = ctx;
74
+ if (jsonSchema.additionalProperties !== void 0) {
75
+ delete jsonSchema.additionalProperties;
76
+ }
77
+ if (jsonSchema.readOnly !== void 0) {
78
+ delete jsonSchema.readOnly;
79
+ }
80
+ if (jsonSchema.maxItems !== void 0) {
81
+ jsonSchema.maxItems = jsonSchema.maxItems.toString();
82
+ }
83
+ if (jsonSchema.format === "email" || jsonSchema.format === "uuid") {
84
+ delete jsonSchema.pattern;
85
+ }
86
+ if (jsonSchema.minItems !== void 0) {
87
+ jsonSchema.minItems = jsonSchema.minItems.toString();
88
+ }
89
+ if (jsonSchema.minLength !== void 0) {
90
+ jsonSchema.minLength = jsonSchema.minLength.toString();
91
+ }
92
+ if (jsonSchema.maxLength !== void 0) {
93
+ jsonSchema.maxLength = jsonSchema.maxLength.toString();
94
+ }
95
+ if (((_a = jsonSchema.enum) == null ? void 0 : _a.length) === 1 && jsonSchema.enum[0] === null) {
96
+ jsonSchema.type = import_genai.Type.NULL;
97
+ delete jsonSchema.enum;
98
+ }
99
+ if (jsonSchema.type !== void 0) {
100
+ jsonSchema.type = jsonSchema.type.toUpperCase();
101
+ }
102
+ }
103
+ });
172
104
  }
173
- const catchall = schema._def.catchall;
174
- let additionalProperties = false;
175
- if (catchall && catchall._def.typeName !== import_zod.z.ZodFirstPartyTypeKind.ZodNever) {
176
- additionalProperties = parseZodType(catchall) || true;
177
- } else {
178
- additionalProperties = schema._def.unknownKeys === "passthrough";
105
+ if (isZodV3Schema(schema)) {
106
+ return (0, import_zod_to_json_schema.zodToJsonSchema)(schema, {
107
+ target: "openApi3",
108
+ emailStrategy: "format:email",
109
+ postProcess: (jsonSchema) => {
110
+ var _a, _b, _c, _d, _e, _f, _g;
111
+ if (!jsonSchema) {
112
+ return;
113
+ }
114
+ if (jsonSchema.additionalProperties !== void 0) {
115
+ delete jsonSchema.additionalProperties;
116
+ }
117
+ if (jsonSchema.maxItems !== void 0) {
118
+ jsonSchema.maxItems = (_a = jsonSchema.maxItems) == null ? void 0 : _a.toString();
119
+ }
120
+ if (jsonSchema.minItems !== void 0) {
121
+ jsonSchema.minItems = (_b = jsonSchema.minItems) == null ? void 0 : _b.toString();
122
+ }
123
+ if (jsonSchema.minLength !== void 0) {
124
+ jsonSchema.minLength = (_c = jsonSchema.minLength) == null ? void 0 : _c.toString();
125
+ }
126
+ if (jsonSchema.maxLength !== void 0) {
127
+ jsonSchema.maxLength = (_d = jsonSchema.maxLength) == null ? void 0 : _d.toString();
128
+ }
129
+ if (((_e = jsonSchema.enum) == null ? void 0 : _e.length) === 1 && jsonSchema.enum[0] === "null") {
130
+ jsonSchema.type = import_genai.Type.NULL;
131
+ delete jsonSchema.enum;
132
+ }
133
+ if (jsonSchema.type === "integer" && jsonSchema.format !== "int64") {
134
+ (_f = jsonSchema.minimum) != null ? _f : jsonSchema.minimum = Number.MIN_SAFE_INTEGER;
135
+ (_g = jsonSchema.maximum) != null ? _g : jsonSchema.maximum = Number.MAX_SAFE_INTEGER;
136
+ }
137
+ if (jsonSchema.type !== void 0) {
138
+ jsonSchema.type = jsonSchema.type.toUpperCase();
139
+ }
140
+ return jsonSchema;
141
+ }
142
+ });
179
143
  }
180
- return {
181
- type: import_genai.Type.OBJECT,
182
- properties,
183
- required: required.length > 0 ? required : [],
184
- ...schema._def.description ? { description: schema._def.description } : {}
185
- };
144
+ throw new Error("Unsupported Zod schema version.");
186
145
  }
187
146
  // Annotate the CommonJS export names for ESM import in node:
188
147
  0 && (module.exports = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -28,6 +28,7 @@ __export(variant_utils_exports, {
28
28
  getGoogleLlmVariant: () => getGoogleLlmVariant
29
29
  });
30
30
  module.exports = __toCommonJS(variant_utils_exports);
31
+ var import_env_aware_utils = require("./env_aware_utils.js");
31
32
  /**
32
33
  * @license
33
34
  * Copyright 2025 Google LLC
@@ -39,14 +40,7 @@ var GoogleLLMVariant = /* @__PURE__ */ ((GoogleLLMVariant2) => {
39
40
  return GoogleLLMVariant2;
40
41
  })(GoogleLLMVariant || {});
41
42
  function getGoogleLlmVariant() {
42
- return getBooleanEnvVar("GOOGLE_GENAI_USE_VERTEXAI") ? "VERTEX_AI" /* VERTEX_AI */ : "GEMINI_API" /* GEMINI_API */;
43
- }
44
- function getBooleanEnvVar(envVar) {
45
- if (!process.env) {
46
- return false;
47
- }
48
- const envVarValue = (process.env[envVar] || "").toLowerCase();
49
- return ["true", "1"].includes(envVar.toLowerCase());
43
+ return (0, import_env_aware_utils.getBooleanEnvVar)("GOOGLE_GENAI_USE_VERTEXAI") ? "VERTEX_AI" /* VERTEX_AI */ : "GEMINI_API" /* GEMINI_API */;
50
44
  }
51
45
  // Annotate the CommonJS export names for ESM import in node:
52
46
  0 && (module.exports = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -32,7 +32,7 @@ module.exports = __toCommonJS(version_exports);
32
32
  * Copyright 2025 Google LLC
33
33
  * SPDX-License-Identifier: Apache-2.0
34
34
  */
35
- const version = "0.2.5";
35
+ const version = "0.4.0";
36
36
  // Annotate the CommonJS export names for ESM import in node:
37
37
  0 && (module.exports = {
38
38
  version