@paean-ai/adk 0.2.18 → 0.2.20

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 (254) hide show
  1. package/dist/cjs/agents/active_streaming_tool.js +44 -0
  2. package/dist/cjs/agents/base_agent.js +245 -0
  3. package/dist/cjs/agents/base_llm_processor.js +44 -0
  4. package/dist/cjs/agents/callback_context.js +98 -0
  5. package/dist/cjs/agents/content_processor_utils.js +311 -0
  6. package/dist/cjs/agents/functions.js +425 -0
  7. package/dist/cjs/agents/instructions.js +110 -0
  8. package/dist/cjs/agents/invocation_context.js +107 -0
  9. package/dist/cjs/agents/live_request_queue.js +136 -0
  10. package/dist/cjs/agents/llm_agent.js +1257 -0
  11. package/dist/cjs/agents/loop_agent.js +68 -0
  12. package/dist/cjs/agents/parallel_agent.js +78 -0
  13. package/dist/cjs/agents/readonly_context.js +68 -0
  14. package/dist/cjs/agents/run_config.js +70 -0
  15. package/dist/cjs/agents/sequential_agent.js +84 -0
  16. package/dist/cjs/agents/transcription_entry.js +27 -0
  17. package/dist/cjs/artifacts/base_artifact_service.js +27 -0
  18. package/dist/cjs/artifacts/gcs_artifact_service.js +140 -0
  19. package/dist/cjs/artifacts/in_memory_artifact_service.js +119 -0
  20. package/dist/cjs/auth/auth_credential.js +46 -0
  21. package/dist/cjs/auth/auth_handler.js +92 -0
  22. package/dist/cjs/auth/auth_schemes.js +62 -0
  23. package/dist/cjs/auth/auth_tool.js +27 -0
  24. package/dist/cjs/auth/credential_service/base_credential_service.js +27 -0
  25. package/dist/cjs/auth/credential_service/in_memory_credential_service.js +63 -0
  26. package/dist/cjs/auth/exchanger/base_credential_exchanger.js +40 -0
  27. package/dist/cjs/auth/exchanger/credential_exchanger_registry.js +59 -0
  28. package/dist/cjs/code_executors/base_code_executor.js +76 -0
  29. package/dist/cjs/code_executors/built_in_code_executor.js +58 -0
  30. package/dist/cjs/code_executors/code_execution_utils.js +142 -0
  31. package/dist/cjs/code_executors/code_executor_context.js +198 -0
  32. package/dist/cjs/common.js +181 -0
  33. package/dist/cjs/events/event.js +119 -0
  34. package/dist/cjs/events/event_actions.js +83 -0
  35. package/dist/cjs/examples/base_example_provider.js +40 -0
  36. package/dist/cjs/examples/example.js +27 -0
  37. package/dist/cjs/examples/example_util.js +107 -0
  38. package/dist/cjs/index.js +12 -12
  39. package/dist/cjs/index.js.map +3 -3
  40. package/dist/cjs/index_web.js +33 -0
  41. package/dist/cjs/memory/base_memory_service.js +27 -0
  42. package/dist/cjs/memory/in_memory_memory_service.js +97 -0
  43. package/dist/cjs/memory/memory_entry.js +27 -0
  44. package/dist/cjs/models/base_llm.js +95 -0
  45. package/dist/cjs/models/base_llm_connection.js +27 -0
  46. package/dist/cjs/models/gemini_llm_connection.js +132 -0
  47. package/dist/cjs/models/google_llm.js +472 -0
  48. package/dist/cjs/models/llm_request.js +82 -0
  49. package/dist/cjs/models/llm_response.js +71 -0
  50. package/dist/cjs/models/registry.js +121 -0
  51. package/dist/cjs/plugins/base_plugin.js +236 -0
  52. package/dist/cjs/plugins/logging_plugin.js +222 -0
  53. package/dist/cjs/plugins/plugin_manager.js +239 -0
  54. package/dist/cjs/plugins/security_plugin.js +153 -0
  55. package/dist/cjs/runner/in_memory_runner.js +58 -0
  56. package/dist/cjs/runner/runner.js +277 -0
  57. package/dist/cjs/sessions/base_session_service.js +71 -0
  58. package/dist/cjs/sessions/in_memory_session_service.js +184 -0
  59. package/dist/cjs/sessions/session.js +48 -0
  60. package/dist/cjs/sessions/state.js +101 -0
  61. package/dist/cjs/telemetry/google_cloud.js +85 -0
  62. package/dist/cjs/telemetry/setup.js +97 -0
  63. package/dist/cjs/telemetry/tracing.js +231 -0
  64. package/dist/cjs/tools/agent_tool.js +134 -0
  65. package/dist/cjs/tools/base_tool.js +107 -0
  66. package/dist/cjs/tools/base_toolset.js +76 -0
  67. package/dist/cjs/tools/forwarding_artifact_service.js +71 -0
  68. package/dist/cjs/tools/function_tool.js +101 -0
  69. package/dist/cjs/tools/google_search_tool.js +77 -0
  70. package/dist/cjs/tools/long_running_tool.js +63 -0
  71. package/dist/cjs/tools/mcp/mcp_session_manager.js +65 -0
  72. package/dist/cjs/tools/mcp/mcp_tool.js +65 -0
  73. package/dist/cjs/tools/mcp/mcp_toolset.js +61 -0
  74. package/dist/cjs/tools/tool_confirmation.js +49 -0
  75. package/dist/cjs/tools/tool_context.js +129 -0
  76. package/dist/cjs/utils/client_labels.js +56 -0
  77. package/dist/cjs/utils/deep_clone.js +44 -0
  78. package/dist/cjs/utils/env_aware_utils.js +83 -0
  79. package/dist/cjs/utils/gemini_schema_util.js +88 -0
  80. package/dist/cjs/utils/logger.js +121 -0
  81. package/dist/cjs/utils/model_name.js +76 -0
  82. package/dist/cjs/utils/simple_zod_to_json.js +191 -0
  83. package/dist/cjs/utils/variant_utils.js +55 -0
  84. package/dist/cjs/version.js +39 -0
  85. package/dist/esm/agents/active_streaming_tool.js +14 -0
  86. package/dist/esm/agents/base_agent.js +214 -0
  87. package/dist/esm/agents/base_llm_processor.js +13 -0
  88. package/dist/esm/agents/callback_context.js +68 -0
  89. package/dist/esm/agents/content_processor_utils.js +280 -0
  90. package/dist/esm/agents/functions.js +384 -0
  91. package/dist/esm/agents/instructions.js +80 -0
  92. package/dist/esm/agents/invocation_context.js +76 -0
  93. package/dist/esm/agents/live_request_queue.js +106 -0
  94. package/dist/esm/agents/llm_agent.js +1225 -0
  95. package/dist/esm/agents/loop_agent.js +38 -0
  96. package/dist/esm/agents/parallel_agent.js +48 -0
  97. package/dist/esm/agents/readonly_context.js +38 -0
  98. package/dist/esm/agents/run_config.js +39 -0
  99. package/dist/esm/agents/sequential_agent.js +54 -0
  100. package/dist/esm/agents/transcription_entry.js +5 -0
  101. package/dist/esm/artifacts/base_artifact_service.js +5 -0
  102. package/dist/esm/artifacts/gcs_artifact_service.js +110 -0
  103. package/dist/esm/artifacts/in_memory_artifact_service.js +89 -0
  104. package/dist/esm/auth/auth_credential.js +16 -0
  105. package/dist/esm/auth/auth_handler.js +62 -0
  106. package/dist/esm/auth/auth_schemes.js +31 -0
  107. package/dist/esm/auth/auth_tool.js +5 -0
  108. package/dist/esm/auth/credential_service/base_credential_service.js +5 -0
  109. package/dist/esm/auth/credential_service/in_memory_credential_service.js +33 -0
  110. package/dist/esm/auth/exchanger/base_credential_exchanger.js +10 -0
  111. package/dist/esm/auth/exchanger/credential_exchanger_registry.js +29 -0
  112. package/dist/esm/code_executors/base_code_executor.js +46 -0
  113. package/dist/esm/code_executors/built_in_code_executor.js +28 -0
  114. package/dist/esm/code_executors/code_execution_utils.js +108 -0
  115. package/dist/esm/code_executors/code_executor_context.js +168 -0
  116. package/dist/esm/common.js +98 -0
  117. package/dist/esm/events/event.js +83 -0
  118. package/dist/esm/events/event_actions.js +52 -0
  119. package/dist/esm/examples/base_example_provider.js +10 -0
  120. package/dist/esm/examples/example.js +5 -0
  121. package/dist/esm/examples/example_util.js +76 -0
  122. package/dist/esm/index.js +12 -12
  123. package/dist/esm/index.js.map +3 -3
  124. package/dist/esm/index_web.js +6 -0
  125. package/dist/esm/memory/base_memory_service.js +5 -0
  126. package/dist/esm/memory/in_memory_memory_service.js +67 -0
  127. package/dist/esm/memory/memory_entry.js +5 -0
  128. package/dist/esm/models/base_llm.js +64 -0
  129. package/dist/esm/models/base_llm_connection.js +5 -0
  130. package/dist/esm/models/gemini_llm_connection.js +102 -0
  131. package/dist/esm/models/google_llm.js +446 -0
  132. package/dist/esm/models/llm_request.js +50 -0
  133. package/dist/esm/models/llm_response.js +41 -0
  134. package/dist/esm/models/registry.js +91 -0
  135. package/dist/esm/plugins/base_plugin.js +206 -0
  136. package/dist/esm/plugins/logging_plugin.js +192 -0
  137. package/dist/esm/plugins/plugin_manager.js +209 -0
  138. package/dist/esm/plugins/security_plugin.js +119 -0
  139. package/dist/esm/runner/in_memory_runner.js +28 -0
  140. package/dist/esm/runner/runner.js +247 -0
  141. package/dist/esm/sessions/base_session_service.js +41 -0
  142. package/dist/esm/sessions/in_memory_session_service.js +154 -0
  143. package/dist/esm/sessions/session.js +18 -0
  144. package/dist/esm/sessions/state.js +71 -0
  145. package/dist/esm/telemetry/google_cloud.js +54 -0
  146. package/dist/esm/telemetry/setup.js +67 -0
  147. package/dist/esm/telemetry/tracing.js +195 -0
  148. package/dist/esm/tools/agent_tool.js +104 -0
  149. package/dist/esm/tools/base_tool.js +77 -0
  150. package/dist/esm/tools/base_toolset.js +46 -0
  151. package/dist/esm/tools/forwarding_artifact_service.js +41 -0
  152. package/dist/esm/tools/function_tool.js +71 -0
  153. package/dist/esm/tools/google_search_tool.js +47 -0
  154. package/dist/esm/tools/long_running_tool.js +33 -0
  155. package/dist/esm/tools/mcp/mcp_session_manager.js +35 -0
  156. package/dist/esm/tools/mcp/mcp_tool.js +35 -0
  157. package/dist/esm/tools/mcp/mcp_toolset.js +31 -0
  158. package/dist/esm/tools/tool_confirmation.js +19 -0
  159. package/dist/esm/tools/tool_context.js +99 -0
  160. package/dist/esm/utils/client_labels.js +26 -0
  161. package/dist/esm/utils/deep_clone.js +14 -0
  162. package/dist/esm/utils/env_aware_utils.js +49 -0
  163. package/dist/esm/utils/gemini_schema_util.js +58 -0
  164. package/dist/esm/utils/logger.js +89 -0
  165. package/dist/esm/utils/model_name.js +41 -0
  166. package/dist/esm/utils/simple_zod_to_json.js +160 -0
  167. package/dist/esm/utils/variant_utils.js +24 -0
  168. package/dist/esm/version.js +9 -0
  169. package/dist/types/models/google_llm.d.ts +0 -7
  170. package/dist/web/agents/active_streaming_tool.js +14 -0
  171. package/dist/web/agents/base_agent.js +265 -0
  172. package/dist/web/agents/base_llm_processor.js +13 -0
  173. package/dist/web/agents/callback_context.js +68 -0
  174. package/dist/web/agents/content_processor_utils.js +280 -0
  175. package/dist/web/agents/functions.js +384 -0
  176. package/dist/web/agents/instructions.js +80 -0
  177. package/dist/web/agents/invocation_context.js +76 -0
  178. package/dist/web/agents/live_request_queue.js +124 -0
  179. package/dist/web/agents/llm_agent.js +1355 -0
  180. package/dist/web/agents/loop_agent.js +71 -0
  181. package/dist/web/agents/parallel_agent.js +83 -0
  182. package/dist/web/agents/readonly_context.js +38 -0
  183. package/dist/web/agents/run_config.js +54 -0
  184. package/dist/web/agents/sequential_agent.js +99 -0
  185. package/dist/web/agents/transcription_entry.js +5 -0
  186. package/dist/web/artifacts/base_artifact_service.js +5 -0
  187. package/dist/web/artifacts/gcs_artifact_service.js +126 -0
  188. package/dist/web/artifacts/in_memory_artifact_service.js +89 -0
  189. package/dist/web/auth/auth_credential.js +16 -0
  190. package/dist/web/auth/auth_handler.js +62 -0
  191. package/dist/web/auth/auth_schemes.js +31 -0
  192. package/dist/web/auth/auth_tool.js +5 -0
  193. package/dist/web/auth/credential_service/base_credential_service.js +5 -0
  194. package/dist/web/auth/credential_service/in_memory_credential_service.js +33 -0
  195. package/dist/web/auth/exchanger/base_credential_exchanger.js +10 -0
  196. package/dist/web/auth/exchanger/credential_exchanger_registry.js +29 -0
  197. package/dist/web/code_executors/base_code_executor.js +46 -0
  198. package/dist/web/code_executors/built_in_code_executor.js +28 -0
  199. package/dist/web/code_executors/code_execution_utils.js +105 -0
  200. package/dist/web/code_executors/code_executor_context.js +168 -0
  201. package/dist/web/common.js +98 -0
  202. package/dist/web/events/event.js +101 -0
  203. package/dist/web/events/event_actions.js +67 -0
  204. package/dist/web/examples/base_example_provider.js +10 -0
  205. package/dist/web/examples/example.js +5 -0
  206. package/dist/web/examples/example_util.js +75 -0
  207. package/dist/web/index.js +1 -1
  208. package/dist/web/index.js.map +3 -3
  209. package/dist/web/index_web.js +6 -0
  210. package/dist/web/memory/base_memory_service.js +5 -0
  211. package/dist/web/memory/in_memory_memory_service.js +67 -0
  212. package/dist/web/memory/memory_entry.js +5 -0
  213. package/dist/web/models/base_llm.js +64 -0
  214. package/dist/web/models/base_llm_connection.js +5 -0
  215. package/dist/web/models/gemini_llm_connection.js +120 -0
  216. package/dist/web/models/google_llm.js +487 -0
  217. package/dist/web/models/llm_request.js +50 -0
  218. package/dist/web/models/llm_response.js +41 -0
  219. package/dist/web/models/registry.js +91 -0
  220. package/dist/web/plugins/base_plugin.js +206 -0
  221. package/dist/web/plugins/logging_plugin.js +192 -0
  222. package/dist/web/plugins/plugin_manager.js +209 -0
  223. package/dist/web/plugins/security_plugin.js +119 -0
  224. package/dist/web/runner/in_memory_runner.js +28 -0
  225. package/dist/web/runner/runner.js +278 -0
  226. package/dist/web/sessions/base_session_service.js +41 -0
  227. package/dist/web/sessions/in_memory_session_service.js +154 -0
  228. package/dist/web/sessions/session.js +18 -0
  229. package/dist/web/sessions/state.js +87 -0
  230. package/dist/web/telemetry/google_cloud.js +54 -0
  231. package/dist/web/telemetry/setup.js +67 -0
  232. package/dist/web/telemetry/tracing.js +210 -0
  233. package/dist/web/tools/agent_tool.js +118 -0
  234. package/dist/web/tools/base_tool.js +77 -0
  235. package/dist/web/tools/base_toolset.js +46 -0
  236. package/dist/web/tools/forwarding_artifact_service.js +41 -0
  237. package/dist/web/tools/function_tool.js +71 -0
  238. package/dist/web/tools/google_search_tool.js +47 -0
  239. package/dist/web/tools/long_running_tool.js +50 -0
  240. package/dist/web/tools/mcp/mcp_session_manager.js +35 -0
  241. package/dist/web/tools/mcp/mcp_tool.js +35 -0
  242. package/dist/web/tools/mcp/mcp_toolset.js +31 -0
  243. package/dist/web/tools/tool_confirmation.js +19 -0
  244. package/dist/web/tools/tool_context.js +99 -0
  245. package/dist/web/utils/client_labels.js +26 -0
  246. package/dist/web/utils/deep_clone.js +14 -0
  247. package/dist/web/utils/env_aware_utils.js +49 -0
  248. package/dist/web/utils/gemini_schema_util.js +58 -0
  249. package/dist/web/utils/logger.js +89 -0
  250. package/dist/web/utils/model_name.js +41 -0
  251. package/dist/web/utils/simple_zod_to_json.js +174 -0
  252. package/dist/web/utils/variant_utils.js +24 -0
  253. package/dist/web/version.js +9 -0
  254. package/package.json +1 -1
