@google/adk 0.1.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 (311) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +9 -0
  3. package/dist/cjs/agents/active_streaming_tool.js +44 -0
  4. package/dist/cjs/agents/base_agent.js +245 -0
  5. package/dist/cjs/agents/base_llm_processor.js +44 -0
  6. package/dist/cjs/agents/callback_context.js +98 -0
  7. package/dist/cjs/agents/content_processor_utils.js +299 -0
  8. package/dist/cjs/agents/functions.js +394 -0
  9. package/dist/cjs/agents/instructions.js +110 -0
  10. package/dist/cjs/agents/invocation_context.js +109 -0
  11. package/dist/cjs/agents/live_request_queue.js +136 -0
  12. package/dist/cjs/agents/llm_agent.js +859 -0
  13. package/dist/cjs/agents/loop_agent.js +68 -0
  14. package/dist/cjs/agents/parallel_agent.js +78 -0
  15. package/dist/cjs/agents/readonly_context.js +68 -0
  16. package/dist/cjs/agents/run_config.js +74 -0
  17. package/dist/cjs/agents/sequential_agent.js +84 -0
  18. package/dist/cjs/agents/transcription_entry.js +27 -0
  19. package/dist/cjs/artifacts/base_artifact_service.js +27 -0
  20. package/dist/cjs/artifacts/in_memory_artifact_service.js +119 -0
  21. package/dist/cjs/auth/auth_credential.js +46 -0
  22. package/dist/cjs/auth/auth_handler.js +92 -0
  23. package/dist/cjs/auth/auth_schemes.js +62 -0
  24. package/dist/cjs/auth/auth_tool.js +27 -0
  25. package/dist/cjs/auth/credential_service/base_credential_service.js +27 -0
  26. package/dist/cjs/auth/credential_service/in_memory_credential_service.js +63 -0
  27. package/dist/cjs/code_executors/base_code_executor.js +76 -0
  28. package/dist/cjs/code_executors/built_in_code_executor.js +58 -0
  29. package/dist/cjs/code_executors/code_execution_utils.js +142 -0
  30. package/dist/cjs/code_executors/code_executor_context.js +198 -0
  31. package/dist/cjs/common.js +161 -0
  32. package/dist/cjs/events/event.js +107 -0
  33. package/dist/cjs/events/event_actions.js +83 -0
  34. package/dist/cjs/examples/base_example_provider.js +40 -0
  35. package/dist/cjs/examples/example.js +27 -0
  36. package/dist/cjs/examples/example_util.js +107 -0
  37. package/dist/cjs/index.js +40 -0
  38. package/dist/cjs/index.js.map +7 -0
  39. package/dist/cjs/index_web.js +33 -0
  40. package/dist/cjs/memory/base_memory_service.js +27 -0
  41. package/dist/cjs/memory/in_memory_memory_service.js +97 -0
  42. package/dist/cjs/memory/memory_entry.js +27 -0
  43. package/dist/cjs/models/base_llm.js +77 -0
  44. package/dist/cjs/models/base_llm_connection.js +27 -0
  45. package/dist/cjs/models/gemini_llm_connection.js +132 -0
  46. package/dist/cjs/models/google_llm.js +321 -0
  47. package/dist/cjs/models/llm_request.js +82 -0
  48. package/dist/cjs/models/llm_response.js +71 -0
  49. package/dist/cjs/models/registry.js +121 -0
  50. package/dist/cjs/package.json +1 -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 +276 -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/tools/agent_tool.js +134 -0
  62. package/dist/cjs/tools/base_tool.js +107 -0
  63. package/dist/cjs/tools/base_toolset.js +76 -0
  64. package/dist/cjs/tools/forwarding_artifact_service.js +71 -0
  65. package/dist/cjs/tools/function_tool.js +101 -0
  66. package/dist/cjs/tools/google_search_tool.js +76 -0
  67. package/dist/cjs/tools/long_running_tool.js +63 -0
  68. package/dist/cjs/tools/mcp/mcp_session_manager.js +65 -0
  69. package/dist/cjs/tools/mcp/mcp_tool.js +65 -0
  70. package/dist/cjs/tools/mcp/mcp_toolset.js +61 -0
  71. package/dist/cjs/tools/tool_confirmation.js +49 -0
  72. package/dist/cjs/tools/tool_context.js +129 -0
  73. package/dist/cjs/utils/deep_clone.js +44 -0
  74. package/dist/cjs/utils/env_aware_utils.js +83 -0
  75. package/dist/cjs/utils/gemini_schema_util.js +88 -0
  76. package/dist/cjs/utils/logger.js +121 -0
  77. package/dist/cjs/utils/model_name.js +64 -0
  78. package/dist/cjs/utils/simple_zod_to_json.js +191 -0
  79. package/dist/cjs/utils/variant_utils.js +55 -0
  80. package/dist/cjs/version.js +39 -0
  81. package/dist/esm/agents/active_streaming_tool.js +14 -0
  82. package/dist/esm/agents/base_agent.js +214 -0
  83. package/dist/esm/agents/base_llm_processor.js +13 -0
  84. package/dist/esm/agents/callback_context.js +68 -0
  85. package/dist/esm/agents/content_processor_utils.js +268 -0
  86. package/dist/esm/agents/functions.js +353 -0
  87. package/dist/esm/agents/instructions.js +80 -0
  88. package/dist/esm/agents/invocation_context.js +78 -0
  89. package/dist/esm/agents/live_request_queue.js +106 -0
  90. package/dist/esm/agents/llm_agent.js +828 -0
  91. package/dist/esm/agents/loop_agent.js +38 -0
  92. package/dist/esm/agents/parallel_agent.js +48 -0
  93. package/dist/esm/agents/readonly_context.js +38 -0
  94. package/dist/esm/agents/run_config.js +43 -0
  95. package/dist/esm/agents/sequential_agent.js +54 -0
  96. package/dist/esm/agents/transcription_entry.js +5 -0
  97. package/dist/esm/artifacts/base_artifact_service.js +5 -0
  98. package/dist/esm/artifacts/in_memory_artifact_service.js +89 -0
  99. package/dist/esm/auth/auth_credential.js +16 -0
  100. package/dist/esm/auth/auth_handler.js +62 -0
  101. package/dist/esm/auth/auth_schemes.js +31 -0
  102. package/dist/esm/auth/auth_tool.js +5 -0
  103. package/dist/esm/auth/credential_service/base_credential_service.js +5 -0
  104. package/dist/esm/auth/credential_service/in_memory_credential_service.js +33 -0
  105. package/dist/esm/code_executors/base_code_executor.js +46 -0
  106. package/dist/esm/code_executors/built_in_code_executor.js +28 -0
  107. package/dist/esm/code_executors/code_execution_utils.js +108 -0
  108. package/dist/esm/code_executors/code_executor_context.js +168 -0
  109. package/dist/esm/common.js +85 -0
  110. package/dist/esm/events/event.js +72 -0
  111. package/dist/esm/events/event_actions.js +52 -0
  112. package/dist/esm/examples/base_example_provider.js +10 -0
  113. package/dist/esm/examples/example.js +5 -0
  114. package/dist/esm/examples/example_util.js +76 -0
  115. package/dist/esm/index.js +40 -0
  116. package/dist/esm/index.js.map +7 -0
  117. package/dist/esm/index_web.js +6 -0
  118. package/dist/esm/memory/base_memory_service.js +5 -0
  119. package/dist/esm/memory/in_memory_memory_service.js +67 -0
  120. package/dist/esm/memory/memory_entry.js +5 -0
  121. package/dist/esm/models/base_llm.js +47 -0
  122. package/dist/esm/models/base_llm_connection.js +5 -0
  123. package/dist/esm/models/gemini_llm_connection.js +102 -0
  124. package/dist/esm/models/google_llm.js +291 -0
  125. package/dist/esm/models/llm_request.js +50 -0
  126. package/dist/esm/models/llm_response.js +41 -0
  127. package/dist/esm/models/registry.js +91 -0
  128. package/dist/esm/plugins/base_plugin.js +206 -0
  129. package/dist/esm/plugins/logging_plugin.js +192 -0
  130. package/dist/esm/plugins/plugin_manager.js +209 -0
  131. package/dist/esm/plugins/security_plugin.js +119 -0
  132. package/dist/esm/runner/in_memory_runner.js +28 -0
  133. package/dist/esm/runner/runner.js +246 -0
  134. package/dist/esm/sessions/base_session_service.js +41 -0
  135. package/dist/esm/sessions/in_memory_session_service.js +154 -0
  136. package/dist/esm/sessions/session.js +18 -0
  137. package/dist/esm/sessions/state.js +71 -0
  138. package/dist/esm/tools/agent_tool.js +104 -0
  139. package/dist/esm/tools/base_tool.js +77 -0
  140. package/dist/esm/tools/base_toolset.js +46 -0
  141. package/dist/esm/tools/forwarding_artifact_service.js +41 -0
  142. package/dist/esm/tools/function_tool.js +71 -0
  143. package/dist/esm/tools/google_search_tool.js +46 -0
  144. package/dist/esm/tools/long_running_tool.js +33 -0
  145. package/dist/esm/tools/mcp/mcp_session_manager.js +35 -0
  146. package/dist/esm/tools/mcp/mcp_tool.js +35 -0
  147. package/dist/esm/tools/mcp/mcp_toolset.js +31 -0
  148. package/dist/esm/tools/tool_confirmation.js +19 -0
  149. package/dist/esm/tools/tool_context.js +99 -0
  150. package/dist/esm/utils/deep_clone.js +14 -0
  151. package/dist/esm/utils/env_aware_utils.js +49 -0
  152. package/dist/esm/utils/gemini_schema_util.js +58 -0
  153. package/dist/esm/utils/logger.js +89 -0
  154. package/dist/esm/utils/model_name.js +31 -0
  155. package/dist/esm/utils/simple_zod_to_json.js +160 -0
  156. package/dist/esm/utils/variant_utils.js +24 -0
  157. package/dist/esm/version.js +9 -0
  158. package/dist/types/agents/active_streaming_tool.d.ts +29 -0
  159. package/dist/types/agents/base_agent.d.ts +167 -0
  160. package/dist/types/agents/base_llm_processor.d.ts +27 -0
  161. package/dist/types/agents/callback_context.d.ts +42 -0
  162. package/dist/types/agents/content_processor_utils.d.ts +36 -0
  163. package/dist/types/agents/functions.d.ts +90 -0
  164. package/dist/types/agents/instructions.d.ts +32 -0
  165. package/dist/types/agents/invocation_context.d.ts +155 -0
  166. package/dist/types/agents/live_request_queue.d.ts +67 -0
  167. package/dist/types/agents/llm_agent.d.ts +333 -0
  168. package/dist/types/agents/loop_agent.d.ts +31 -0
  169. package/dist/types/agents/parallel_agent.d.ts +21 -0
  170. package/dist/types/agents/readonly_context.d.ts +31 -0
  171. package/dist/types/agents/run_config.d.ts +76 -0
  172. package/dist/types/agents/sequential_agent.d.ts +26 -0
  173. package/dist/types/agents/transcription_entry.d.ts +17 -0
  174. package/dist/types/artifacts/base_artifact_service.d.ts +127 -0
  175. package/dist/types/artifacts/in_memory_artifact_service.d.ts +18 -0
  176. package/dist/types/auth/auth_credential.d.ts +227 -0
  177. package/dist/types/auth/auth_handler.d.ts +27 -0
  178. package/dist/types/auth/auth_schemes.d.ts +36 -0
  179. package/dist/types/auth/auth_tool.d.ts +51 -0
  180. package/dist/types/auth/credential_service/base_credential_service.d.ts +27 -0
  181. package/dist/types/auth/credential_service/in_memory_credential_service.d.ts +19 -0
  182. package/dist/types/code_executors/base_code_executor.d.ts +60 -0
  183. package/dist/types/code_executors/built_in_code_executor.d.ts +13 -0
  184. package/dist/types/code_executors/code_execution_utils.d.ts +99 -0
  185. package/dist/types/code_executors/code_executor_context.d.ts +92 -0
  186. package/dist/types/common.d.ts +51 -0
  187. package/dist/types/events/event.d.ts +81 -0
  188. package/dist/types/events/event_actions.d.ts +74 -0
  189. package/dist/types/examples/base_example_provider.d.ts +20 -0
  190. package/dist/types/examples/example.d.ts +19 -0
  191. package/dist/types/examples/example_util.d.ts +13 -0
  192. package/dist/types/index.d.ts +9 -0
  193. package/dist/types/index_web.d.ts +6 -0
  194. package/dist/types/memory/base_memory_service.d.ts +47 -0
  195. package/dist/types/memory/in_memory_memory_service.d.ts +18 -0
  196. package/dist/types/memory/memory_entry.d.ts +24 -0
  197. package/dist/types/models/base_llm.d.ts +46 -0
  198. package/dist/types/models/base_llm_connection.d.ts +51 -0
  199. package/dist/types/models/gemini_llm_connection.d.ts +54 -0
  200. package/dist/types/models/google_llm.d.ts +88 -0
  201. package/dist/types/models/llm_request.d.ts +49 -0
  202. package/dist/types/models/llm_response.d.ts +79 -0
  203. package/dist/types/models/registry.d.ts +45 -0
  204. package/dist/types/plugins/base_plugin.d.ts +310 -0
  205. package/dist/types/plugins/logging_plugin.d.ts +104 -0
  206. package/dist/types/plugins/plugin_manager.d.ts +155 -0
  207. package/dist/types/plugins/security_plugin.d.ts +60 -0
  208. package/dist/types/runner/in_memory_runner.d.ts +15 -0
  209. package/dist/types/runner/runner.d.ts +80 -0
  210. package/dist/types/sessions/base_session_service.d.ts +129 -0
  211. package/dist/types/sessions/in_memory_session_service.d.ts +32 -0
  212. package/dist/types/sessions/session.d.ts +46 -0
  213. package/dist/types/sessions/state.d.ts +57 -0
  214. package/dist/types/tools/agent_tool.d.ts +37 -0
  215. package/dist/types/tools/base_tool.d.ts +84 -0
  216. package/dist/types/tools/base_toolset.d.ts +64 -0
  217. package/dist/types/tools/forwarding_artifact_service.d.ts +21 -0
  218. package/dist/types/tools/function_tool.d.ts +48 -0
  219. package/dist/types/tools/google_search_tool.d.ts +18 -0
  220. package/dist/types/tools/long_running_tool.d.ts +18 -0
  221. package/dist/types/tools/mcp/mcp_session_manager.d.ts +57 -0
  222. package/dist/types/tools/mcp/mcp_tool.d.ts +30 -0
  223. package/dist/types/tools/mcp/mcp_toolset.d.ts +39 -0
  224. package/dist/types/tools/tool_confirmation.d.ts +25 -0
  225. package/dist/types/tools/tool_context.d.ts +63 -0
  226. package/dist/types/utils/deep_clone.d.ts +1 -0
  227. package/dist/types/utils/env_aware_utils.d.ts +31 -0
  228. package/dist/types/utils/gemini_schema_util.d.ts +23 -0
  229. package/dist/types/utils/logger.d.ts +41 -0
  230. package/dist/types/utils/model_name.d.ts +34 -0
  231. package/dist/types/utils/simple_zod_to_json.d.ts +12 -0
  232. package/dist/types/utils/variant_utils.d.ts +24 -0
  233. package/dist/types/version.d.ts +6 -0
  234. package/dist/web/agents/active_streaming_tool.js +14 -0
  235. package/dist/web/agents/base_agent.js +265 -0
  236. package/dist/web/agents/base_llm_processor.js +13 -0
  237. package/dist/web/agents/callback_context.js +68 -0
  238. package/dist/web/agents/content_processor_utils.js +268 -0
  239. package/dist/web/agents/functions.js +353 -0
  240. package/dist/web/agents/instructions.js +80 -0
  241. package/dist/web/agents/invocation_context.js +78 -0
  242. package/dist/web/agents/live_request_queue.js +124 -0
  243. package/dist/web/agents/llm_agent.js +973 -0
  244. package/dist/web/agents/loop_agent.js +71 -0
  245. package/dist/web/agents/parallel_agent.js +83 -0
  246. package/dist/web/agents/readonly_context.js +38 -0
  247. package/dist/web/agents/run_config.js +43 -0
  248. package/dist/web/agents/sequential_agent.js +99 -0
  249. package/dist/web/agents/transcription_entry.js +5 -0
  250. package/dist/web/artifacts/base_artifact_service.js +5 -0
  251. package/dist/web/artifacts/in_memory_artifact_service.js +89 -0
  252. package/dist/web/auth/auth_credential.js +16 -0
  253. package/dist/web/auth/auth_handler.js +62 -0
  254. package/dist/web/auth/auth_schemes.js +31 -0
  255. package/dist/web/auth/auth_tool.js +5 -0
  256. package/dist/web/auth/credential_service/base_credential_service.js +5 -0
  257. package/dist/web/auth/credential_service/in_memory_credential_service.js +33 -0
  258. package/dist/web/code_executors/base_code_executor.js +46 -0
  259. package/dist/web/code_executors/built_in_code_executor.js +28 -0
  260. package/dist/web/code_executors/code_execution_utils.js +105 -0
  261. package/dist/web/code_executors/code_executor_context.js +168 -0
  262. package/dist/web/common.js +85 -0
  263. package/dist/web/events/event.js +90 -0
  264. package/dist/web/events/event_actions.js +67 -0
  265. package/dist/web/examples/base_example_provider.js +10 -0
  266. package/dist/web/examples/example.js +5 -0
  267. package/dist/web/examples/example_util.js +75 -0
  268. package/dist/web/index.js +13 -0
  269. package/dist/web/index.js.map +7 -0
  270. package/dist/web/index_web.js +6 -0
  271. package/dist/web/memory/base_memory_service.js +5 -0
  272. package/dist/web/memory/in_memory_memory_service.js +67 -0
  273. package/dist/web/memory/memory_entry.js +5 -0
  274. package/dist/web/models/base_llm.js +47 -0
  275. package/dist/web/models/base_llm_connection.js +5 -0
  276. package/dist/web/models/gemini_llm_connection.js +120 -0
  277. package/dist/web/models/google_llm.js +332 -0
  278. package/dist/web/models/llm_request.js +50 -0
  279. package/dist/web/models/llm_response.js +41 -0
  280. package/dist/web/models/registry.js +91 -0
  281. package/dist/web/plugins/base_plugin.js +206 -0
  282. package/dist/web/plugins/logging_plugin.js +192 -0
  283. package/dist/web/plugins/plugin_manager.js +209 -0
  284. package/dist/web/plugins/security_plugin.js +119 -0
  285. package/dist/web/runner/in_memory_runner.js +28 -0
  286. package/dist/web/runner/runner.js +277 -0
  287. package/dist/web/sessions/base_session_service.js +41 -0
  288. package/dist/web/sessions/in_memory_session_service.js +154 -0
  289. package/dist/web/sessions/session.js +18 -0
  290. package/dist/web/sessions/state.js +87 -0
  291. package/dist/web/tools/agent_tool.js +118 -0
  292. package/dist/web/tools/base_tool.js +77 -0
  293. package/dist/web/tools/base_toolset.js +46 -0
  294. package/dist/web/tools/forwarding_artifact_service.js +41 -0
  295. package/dist/web/tools/function_tool.js +71 -0
  296. package/dist/web/tools/google_search_tool.js +46 -0
  297. package/dist/web/tools/long_running_tool.js +50 -0
  298. package/dist/web/tools/mcp/mcp_session_manager.js +35 -0
  299. package/dist/web/tools/mcp/mcp_tool.js +35 -0
  300. package/dist/web/tools/mcp/mcp_toolset.js +31 -0
  301. package/dist/web/tools/tool_confirmation.js +19 -0
  302. package/dist/web/tools/tool_context.js +99 -0
  303. package/dist/web/utils/deep_clone.js +14 -0
  304. package/dist/web/utils/env_aware_utils.js +49 -0
  305. package/dist/web/utils/gemini_schema_util.js +58 -0
  306. package/dist/web/utils/logger.js +89 -0
  307. package/dist/web/utils/model_name.js +31 -0
  308. package/dist/web/utils/simple_zod_to_json.js +174 -0
  309. package/dist/web/utils/variant_utils.js +24 -0
  310. package/dist/web/version.js +9 -0
  311. package/package.json +61 -0
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export { BaseAgent } from './agents/base_agent.js';
7
+ export { CallbackContext } from './agents/callback_context.js';
8
+ export { functionsExportedForTestingOnly } from './agents/functions.js';
9
+ export { InvocationContext } from './agents/invocation_context.js';
10
+ export { LiveRequestQueue } from './agents/live_request_queue.js';
11
+ export type { LiveRequest } from './agents/live_request_queue.js';
12
+ export { LlmAgent } from './agents/llm_agent.js';
13
+ export type { AfterModelCallback, AfterToolCallback, BeforeModelCallback, BeforeToolCallback, SingleAfterModelCallback, SingleAfterToolCallback, SingleBeforeModelCallback, SingleBeforeToolCallback } from './agents/llm_agent.js';
14
+ export { LoopAgent } from './agents/loop_agent.js';
15
+ export { ParallelAgent } from './agents/parallel_agent.js';
16
+ export { RunConfig, StreamingMode } from './agents/run_config.js';
17
+ export { SequentialAgent } from './agents/sequential_agent.js';
18
+ export { InMemoryArtifactService } from './artifacts/in_memory_artifact_service.js';
19
+ export type { BaseCredentialService } from './auth/credential_service/base_credential_service.js';
20
+ export { createEvent, getFunctionCalls, getFunctionResponses, hasTrailingCodeExecutionResult, isFinalResponse } from './events/event.js';
21
+ export type { Event } from './events/event.js';
22
+ export type { EventActions } from './events/event_actions.js';
23
+ export { InMemoryMemoryService } from './memory/in_memory_memory_service.js';
24
+ export { BaseLlm } from './models/base_llm.js';
25
+ export type { BaseLlmConnection } from './models/base_llm_connection.js';
26
+ export type { LlmRequest } from './models/llm_request.js';
27
+ export type { LlmResponse } from './models/llm_response.js';
28
+ export { BasePlugin } from './plugins/base_plugin.js';
29
+ export { LoggingPlugin } from './plugins/logging_plugin.js';
30
+ export { PluginManager } from './plugins/plugin_manager.js';
31
+ export { getAskUserConfirmationFunctionCalls, InMemoryPolicyEngine, PolicyOutcome, REQUEST_CONFIRMATION_FUNCTION_CALL_NAME, SecurityPlugin } from './plugins/security_plugin.js';
32
+ export type { BasePolicyEngine, PolicyCheckResult, ToolCallPolicyContext } from './plugins/security_plugin.js';
33
+ export { InMemoryRunner } from './runner/in_memory_runner.js';
34
+ export { Runner } from './runner/runner.js';
35
+ export { InMemorySessionService } from './sessions/in_memory_session_service.js';
36
+ export { createSession } from './sessions/session.js';
37
+ export type { Session } from './sessions/session.js';
38
+ export { AgentTool } from './tools/agent_tool.js';
39
+ export { BaseTool } from './tools/base_tool.js';
40
+ export { BaseToolset } from './tools/base_toolset.js';
41
+ export { FunctionTool } from './tools/function_tool.js';
42
+ export { GOOGLE_SEARCH } from './tools/google_search_tool.js';
43
+ export { LongRunningFunctionTool } from './tools/long_running_tool.js';
44
+ export { ToolConfirmation } from './tools/tool_confirmation.js';
45
+ export { ToolContext } from './tools/tool_context.js';
46
+ export { LogLevel, setLogLevel } from './utils/logger.js';
47
+ export { zodObjectToSchema } from './utils/simple_zod_to_json.js';
48
+ export * from './artifacts/base_artifact_service.js';
49
+ export * from './memory/base_memory_service.js';
50
+ export * from './sessions/base_session_service.js';
51
+ export * from './tools/base_tool.js';
@@ -0,0 +1,81 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { FunctionCall, FunctionResponse } from '@google/genai';
7
+ import { LlmResponse } from '../models/llm_response.js';
8
+ import { EventActions } from './event_actions.js';
9
+ /**
10
+ * Represents an event in a conversation between agents and users.
11
+
12
+ It is used to store the content of the conversation, as well as the actions
13
+ taken by the agents like function calls, etc.
14
+ */
15
+ export interface Event extends LlmResponse {
16
+ /**
17
+ * The unique identifier of the event.
18
+ * Do not assign the ID. It will be assigned by the session.
19
+ */
20
+ id: string;
21
+ /**
22
+ * The invocation ID of the event. Should be non-empty before appending to a
23
+ * session.
24
+ */
25
+ invocationId: string;
26
+ /**
27
+ * "user" or the name of the agent, indicating who appended the event to the
28
+ * session.
29
+ */
30
+ author?: string;
31
+ /**
32
+ * The actions taken by the agent.
33
+ */
34
+ actions: EventActions;
35
+ /**
36
+ * Set of ids of the long running function calls. Agent client will know from
37
+ * this field about which function call is long running. Only valid for
38
+ * function call event
39
+ */
40
+ longRunningToolIds?: string[];
41
+ /**
42
+ * The branch of the event.
43
+ * The format is like agent_1.agent_2.agent_3, where agent_1 is the parent of
44
+ * agent_2, and agent_2 is the parent of agent_3.
45
+ *
46
+ * Branch is used when multiple sub-agent shouldn't see their peer agents'
47
+ * conversation history.
48
+ */
49
+ branch?: string;
50
+ /**
51
+ * The timestamp of the event.
52
+ */
53
+ timestamp: number;
54
+ }
55
+ /**
56
+ * Creates an event from a partial event.
57
+ *
58
+ * @param params The partial event to create the event from.
59
+ * @returns The event.
60
+ */
61
+ export declare function createEvent(params?: Partial<Event>): Event;
62
+ /**
63
+ * Returns whether the event is the final response of the agent.
64
+ */
65
+ export declare function isFinalResponse(event: Event): boolean;
66
+ /**
67
+ * Returns the function calls in the event.
68
+ */
69
+ export declare function getFunctionCalls(event: Event): FunctionCall[];
70
+ /**
71
+ * Returns the function responses in the event.
72
+ */
73
+ export declare function getFunctionResponses(event: Event): FunctionResponse[];
74
+ /**
75
+ * Returns whether the event has a trailing code execution result.
76
+ */
77
+ export declare function hasTrailingCodeExecutionResult(event: Event): boolean;
78
+ /**
79
+ * Generates a new unique ID for the event.
80
+ */
81
+ export declare function createNewEventId(): string;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { ToolConfirmation } from '../tools/tool_confirmation.js';
7
+ type AuthConfig = any;
8
+ /**
9
+ * Represents the actions attached to an event.
10
+ */
11
+ export interface EventActions {
12
+ /**
13
+ * If true, it won't call model to summarize function response.
14
+ * Only used for function_response event.
15
+ */
16
+ skipSummarization?: boolean;
17
+ /**
18
+ * Indicates that the event is updating the state with the given delta.
19
+ */
20
+ stateDelta: {
21
+ [key: string]: unknown;
22
+ };
23
+ /**
24
+ * Indicates that the event is updating an artifact. key is the filename,
25
+ * value is the version.
26
+ */
27
+ artifactDelta: {
28
+ [key: string]: number;
29
+ };
30
+ /**
31
+ * If set, the event transfers to the specified agent.
32
+ */
33
+ transferToAgent?: string;
34
+ /**
35
+ * The agent is escalating to a higher level agent.
36
+ */
37
+ escalate?: boolean;
38
+ /**
39
+ * Authentication configurations requested by tool responses.
40
+ *
41
+ * This field will only be set by a tool response event indicating tool
42
+ * request auth credential.
43
+ * - Keys: The function call id. Since one function response event could
44
+ * contain multiple function responses that correspond to multiple function
45
+ * calls. Each function call could request different auth configs. This id is
46
+ * used to identify the function call.
47
+ * - Values: The requested auth config.
48
+ */
49
+ requestedAuthConfigs: {
50
+ [key: string]: AuthConfig;
51
+ };
52
+ /**
53
+ * A dict of tool confirmation requested by this event, keyed by the function
54
+ * call id.
55
+ */
56
+ requestedToolConfirmations: {
57
+ [key: string]: ToolConfirmation;
58
+ };
59
+ }
60
+ /**
61
+ * Creates an EventActions object.
62
+ */
63
+ export declare function createEventActions(state?: Partial<EventActions>): EventActions;
64
+ /**
65
+ * Merges a list of EventActions objects into a single EventActions object.
66
+ *
67
+ * 1. It merges dictionaries (stateDelta, artifactDelta, requestedAuthConfigs)
68
+ * by adding all the properties from each source.
69
+ *
70
+ * 2. For other properties (skipSummarization,transferToAgent, escalate), the
71
+ * last one wins.
72
+ */
73
+ export declare function mergeEventActions(sources: Array<Partial<EventActions>>, target?: EventActions): EventActions;
74
+ export {};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Example } from './example.js';
7
+ /**
8
+ * Base class for example providers.
9
+ *
10
+ * This class defines the interface for providing examples for a given query.
11
+ */
12
+ export declare abstract class BaseExampleProvider {
13
+ /**
14
+ * Returns a list of examples for a given query.
15
+ *
16
+ * @param query The query to get examples for.
17
+ * @return A list of Example objects.
18
+ */
19
+ abstract getExamples(query: string): Example[];
20
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Content } from '@google/genai';
7
+ /**
8
+ * A few-shot example.
9
+ */
10
+ export interface Example {
11
+ /**
12
+ * The input content for the example.
13
+ */
14
+ input: Content;
15
+ /**
16
+ * The expected output content for the example.
17
+ */
18
+ output: Content[];
19
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { BaseExampleProvider } from './base_example_provider.js';
7
+ import { Example } from './example.js';
8
+ /**
9
+ * Converts a list of examples to a string that can be used in a system
10
+ * instruction.
11
+ */
12
+ export declare function convertExamplesToText(examples: Example[], model?: string): string;
13
+ export declare function buildExampleSi(examples: Example[] | BaseExampleProvider, query: string, model?: string): string;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export * from './common.js';
7
+ export * from './tools/mcp/mcp_session_manager.js';
8
+ export * from './tools/mcp/mcp_tool.js';
9
+ export * from './tools/mcp/mcp_toolset.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export * from './common.js';
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Session } from '../sessions/session.js';
7
+ import { MemoryEntry } from './memory_entry.js';
8
+ /**
9
+ * Represents the response from a memory search.
10
+ */
11
+ export interface SearchMemoryResponse {
12
+ /**
13
+ * A list of memory entries that are related to the search query.
14
+ */
15
+ memories: MemoryEntry[];
16
+ }
17
+ /**
18
+ * The parameters for `searchMemory`.
19
+ */
20
+ export interface SearchMemoryRequest {
21
+ appName: string;
22
+ userId: string;
23
+ query: string;
24
+ }
25
+ /**
26
+ * Base interface for memory services.
27
+ *
28
+ * The service provides functionalities to ingest sessions into memory so that
29
+ * the memory can be used for user queries.
30
+ */
31
+ export interface BaseMemoryService {
32
+ /**
33
+ * Adds a session to the memory.
34
+ *
35
+ * @param session The session to add to the memory.
36
+ * @return A promise that resolves when the session is added to the memory.
37
+ */
38
+ addSessionToMemory(session: Session): Promise<void>;
39
+ /**
40
+ * Searches for sessions that match the query.
41
+ *
42
+ * @param request The request to search memory.
43
+ * @return A promise that resolves to SearchMemoryResponse containing the
44
+ * matching memories.
45
+ */
46
+ searchMemory(request: SearchMemoryRequest): Promise<SearchMemoryResponse>;
47
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Session } from '../sessions/session.js';
7
+ import { BaseMemoryService, SearchMemoryRequest, SearchMemoryResponse } from './base_memory_service.js';
8
+ /**
9
+ * An in-memory memory service for prototyping purpose only.
10
+ *
11
+ * Uses keyword matching instead of semantic search.
12
+ */
13
+ export declare class InMemoryMemoryService implements BaseMemoryService {
14
+ private readonly memories;
15
+ private readonly sessionEvents;
16
+ addSessionToMemory(session: Session): Promise<void>;
17
+ searchMemory(req: SearchMemoryRequest): Promise<SearchMemoryResponse>;
18
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Content } from '@google/genai';
7
+ /**
8
+ * Represents one memory entry.
9
+ */
10
+ export interface MemoryEntry {
11
+ /**
12
+ * The content of the memory entry.
13
+ */
14
+ content: Content;
15
+ /**
16
+ * The author of the memory.
17
+ */
18
+ author?: string;
19
+ /**
20
+ * The timestamp when the original content of this memory happened.
21
+ * This string will be forwarded to LLM. Preferred format is ISO 8601 format.
22
+ */
23
+ timestamp?: string;
24
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { BaseLlmConnection } from './base_llm_connection.js';
7
+ import { LlmRequest } from './llm_request.js';
8
+ import { LlmResponse } from './llm_response.js';
9
+ /**
10
+ * The BaseLLM class.
11
+ */
12
+ export declare abstract class BaseLlm {
13
+ readonly model: string;
14
+ /**
15
+ * Creates an instance of BaseLLM.
16
+ *
17
+ * @param model The name of the LLM, e.g. gemini-1.5-flash or
18
+ * gemini-1.5-flash-001.
19
+ */
20
+ constructor(model: string);
21
+ /**
22
+ * List of supported models in regex for LlmRegistry.
23
+ */
24
+ static readonly supportedModels: Array<string | RegExp>;
25
+ /**
26
+ * Generates one content from the given contents and tools.
27
+ *
28
+ * @param llmRequest LlmRequest, the request to send to the LLM.
29
+ * For non-streaming call, it will only yield one Content.
30
+ * @return A generator of LlmResponse.
31
+ */
32
+ abstract generateContentAsync(llmRequest: LlmRequest): AsyncGenerator<LlmResponse, void>;
33
+ /**
34
+ * Creates a live connection to the LLM.
35
+ *
36
+ * @param llmRequest LlmRequest, the request to send to the LLM.
37
+ * @return A live connection to the LLM.
38
+ */
39
+ abstract connect(llmRequest: LlmRequest): Promise<BaseLlmConnection>;
40
+ /**
41
+ * Appends a user content, so that model can continue to output.
42
+ *
43
+ * @param llmRequest LlmRequest, the request to send to the LLM.
44
+ */
45
+ maybeAppendUserContent(llmRequest: LlmRequest): void;
46
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Content, Blob } from '@google/genai';
7
+ import { LlmResponse } from './llm_response.js';
8
+ /**
9
+ * The base class for a live model connection.
10
+ */
11
+ export interface BaseLlmConnection {
12
+ /**
13
+ * Sends the conversation history to the model.
14
+ *
15
+ * You call this method right after setting up the model connection.
16
+ * The model will respond if the last content is from user, otherwise it will
17
+ * wait for new user input before responding.
18
+ *
19
+ * @param history The conversation history to send to the model.
20
+ */
21
+ sendHistory(history: Content[]): Promise<void>;
22
+ /**
23
+ * Sends the content to the model.
24
+ *
25
+ * The model will respond immediately upon receiving the content.
26
+ * If you send function responses, all parts in the content should be function
27
+ * responses.
28
+ *
29
+ * @param content The content to send to the model.
30
+ */
31
+ sendContent(content: Content): Promise<void>;
32
+ /**
33
+ * Sends a chunk of audio or a frame of video to the model in realtime.
34
+ *
35
+ * The model may not respond immediately upon receiving the blob. It will do
36
+ * voice activity detection and decide when to respond.
37
+ *
38
+ * @param blob The blob to send to the model.
39
+ */
40
+ sendRealtime(blob: Blob): Promise<void>;
41
+ /**
42
+ * Receives the model response using the llm server connection.
43
+ *
44
+ * @return A generator of LlmResponse.
45
+ */
46
+ receive(): AsyncGenerator<LlmResponse, void, void>;
47
+ /**
48
+ * Closes the llm server connection.
49
+ */
50
+ close(): Promise<void>;
51
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Blob, Content, Session } from '@google/genai';
7
+ import { BaseLlmConnection } from './base_llm_connection.js';
8
+ import { LlmResponse } from './llm_response.js';
9
+ /** The Gemini model connection. */
10
+ export declare class GeminiLlmConnection implements BaseLlmConnection {
11
+ private readonly geminiSession;
12
+ constructor(geminiSession: Session);
13
+ /**
14
+ * Sends the conversation history to the gemini model.
15
+ *
16
+ * You call this method right after setting up the model connection.
17
+ * The model will respond if the last content is from user, otherwise it will
18
+ * wait for new user input before responding.
19
+ *
20
+ * @param history The conversation history to send to the model.
21
+ */
22
+ sendHistory(history: Content[]): Promise<void>;
23
+ /**
24
+ * Sends a user content to the gemini model.
25
+ *
26
+ * The model will respond immediately upon receiving the content.
27
+ * If you send function responses, all parts in the content should be function
28
+ * responses.
29
+ *
30
+ * @param content The content to send to the model.
31
+ */
32
+ sendContent(content: Content): Promise<void>;
33
+ /**
34
+ * Sends a chunk of audio or a frame of video to the model in realtime.
35
+ *
36
+ * @param blob The blob to send to the model.
37
+ */
38
+ sendRealtime(blob: Blob): Promise<void>;
39
+ /**
40
+ * Builds a full text response.
41
+ *
42
+ * The text should not be partial and the returned LlmResponse is not be
43
+ * partial.
44
+ *
45
+ * @param text The text to be included in the response.
46
+ * @returns An LlmResponse containing the full text.
47
+ */
48
+ private buildFullTextResponse;
49
+ receive(): AsyncGenerator<LlmResponse, void, void>;
50
+ /**
51
+ * Closes the llm server connection.
52
+ */
53
+ close(): Promise<void>;
54
+ }
@@ -0,0 +1,88 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { GoogleGenAI } from '@google/genai';
7
+ import { GoogleLLMVariant } from '../utils/variant_utils.js';
8
+ import { BaseLlm } from './base_llm.js';
9
+ import { BaseLlmConnection } from './base_llm_connection.js';
10
+ import { LlmRequest } from './llm_request.js';
11
+ import { LlmResponse } from './llm_response.js';
12
+ /**
13
+ * The parameters for creating a Gemini instance.
14
+ */
15
+ export interface GeminiParams {
16
+ /**
17
+ * The name of the model to use. Defaults to 'gemini-2.5-flash'.
18
+ */
19
+ model?: string;
20
+ /**
21
+ * The API key to use for the Gemini API. If not provided, it will look for
22
+ * the GOOGLE_GENAI_API_KEY or GEMINI_API_KEY environment variable.
23
+ */
24
+ apiKey?: string;
25
+ /**
26
+ * Whether to use Vertex AI. If true, `project`, `location`
27
+ * should be provided.
28
+ */
29
+ vertexai?: boolean;
30
+ /**
31
+ * The Vertex AI project ID. Required if `vertexai` is true.
32
+ */
33
+ project?: string;
34
+ /**
35
+ * The Vertex AI location. Required if `vertexai` is true.
36
+ */
37
+ location?: string;
38
+ /**
39
+ * Headers to merge with internally crafted headers.
40
+ */
41
+ headers?: Record<string, string>;
42
+ }
43
+ /**
44
+ * Integration for Gemini models.
45
+ */
46
+ export declare class Gemini extends BaseLlm {
47
+ private readonly apiKey?;
48
+ private readonly vertexai;
49
+ private readonly project?;
50
+ private readonly location?;
51
+ private readonly headers?;
52
+ /**
53
+ * @param params The parameters for creating a Gemini instance.
54
+ */
55
+ constructor({ model, apiKey, vertexai, project, location, headers }?: GeminiParams);
56
+ /**
57
+ * A list of model name patterns that are supported by this LLM.
58
+ *
59
+ * @returns A list of supported models.
60
+ */
61
+ static readonly supportedModels: Array<string | RegExp>;
62
+ private _apiClient?;
63
+ private _apiBackend?;
64
+ private _trackingHeaders?;
65
+ private _liveApiVersion?;
66
+ private _liveApiClient?;
67
+ /**
68
+ * Sends a request to the Gemini model.
69
+ *
70
+ * @param llmRequest LlmRequest, the request to send to the Gemini model.
71
+ * @param stream bool = false, whether to do streaming call.
72
+ * @yields LlmResponse: The model response.
73
+ */
74
+ generateContentAsync(llmRequest: LlmRequest, stream?: boolean): AsyncGenerator<LlmResponse, void>;
75
+ get apiClient(): GoogleGenAI;
76
+ get apiBackend(): GoogleLLMVariant;
77
+ get trackingHeaders(): Record<string, string>;
78
+ get liveApiVersion(): string;
79
+ get liveApiClient(): GoogleGenAI;
80
+ /**
81
+ * Connects to the Gemini model and returns an llm connection.
82
+ *
83
+ * @param llmRequest LlmRequest, the request to send to the Gemini model.
84
+ * @returns BaseLlmConnection, the connection to the Gemini model.
85
+ */
86
+ connect(llmRequest: LlmRequest): Promise<BaseLlmConnection>;
87
+ private preprocessRequest;
88
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Content, GenerateContentConfig, LiveConnectConfig, SchemaUnion } from '@google/genai';
7
+ import { BaseTool } from '../tools/base_tool.js';
8
+ /**
9
+ * LLM request class that allows passing in tools, output schema and system
10
+ * instructions to the model.
11
+ */
12
+ export interface LlmRequest {
13
+ /**
14
+ * The model name.
15
+ */
16
+ model?: string;
17
+ /**
18
+ * The contents to send to the model.
19
+ */
20
+ contents: Content[];
21
+ /**
22
+ * Additional config for the generate content request.
23
+ * Tools in generateContentConfig should not be set directly; use appendTools.
24
+ */
25
+ config?: GenerateContentConfig;
26
+ liveConnectConfig: LiveConnectConfig;
27
+ /**
28
+ * The tools dictionary. Excluded from JSON serialization.
29
+ */
30
+ toolsDict: {
31
+ [key: string]: BaseTool;
32
+ };
33
+ }
34
+ /**
35
+ * Appends instructions to the system instruction.
36
+ * @param instructions The instructions to append.
37
+ */
38
+ export declare function appendInstructions(llmRequest: LlmRequest, instructions: string[]): void;
39
+ /**
40
+ * Appends tools to the request.
41
+ * @param tools The tools to append.
42
+ */
43
+ export declare function appendTools(llmRequest: LlmRequest, tools: BaseTool[]): void;
44
+ /**
45
+ * Sets the output schema for the request.
46
+ *
47
+ * @param schema The JSON Schema object to set as the output schema.
48
+ */
49
+ export declare function setOutputSchema(llmRequest: LlmRequest, schema: SchemaUnion): void;