@@ -0,0 +1,89 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
7
+ LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
8
+ LogLevel2[LogLevel2["INFO"] = 1] = "INFO";
9
+ LogLevel2[LogLevel2["WARN"] = 2] = "WARN";
10
+ LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";
11
+ return LogLevel2;
12
+ })(LogLevel || {});
13
+ let logLevel = 1 /* INFO */;
14
+ function setLogLevel(level) {
15
+ logLevel = level;
16
+ }
17
+ class SimpleLogger {
18
+ log(level, ...args) {
19
+ if (level < logLevel) {
20
+ return;
21
+ }
22
+ switch (level) {
23
+ case 0 /* DEBUG */:
24
+ this.debug(...args);
25
+ break;
26
+ case 1 /* INFO */:
27
+ this.info(...args);
28
+ break;
29
+ case 2 /* WARN */:
30
+ this.warn(...args);
31
+ break;
32
+ case 3 /* ERROR */:
33
+ this.error(...args);
34
+ break;
35
+ default:
36
+ throw new Error(`Unsupported log level: ${level}`);
37
+ }
38
+ }
39
+ debug(...args) {
40
+ if (logLevel > 0 /* DEBUG */) {
41
+ return;
42
+ }
43
+ console.debug(getColoredPrefix(0 /* DEBUG */), ...args);
44
+ }
45
+ info(...args) {
46
+ if (logLevel > 1 /* INFO */) {
47
+ return;
48
+ }
49
+ console.info(getColoredPrefix(1 /* INFO */), ...args);
50
+ }
51
+ warn(...args) {
52
+ if (logLevel > 2 /* WARN */) {
53
+ return;
54
+ }
55
+ console.warn(getColoredPrefix(2 /* WARN */), ...args);
56
+ }
57
+ error(...args) {
58
+ if (logLevel > 3 /* ERROR */) {
59
+ return;
60
+ }
61
+ console.error(getColoredPrefix(3 /* ERROR */), ...args);
62
+ }
63
+ }
64
+ const LOG_LEVEL_STR = {
65
+ [0 /* DEBUG */]: "DEBUG",
66
+ [1 /* INFO */]: "INFO",
67
+ [2 /* WARN */]: "WARN",
68
+ [3 /* ERROR */]: "ERROR"
69
+ };
70
+ const CONSOLE_COLOR_MAP = {
71
+ [0 /* DEBUG */]: "\x1B[34m",
72
+ // Blue
73
+ [1 /* INFO */]: "\x1B[32m",
74
+ // Green
75
+ [2 /* WARN */]: "\x1B[33m",
76
+ // Yellow
77
+ [3 /* ERROR */]: "\x1B[31m"
78
+ // Red
79
+ };
80
+ const RESET_COLOR = "\x1B[0m";
81
+ function getColoredPrefix(level) {
82
+ return `${CONSOLE_COLOR_MAP[level]}[ADK ${LOG_LEVEL_STR[level]}]:${RESET_COLOR}`;
83
+ }
84
+ const logger = new SimpleLogger();
85
+ export {
86
+ LogLevel,
87
+ logger,
88
+ setLogLevel
89
+ };
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ const MODEL_NAME_PATTERN = "^projects/[^/]+/locations/[^/]+/publishers/[^/]+/models/(.+)$";
7
+ function extractModelName(modelString) {
8
+ const match = modelString.match(MODEL_NAME_PATTERN);
9
+ if (match) {
10
+ return match[1];
11
+ }
12
+ return modelString;
13
+ }
14
+ function isGeminiModel(modelString) {
15
+ const modelName = extractModelName(modelString);
16
+ return modelName.startsWith("gemini-");
17
+ }
18
+ function isGemini1Model(modelString) {
19
+ const modelName = extractModelName(modelString);
20
+ return modelName.startsWith("gemini-1");
21
+ }
22
+ function isGemini2Model(modelString) {
23
+ const modelName = extractModelName(modelString);
24
+ return modelName.startsWith("gemini-2");
25
+ }
26
+ function isGemini3Model(modelString) {
27
+ const modelName = extractModelName(modelString);
28
+ return modelName.startsWith("gemini-3");
29
+ }
30
+ function isGemini3PreviewModel(modelString) {
31
+ const modelName = extractModelName(modelString);
32
+ return modelName.startsWith("gemini-3") && modelName.includes("preview");
33
+ }
34
+ export {
35
+ extractModelName,
36
+ isGemini1Model,
37
+ isGemini2Model,
38
+ isGemini3Model,
39
+ isGemini3PreviewModel,
40
+ isGeminiModel
41
+ };
@@ -0,0 +1,160 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Type } from "@google/genai";
7
+ import { z } from "zod";
8
+ function isZodObject(obj) {
9
+ var _a;
10
+ return obj !== null && typeof obj === "object" && ((_a = obj._def) == null ? void 0 : _a.typeName) === "ZodObject";
11
+ }
12
+ function parseZodType(zodType) {
13
+ const def = zodType._def;
14
+ if (!def) {
15
+ return {};
16
+ }
17
+ const description = def.description;
18
+ const result = {};
19
+ if (description) result.description = description;
20
+ const returnResult = (result2) => {
21
+ if (result2.description === void 0) {
22
+ delete result2.description;
23
+ }
24
+ return result2;
25
+ };
26
+ switch (def.typeName) {
27
+ case z.ZodFirstPartyTypeKind.ZodString:
28
+ result.type = Type.STRING;
29
+ for (const check of def.checks || []) {
30
+ if (check.kind === "min")
31
+ result.minLength = check.value.toString();
32
+ else if (check.kind === "max")
33
+ result.maxLength = check.value.toString();
34
+ else if (check.kind === "email")
35
+ result.format = "email";
36
+ else if (check.kind === "uuid")
37
+ result.format = "uuid";
38
+ else if (check.kind === "url")
39
+ result.format = "uri";
40
+ else if (check.kind === "regex")
41
+ result.pattern = check.regex.source;
42
+ }
43
+ return returnResult(result);
44
+ case z.ZodFirstPartyTypeKind.ZodNumber:
45
+ result.type = Type.NUMBER;
46
+ for (const check of def.checks || []) {
47
+ if (check.kind === "min")
48
+ result.minimum = check.value;
49
+ else if (check.kind === "max")
50
+ result.maximum = check.value;
51
+ else if (check.kind === "int")
52
+ result.type = Type.INTEGER;
53
+ }
54
+ return returnResult(result);
55
+ case z.ZodFirstPartyTypeKind.ZodBoolean:
56
+ result.type = Type.BOOLEAN;
57
+ return returnResult(result);
58
+ case z.ZodFirstPartyTypeKind.ZodArray:
59
+ result.type = Type.ARRAY;
60
+ result.items = parseZodType(def.type);
61
+ if (def.minLength) result.minItems = def.minLength.value.toString();
62
+ if (def.maxLength) result.maxItems = def.maxLength.value.toString();
63
+ return returnResult(result);
64
+ case z.ZodFirstPartyTypeKind.ZodObject: {
65
+ const nestedSchema = zodObjectToSchema(zodType);
66
+ return nestedSchema;
67
+ }
68
+ case z.ZodFirstPartyTypeKind.ZodLiteral:
69
+ const literalType = typeof def.value;
70
+ result.enum = [def.value.toString()];
71
+ if (literalType === "string") {
72
+ result.type = Type.STRING;
73
+ } else if (literalType === "number") {
74
+ result.type = Type.NUMBER;
75
+ } else if (literalType === "boolean") {
76
+ result.type = Type.BOOLEAN;
77
+ } else if (def.value === null) {
78
+ result.type = Type.NULL;
79
+ } else {
80
+ throw new Error(`Unsupported ZodLiteral value type: ${literalType}`);
81
+ }
82
+ return returnResult(result);
83
+ case z.ZodFirstPartyTypeKind.ZodEnum:
84
+ result.type = Type.STRING;
85
+ result.enum = def.values;
86
+ return returnResult(result);
87
+ case z.ZodFirstPartyTypeKind.ZodNativeEnum:
88
+ result.type = Type.STRING;
89
+ result.enum = Object.values(def.values);
90
+ return returnResult(result);
91
+ case z.ZodFirstPartyTypeKind.ZodUnion:
92
+ result.anyOf = def.options.map(parseZodType);
93
+ return returnResult(result);
94
+ case z.ZodFirstPartyTypeKind.ZodOptional:
95
+ return parseZodType(def.innerType);
96
+ case z.ZodFirstPartyTypeKind.ZodNullable:
97
+ const nullableInner = parseZodType(def.innerType);
98
+ return nullableInner ? returnResult({
99
+ anyOf: [nullableInner, { type: Type.NULL }],
100
+ ...description && { description }
101
+ }) : returnResult({ type: Type.NULL, ...description && { description } });
102
+ case z.ZodFirstPartyTypeKind.ZodDefault:
103
+ const defaultInner = parseZodType(def.innerType);
104
+ if (defaultInner) defaultInner.default = def.defaultValue();
105
+ return defaultInner;
106
+ case z.ZodFirstPartyTypeKind.ZodBranded:
107
+ return parseZodType(def.type);
108
+ case z.ZodFirstPartyTypeKind.ZodReadonly:
109
+ return parseZodType(def.innerType);
110
+ case z.ZodFirstPartyTypeKind.ZodNull:
111
+ result.type = Type.NULL;
112
+ return returnResult(result);
113
+ case z.ZodFirstPartyTypeKind.ZodAny:
114
+ case z.ZodFirstPartyTypeKind.ZodUnknown:
115
+ return returnResult({ ...description && { description } });
116
+ default:
117
+ throw new Error(`Unsupported Zod type: ${def.typeName}`);
118
+ }
119
+ }
120
+ function zodObjectToSchema(schema) {
121
+ if (schema._def.typeName !== z.ZodFirstPartyTypeKind.ZodObject) {
122
+ throw new Error("Expected a ZodObject");
123
+ }
124
+ const shape = schema.shape;
125
+ const properties = {};
126
+ const required = [];
127
+ for (const key in shape) {
128
+ const fieldSchema = shape[key];
129
+ const parsedField = parseZodType(fieldSchema);
130
+ if (parsedField) {
131
+ properties[key] = parsedField;
132
+ }
133
+ let currentSchema = fieldSchema;
134
+ let isOptional = false;
135
+ while (currentSchema._def.typeName === z.ZodFirstPartyTypeKind.ZodOptional || currentSchema._def.typeName === z.ZodFirstPartyTypeKind.ZodDefault) {
136
+ isOptional = true;
137
+ currentSchema = currentSchema._def.innerType;
138
+ }
139
+ if (!isOptional) {
140
+ required.push(key);
141
+ }
142
+ }
143
+ const catchall = schema._def.catchall;
144
+ let additionalProperties = false;
145
+ if (catchall && catchall._def.typeName !== z.ZodFirstPartyTypeKind.ZodNever) {
146
+ additionalProperties = parseZodType(catchall) || true;
147
+ } else {
148
+ additionalProperties = schema._def.unknownKeys === "passthrough";
149
+ }
150
+ return {
151
+ type: Type.OBJECT,
152
+ properties,
153
+ required: required.length > 0 ? required : [],
154
+ ...schema._def.description ? { description: schema._def.description } : {}
155
+ };
156
+ }
157
+ export {
158
+ isZodObject,
159
+ zodObjectToSchema
160
+ };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ var GoogleLLMVariant = /* @__PURE__ */ ((GoogleLLMVariant2) => {
7
+ GoogleLLMVariant2["VERTEX_AI"] = "VERTEX_AI";
8
+ GoogleLLMVariant2["GEMINI_API"] = "GEMINI_API";
9
+ return GoogleLLMVariant2;
10
+ })(GoogleLLMVariant || {});
11
+ function getGoogleLlmVariant() {
12
+ return getBooleanEnvVar("GOOGLE_GENAI_USE_VERTEXAI") ? "VERTEX_AI" /* VERTEX_AI */ : "GEMINI_API" /* GEMINI_API */;
13
+ }
14
+ function getBooleanEnvVar(envVar) {
15
+ if (!process.env) {
16
+ return false;
17
+ }
18
+ const envVarValue = (process.env[envVar] || "").toLowerCase();
19
+ return ["true", "1"].includes(envVar.toLowerCase());
20
+ }
21
+ export {
22
+ GoogleLLMVariant,
23
+ getGoogleLlmVariant
24
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ const version = "0.2.4";
7
+ export {
8
+ version
9
+ };
@@ -60,13 +60,6 @@ export declare class Gemini extends BaseLlm {
60
60
  private readonly headers?;
61
61
  private readonly apiEndpoint?;
62
62
  private readonly isGemini3Preview;
63
- /**
64
- * Cached thoughtSignature from Gemini 3 thinking mode responses.
65
- * Gemini 3 may not return a new signature for follow-up tool calls in the same turn,
66
- * so we cache the signature from the first response and reuse it for subsequent calls.
67
- * This is reset at the start of each new generateContentAsync call.
68
- */
69
- private cachedThoughtSignature?;
70
63
  /**
71
64
  * @param params The parameters for creating a Gemini instance.
72
65
  */
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ class ActiveStreamingTool {
7
+ constructor(params = {}) {
8
+ this.task = params.task;
9
+ this.stream = params.stream;
10
+ }
11
+ }
12
+ export {
13
+ ActiveStreamingTool
14
+ };
@@ -0,0 +1,265 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
+ var __await = function(promise, isYieldStar) {
22
+ this[0] = promise;
23
+ this[1] = isYieldStar;
24
+ };
25
+ var __asyncGenerator = (__this, __arguments, generator) => {
26
+ var resume = (k, v, yes, no) => {
27
+ try {
28
+ var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done;
29
+ Promise.resolve(isAwait ? v[0] : v).then((y) => isAwait ? resume(k === "return" ? k : "next", v[1] ? { done: y.done, value: y.value } : y, yes, no) : yes({ value: y, done })).catch((e) => resume("throw", e, yes, no));
30
+ } catch (e) {
31
+ no(e);
32
+ }
33
+ }, method = (k) => it[k] = (x) => new Promise((yes, no) => resume(k, x, yes, no)), it = {};
34
+ return generator = generator.apply(__this, __arguments), it[__knownSymbol("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
35
+ };
36
+ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")]) ? it.call(obj) : (obj = obj[__knownSymbol("iterator")](), it = {}, method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((yes, no, done) => (arg = fn.call(obj, arg), done = arg.done, Promise.resolve(arg.value).then((value) => yes({ value, done }), no)))), method("next"), method("return"), it);
37
+ /**
38
+ * @license
39
+ * Copyright 2025 Google LLC
40
+ * SPDX-License-Identifier: Apache-2.0
41
+ */
42
+ import { trace } from "@opentelemetry/api";
43
+ import { createEvent } from "../events/event.js";
44
+ import { CallbackContext } from "./callback_context.js";
45
+ import { InvocationContext } from "./invocation_context.js";
46
+ class BaseAgent {
47
+ constructor(config) {
48
+ this.name = validateAgentName(config.name);
49
+ this.description = config.description;
50
+ this.parentAgent = config.parentAgent;
51
+ this.subAgents = config.subAgents || [];
52
+ this.rootAgent = getRootAgent(this);
53
+ this.beforeAgentCallback = getCannonicalCallback(config.beforeAgentCallback);
54
+ this.afterAgentCallback = getCannonicalCallback(config.afterAgentCallback);
55
+ this.setParentAgentForSubAgents();
56
+ }
57
+ /**
58
+ * Entry method to run an agent via text-based conversation.
59
+ *
60
+ * @param parentContext The invocation context of the parent agent.
61
+ * @yields The events generated by the agent.
62
+ * @returns An AsyncGenerator that yields the events generated by the agent.
63
+ */
64
+ runAsync(parentContext) {
65
+ return __asyncGenerator(this, null, function* () {
66
+ const span = trace.getTracer("gcp.vertex.agent").startSpan("agent_run [".concat(this.name, "]"));
67
+ try {
68
+ const context = this.createInvocationContext(parentContext);
69
+ const beforeAgentCallbackEvent = yield new __await(this.handleBeforeAgentCallback(context));
70
+ if (beforeAgentCallbackEvent) {
71
+ yield beforeAgentCallbackEvent;
72
+ }
73
+ if (context.endInvocation) {
74
+ return;
75
+ }
76
+ try {
77
+ for (var iter = __forAwait(this.runAsyncImpl(context)), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
78
+ const event = temp.value;
79
+ yield event;
80
+ }
81
+ } catch (temp) {
82
+ error = [temp];
83
+ } finally {
84
+ try {
85
+ more && (temp = iter.return) && (yield new __await(temp.call(iter)));
86
+ } finally {
87
+ if (error)
88
+ throw error[0];
89
+ }
90
+ }
91
+ if (context.endInvocation) {
92
+ return;
93
+ }
94
+ const afterAgentCallbackEvent = yield new __await(this.handleAfterAgentCallback(context));
95
+ if (afterAgentCallbackEvent) {
96
+ yield afterAgentCallbackEvent;
97
+ }
98
+ } finally {
99
+ span.end();
100
+ }
101
+ });
102
+ }
103
+ /**
104
+ * Entry method to run an agent via video/audio-based conversation.
105
+ *
106
+ * @param parentContext The invocation context of the parent agent.
107
+ * @yields The events generated by the agent.
108
+ * @returns An AsyncGenerator that yields the events generated by the agent.
109
+ */
110
+ runLive(parentContext) {
111
+ return __asyncGenerator(this, null, function* () {
112
+ const span = trace.getTracer("gcp.vertex.agent").startSpan("agent_run [".concat(this.name, "]"));
113
+ try {
114
+ throw new Error("Live mode is not implemented yet.");
115
+ } finally {
116
+ span.end();
117
+ }
118
+ });
119
+ }
120
+ /**
121
+ * Finds the agent with the given name in this agent and its descendants.
122
+ *
123
+ * @param name The name of the agent to find.
124
+ * @return The agent with the given name, or undefined if not found.
125
+ */
126
+ findAgent(name) {
127
+ if (this.name === name) {
128
+ return this;
129
+ }
130
+ return this.findSubAgent(name);
131
+ }
132
+ /**
133
+ * Finds the agent with the given name in this agent's descendants.
134
+ *
135
+ * @param name The name of the agent to find.
136
+ * @return The agent with the given name, or undefined if not found.
137
+ */
138
+ findSubAgent(name) {
139
+ for (const subAgent of this.subAgents) {
140
+ const result = subAgent.findAgent(name);
141
+ if (result) {
142
+ return result;
143
+ }
144
+ }
145
+ return void 0;
146
+ }
147
+ /**
148
+ * Creates an invocation context for this agent.
149
+ *
150
+ * @param parentContext The invocation context of the parent agent.
151
+ * @return The invocation context for this agent.
152
+ */
153
+ createInvocationContext(parentContext) {
154
+ return new InvocationContext(__spreadProps(__spreadValues({}, parentContext), {
155
+ agent: this
156
+ }));
157
+ }
158
+ /**
159
+ * Runs the before agent callback if it exists.
160
+ *
161
+ * @param invocationContext The invocation context of the agent.
162
+ * @return The event to return to the user, or undefined if no event is
163
+ * generated.
164
+ */
165
+ async handleBeforeAgentCallback(invocationContext) {
166
+ if (this.beforeAgentCallback.length === 0) {
167
+ return void 0;
168
+ }
169
+ const callbackContext = new CallbackContext({ invocationContext });
170
+ for (const callback of this.beforeAgentCallback) {
171
+ const content = await callback(callbackContext);
172
+ if (content) {
173
+ invocationContext.endInvocation = true;
174
+ return createEvent({
175
+ invocationId: invocationContext.invocationId,
176
+ author: this.name,
177
+ branch: invocationContext.branch,
178
+ content,
179
+ actions: callbackContext.eventActions
180
+ });
181
+ }
182
+ }
183
+ if (callbackContext.state.hasDelta()) {
184
+ return createEvent({
185
+ invocationId: invocationContext.invocationId,
186
+ author: this.name,
187
+ branch: invocationContext.branch,
188
+ actions: callbackContext.eventActions
189
+ });
190
+ }
191
+ return void 0;
192
+ }
193
+ /**
194
+ * Runs the after agent callback if it exists.
195
+ *
196
+ * @param invocationContext The invocation context of the agent.
197
+ * @return The event to return to the user, or undefined if no event is
198
+ * generated.
199
+ */
200
+ async handleAfterAgentCallback(invocationContext) {
201
+ if (this.afterAgentCallback.length === 0) {
202
+ return void 0;
203
+ }
204
+ const callbackContext = new CallbackContext({ invocationContext });
205
+ for (const callback of this.afterAgentCallback) {
206
+ const content = await callback(callbackContext);
207
+ if (content) {
208
+ return createEvent({
209
+ invocationId: invocationContext.invocationId,
210
+ author: this.name,
211
+ branch: invocationContext.branch,
212
+ content,
213
+ actions: callbackContext.eventActions
214
+ });
215
+ }
216
+ }
217
+ if (callbackContext.state.hasDelta()) {
218
+ return createEvent({
219
+ invocationId: invocationContext.invocationId,
220
+ author: this.name,
221
+ branch: invocationContext.branch,
222
+ actions: callbackContext.eventActions
223
+ });
224
+ }
225
+ return void 0;
226
+ }
227
+ setParentAgentForSubAgents() {
228
+ for (const subAgent of this.subAgents) {
229
+ if (subAgent.parentAgent) {
230
+ throw new Error('Agent "'.concat(subAgent.name, '" already has a parent agent, current parent: "').concat(subAgent.parentAgent.name, '", trying to add: "').concat(this.name, '"'));
231
+ }
232
+ subAgent.parentAgent = this;
233
+ }
234
+ }
235
+ }
236
+ function validateAgentName(name) {
237
+ if (!isIdentifier(name)) {
238
+ throw new Error('Found invalid agent name: "'.concat(name, '". Agent name must be a valid identifier. It should start with a letter (a-z, A-Z) or an underscore (_), and can only contain letters, digits (0-9), and underscores.'));
239
+ }
240
+ if (name === "user") {
241
+ throw new Error(
242
+ "Agent name cannot be 'user'. 'user' is reserved for end-user's input."
243
+ );
244
+ }
245
+ return name;
246
+ }
247
+ function isIdentifier(str) {
248
+ return new RegExp("^[\\p{ID_Start}$_][\\p{ID_Continue}$_]*$", "u").test(str);
249
+ }
250
+ function getRootAgent(rootAgent) {
251
+ while (rootAgent.parentAgent) {
252
+ rootAgent = rootAgent.parentAgent;
253
+ }
254
+ return rootAgent;
255
+ }
256
+ function getCannonicalCallback(callbacks) {
257
+ if (!callbacks) {
258
+ return [];
259
+ }
260
+ return Array.isArray(callbacks) ? callbacks : [callbacks];
261
+ }
262
+ export {
263
+ BaseAgent,
264
+ getCannonicalCallback
265
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ class BaseLlmRequestProcessor {
7
+ }
8
+ class BaseLlmResponseProcessor {
9
+ }
10
+ export {
11
+ BaseLlmRequestProcessor,
12
+ BaseLlmResponseProcessor
13
+ };