@google/adk 1.1.0 → 1.3.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 (300) hide show
  1. package/dist/cjs/agents/base_agent.js +19 -1
  2. package/dist/cjs/agents/functions.js +4 -0
  3. package/dist/cjs/agents/instructions.js +81 -33
  4. package/dist/cjs/agents/invocation_context.js +0 -1
  5. package/dist/cjs/agents/llm_agent.js +52 -5
  6. package/dist/cjs/agents/processors/agent_transfer_llm_request_processor.js +7 -0
  7. package/dist/cjs/agents/processors/basic_llm_request_processor.js +8 -1
  8. package/dist/cjs/agents/processors/content_processor_utils.js +37 -24
  9. package/dist/cjs/agents/processors/content_request_processor.js +7 -0
  10. package/dist/cjs/agents/processors/context_compactor_request_processor.js +12 -0
  11. package/dist/cjs/agents/processors/identity_llm_request_processor.js +7 -0
  12. package/dist/cjs/agents/processors/instructions_llm_request_processor.js +5 -0
  13. package/dist/cjs/agents/processors/request_confirmation_llm_request_processor.js +9 -1
  14. package/dist/cjs/agents/processors/tool_filter_request_processor.js +7 -1
  15. package/dist/cjs/auth/auth_preprocessor.js +12 -10
  16. package/dist/cjs/auth/oauth2/oauth2_discovery.js +26 -2
  17. package/dist/cjs/code_executors/agent_engine_sandbox_code_executor.js +305 -0
  18. package/dist/cjs/code_executors/code_execution_utils.js +1 -1
  19. package/dist/cjs/code_executors/code_executor_context.js +7 -7
  20. package/dist/cjs/common.js +50 -0
  21. package/dist/cjs/context/summarizers/llm_summarizer.js +11 -0
  22. package/dist/cjs/context/token_based_context_compactor.js +1 -1
  23. package/dist/cjs/events/event.js +4 -2
  24. package/dist/cjs/index.js +14 -0
  25. package/dist/cjs/integrations/agent_registry/agent_registry.js +362 -0
  26. package/dist/cjs/integrations/agent_registry/agent_registry_mcp_toolset.js +122 -0
  27. package/dist/cjs/integrations/agent_registry/helpers.js +57 -0
  28. package/dist/cjs/integrations/agent_registry/types.js +50 -0
  29. package/dist/cjs/memory/vertex_ai_memory_bank_service.js +496 -0
  30. package/dist/cjs/models/gemini_llm_connection.js +62 -19
  31. package/dist/cjs/models/google_llm.js +26 -8
  32. package/dist/cjs/plugins/security_plugin.js +16 -0
  33. package/dist/cjs/runner/in_memory_runner.js +10 -5
  34. package/dist/cjs/runner/runner.js +32 -2
  35. package/dist/cjs/sessions/base_session_service.js +13 -2
  36. package/dist/cjs/sessions/database_session_service.js +51 -5
  37. package/dist/cjs/sessions/db/schema.js +45 -10
  38. package/dist/cjs/sessions/in_memory_session_service.js +72 -15
  39. package/dist/cjs/sessions/registry.js +4 -0
  40. package/dist/cjs/sessions/vertex_ai_session_service.js +429 -0
  41. package/dist/cjs/skills/gcp_skill_registry.js +104 -0
  42. package/dist/cjs/skills/loader.js +65 -0
  43. package/dist/cjs/skills/skill_registry.js +27 -0
  44. package/dist/cjs/tools/agent_tool.js +10 -5
  45. package/dist/cjs/tools/exit_loop_tool.js +9 -0
  46. package/dist/cjs/tools/function_tool.js +7 -2
  47. package/dist/cjs/tools/google_maps_grounding_tool.js +80 -0
  48. package/dist/cjs/tools/long_running_tool.js +2 -1
  49. package/dist/cjs/tools/mcp/mcp_session_manager.js +11 -0
  50. package/dist/cjs/tools/mcp/mcp_tool.js +10 -6
  51. package/dist/cjs/tools/mcp/mcp_toolset.js +26 -3
  52. package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +78 -0
  53. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +84 -0
  54. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +133 -0
  55. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +232 -0
  56. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +224 -0
  57. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +127 -0
  58. package/dist/cjs/tools/openapi_tool/openapi_toolset.js +133 -0
  59. package/dist/cjs/tools/openapi_tool/rest_api_tool.js +256 -0
  60. package/dist/cjs/tools/skill/load_skill_resource_tool.js +27 -28
  61. package/dist/cjs/tools/skill/load_skill_tool.js +12 -1
  62. package/dist/cjs/tools/skill/run_skill_script_tool.js +12 -1
  63. package/dist/cjs/tools/skill/search_skills_tool.js +108 -0
  64. package/dist/cjs/tools/skill/skill_toolset.js +40 -5
  65. package/dist/cjs/tools/vertex_rag_retrieval_tool.js +64 -0
  66. package/dist/cjs/utils/async_queue.js +88 -0
  67. package/dist/cjs/utils/case_utils.js +53 -0
  68. package/dist/cjs/utils/env_aware_utils.js +4 -0
  69. package/dist/cjs/utils/file_utils.js +28 -0
  70. package/dist/cjs/utils/gemini_schema_util.js +18 -0
  71. package/dist/cjs/utils/live_connection_utils.js +284 -0
  72. package/dist/cjs/utils/model_name.js +9 -0
  73. package/dist/cjs/utils/partial_copy.js +51 -0
  74. package/dist/cjs/utils/streaming_utils.js +169 -122
  75. package/dist/cjs/utils/vertex_ai_utils.js +50 -0
  76. package/dist/cjs/version.js +1 -1
  77. package/dist/esm/agents/base_agent.js +19 -1
  78. package/dist/esm/agents/functions.js +4 -0
  79. package/dist/esm/agents/instructions.js +81 -33
  80. package/dist/esm/agents/invocation_context.js +0 -1
  81. package/dist/esm/agents/llm_agent.js +53 -5
  82. package/dist/esm/agents/processors/agent_transfer_llm_request_processor.js +7 -0
  83. package/dist/esm/agents/processors/basic_llm_request_processor.js +8 -1
  84. package/dist/esm/agents/processors/content_processor_utils.js +35 -23
  85. package/dist/esm/agents/processors/content_request_processor.js +7 -0
  86. package/dist/esm/agents/processors/context_compactor_request_processor.js +12 -0
  87. package/dist/esm/agents/processors/identity_llm_request_processor.js +7 -0
  88. package/dist/esm/agents/processors/instructions_llm_request_processor.js +5 -0
  89. package/dist/esm/agents/processors/request_confirmation_llm_request_processor.js +9 -1
  90. package/dist/esm/agents/processors/tool_filter_request_processor.js +7 -1
  91. package/dist/esm/auth/auth_preprocessor.js +12 -10
  92. package/dist/esm/auth/oauth2/oauth2_discovery.js +26 -2
  93. package/dist/esm/code_executors/agent_engine_sandbox_code_executor.js +281 -0
  94. package/dist/esm/code_executors/code_execution_utils.js +1 -1
  95. package/dist/esm/code_executors/code_executor_context.js +7 -7
  96. package/dist/esm/common.js +43 -1
  97. package/dist/esm/context/summarizers/llm_summarizer.js +11 -0
  98. package/dist/esm/context/token_based_context_compactor.js +1 -1
  99. package/dist/esm/events/event.js +4 -2
  100. package/dist/esm/index.js +11 -0
  101. package/dist/esm/integrations/agent_registry/agent_registry.js +333 -0
  102. package/dist/esm/integrations/agent_registry/agent_registry_mcp_toolset.js +96 -0
  103. package/dist/esm/integrations/agent_registry/helpers.js +28 -0
  104. package/dist/esm/integrations/agent_registry/types.js +20 -0
  105. package/dist/esm/memory/vertex_ai_memory_bank_service.js +468 -0
  106. package/dist/esm/models/gemini_llm_connection.js +62 -19
  107. package/dist/esm/models/google_llm.js +26 -8
  108. package/dist/esm/plugins/security_plugin.js +16 -0
  109. package/dist/esm/runner/in_memory_runner.js +10 -5
  110. package/dist/esm/runner/runner.js +32 -2
  111. package/dist/esm/sessions/base_session_service.js +11 -1
  112. package/dist/esm/sessions/database_session_service.js +51 -5
  113. package/dist/esm/sessions/db/schema.js +44 -10
  114. package/dist/esm/sessions/in_memory_session_service.js +74 -16
  115. package/dist/esm/sessions/registry.js +7 -0
  116. package/dist/esm/sessions/vertex_ai_session_service.js +405 -0
  117. package/dist/esm/skills/gcp_skill_registry.js +78 -0
  118. package/dist/esm/skills/loader.js +64 -0
  119. package/dist/esm/skills/skill_registry.js +7 -0
  120. package/dist/esm/tools/agent_tool.js +10 -5
  121. package/dist/esm/tools/exit_loop_tool.js +9 -0
  122. package/dist/esm/tools/function_tool.js +7 -2
  123. package/dist/esm/tools/google_maps_grounding_tool.js +54 -0
  124. package/dist/esm/tools/long_running_tool.js +2 -1
  125. package/dist/esm/tools/mcp/mcp_session_manager.js +11 -0
  126. package/dist/esm/tools/mcp/mcp_tool.js +10 -6
  127. package/dist/esm/tools/mcp/mcp_toolset.js +26 -3
  128. package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +48 -0
  129. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +60 -0
  130. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +111 -0
  131. package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +206 -0
  132. package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +198 -0
  133. package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +101 -0
  134. package/dist/esm/tools/openapi_tool/openapi_toolset.js +97 -0
  135. package/dist/esm/tools/openapi_tool/rest_api_tool.js +229 -0
  136. package/dist/esm/tools/skill/load_skill_resource_tool.js +26 -27
  137. package/dist/esm/tools/skill/load_skill_tool.js +12 -1
  138. package/dist/esm/tools/skill/run_skill_script_tool.js +12 -1
  139. package/dist/esm/tools/skill/search_skills_tool.js +82 -0
  140. package/dist/esm/tools/skill/skill_toolset.js +40 -5
  141. package/dist/esm/tools/vertex_rag_retrieval_tool.js +36 -0
  142. package/dist/esm/utils/async_queue.js +60 -0
  143. package/dist/esm/utils/case_utils.js +25 -0
  144. package/dist/esm/utils/env_aware_utils.js +4 -0
  145. package/dist/esm/utils/file_utils.js +26 -0
  146. package/dist/esm/utils/gemini_schema_util.js +18 -0
  147. package/dist/esm/utils/live_connection_utils.js +256 -0
  148. package/dist/esm/utils/model_name.js +8 -0
  149. package/dist/esm/utils/partial_copy.js +23 -0
  150. package/dist/esm/utils/streaming_utils.js +167 -121
  151. package/dist/esm/utils/vertex_ai_utils.js +22 -0
  152. package/dist/esm/version.js +1 -1
  153. package/dist/types/a2a/a2a_remote_agent.d.ts +14 -0
  154. package/dist/types/a2a/a2a_remote_agent_utils.d.ts +29 -4
  155. package/dist/types/a2a/event_converter_utils.d.ts +14 -1
  156. package/dist/types/a2a/metadata_converter_utils.d.ts +18 -0
  157. package/dist/types/a2a/part_converter_utils.d.ts +51 -6
  158. package/dist/types/agents/invocation_context.d.ts +0 -9
  159. package/dist/types/agents/llm_agent.d.ts +14 -0
  160. package/dist/types/agents/processors/agent_transfer_llm_request_processor.d.ts +14 -0
  161. package/dist/types/agents/processors/base_llm_processor.d.ts +12 -4
  162. package/dist/types/agents/processors/basic_llm_request_processor.d.ts +12 -0
  163. package/dist/types/agents/processors/content_processor_utils.d.ts +26 -0
  164. package/dist/types/agents/processors/content_request_processor.d.ts +16 -0
  165. package/dist/types/agents/processors/context_compactor_request_processor.d.ts +12 -0
  166. package/dist/types/agents/processors/identity_llm_request_processor.d.ts +11 -0
  167. package/dist/types/agents/processors/request_confirmation_llm_request_processor.d.ts +14 -1
  168. package/dist/types/agents/processors/tool_filter_request_processor.d.ts +12 -1
  169. package/dist/types/agents/run_config.d.ts +15 -0
  170. package/dist/types/code_executors/agent_engine_sandbox_code_executor.d.ts +51 -0
  171. package/dist/types/common.d.ts +19 -1
  172. package/dist/types/context/summarizers/llm_summarizer.d.ts +17 -0
  173. package/dist/types/events/event_actions.d.ts +25 -8
  174. package/dist/types/events/structured_events.d.ts +13 -0
  175. package/dist/types/examples/example_util.d.ts +25 -0
  176. package/dist/types/index.d.ts +6 -0
  177. package/dist/types/integrations/agent_registry/agent_registry.d.ts +94 -0
  178. package/dist/types/integrations/agent_registry/agent_registry_mcp_toolset.d.ts +62 -0
  179. package/dist/types/integrations/agent_registry/helpers.d.ts +7 -0
  180. package/dist/types/integrations/agent_registry/types.d.ts +101 -0
  181. package/dist/types/memory/vertex_ai_memory_bank_service.d.ts +52 -0
  182. package/dist/types/models/base_llm_connection.d.ts +10 -0
  183. package/dist/types/models/gemini_llm_connection.d.ts +15 -4
  184. package/dist/types/models/llm_response.d.ts +10 -1
  185. package/dist/types/plugins/security_plugin.d.ts +30 -0
  186. package/dist/types/runner/in_memory_runner.d.ts +28 -1
  187. package/dist/types/runner/runner.d.ts +47 -0
  188. package/dist/types/sessions/base_session_service.d.ts +22 -0
  189. package/dist/types/sessions/database_session_service.d.ts +1 -1
  190. package/dist/types/sessions/db/schema.d.ts +1 -0
  191. package/dist/types/sessions/in_memory_session_service.d.ts +1 -1
  192. package/dist/types/sessions/vertex_ai_session_service.d.ts +37 -0
  193. package/dist/types/skills/gcp_skill_registry.d.ts +24 -0
  194. package/dist/types/skills/loader.d.ts +7 -0
  195. package/dist/types/skills/skill.d.ts +1 -1
  196. package/dist/types/skills/skill_registry.d.ts +29 -0
  197. package/dist/types/tools/exit_loop_tool.d.ts +9 -0
  198. package/dist/types/tools/function_tool.d.ts +22 -2
  199. package/dist/types/tools/google_maps_grounding_tool.d.ts +22 -0
  200. package/dist/types/tools/long_running_tool.d.ts +11 -1
  201. package/dist/types/tools/mcp/mcp_session_manager.d.ts +3 -0
  202. package/dist/types/tools/mcp/mcp_toolset.d.ts +2 -1
  203. package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +25 -0
  204. package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +20 -0
  205. package/dist/types/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.d.ts +20 -0
  206. package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +34 -0
  207. package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +59 -0
  208. package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +23 -0
  209. package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +27 -0
  210. package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +50 -0
  211. package/dist/types/tools/skill/load_skill_resource_tool.d.ts +1 -1
  212. package/dist/types/tools/skill/search_skills_tool.d.ts +14 -0
  213. package/dist/types/tools/skill/skill_toolset.d.ts +5 -0
  214. package/dist/types/tools/vertex_rag_retrieval_tool.d.ts +42 -0
  215. package/dist/types/utils/async_queue.d.ts +18 -0
  216. package/dist/types/utils/case_utils.d.ts +12 -0
  217. package/dist/types/utils/file_utils.d.ts +2 -0
  218. package/dist/types/utils/live_connection_utils.d.ts +30 -0
  219. package/dist/types/utils/model_name.d.ts +7 -0
  220. package/dist/types/utils/partial_copy.d.ts +13 -0
  221. package/dist/types/utils/streaming_utils.d.ts +7 -17
  222. package/dist/types/utils/vertex_ai_utils.d.ts +14 -0
  223. package/dist/types/version.d.ts +1 -1
  224. package/dist/web/agents/base_agent.js +31 -1
  225. package/dist/web/agents/functions.js +4 -0
  226. package/dist/web/agents/instructions.js +81 -33
  227. package/dist/web/agents/invocation_context.js +0 -1
  228. package/dist/web/agents/llm_agent.js +53 -5
  229. package/dist/web/agents/processors/agent_transfer_llm_request_processor.js +7 -0
  230. package/dist/web/agents/processors/basic_llm_request_processor.js +8 -1
  231. package/dist/web/agents/processors/content_processor_utils.js +53 -23
  232. package/dist/web/agents/processors/content_request_processor.js +7 -0
  233. package/dist/web/agents/processors/context_compactor_request_processor.js +12 -0
  234. package/dist/web/agents/processors/identity_llm_request_processor.js +7 -0
  235. package/dist/web/agents/processors/instructions_llm_request_processor.js +5 -0
  236. package/dist/web/agents/processors/request_confirmation_llm_request_processor.js +9 -1
  237. package/dist/web/agents/processors/tool_filter_request_processor.js +7 -1
  238. package/dist/web/auth/auth_preprocessor.js +12 -10
  239. package/dist/web/auth/oauth2/oauth2_discovery.js +26 -2
  240. package/dist/web/code_executors/agent_engine_sandbox_code_executor.js +281 -0
  241. package/dist/web/code_executors/code_execution_utils.js +1 -1
  242. package/dist/web/code_executors/code_executor_context.js +7 -7
  243. package/dist/web/common.js +43 -1
  244. package/dist/web/context/summarizers/llm_summarizer.js +11 -0
  245. package/dist/web/context/token_based_context_compactor.js +1 -1
  246. package/dist/web/events/event.js +4 -2
  247. package/dist/web/index.js +11 -0
  248. package/dist/web/integrations/agent_registry/agent_registry.js +333 -0
  249. package/dist/web/integrations/agent_registry/agent_registry_mcp_toolset.js +109 -0
  250. package/dist/web/integrations/agent_registry/helpers.js +28 -0
  251. package/dist/web/integrations/agent_registry/types.js +20 -0
  252. package/dist/web/memory/vertex_ai_memory_bank_service.js +475 -0
  253. package/dist/web/models/gemini_llm_connection.js +75 -19
  254. package/dist/web/models/google_llm.js +26 -8
  255. package/dist/web/plugins/security_plugin.js +16 -0
  256. package/dist/web/runner/in_memory_runner.js +10 -5
  257. package/dist/web/runner/runner.js +32 -2
  258. package/dist/web/sessions/base_session_service.js +11 -1
  259. package/dist/web/sessions/database_session_service.js +51 -5
  260. package/dist/web/sessions/db/schema.js +44 -10
  261. package/dist/web/sessions/in_memory_session_service.js +74 -16
  262. package/dist/web/sessions/registry.js +7 -0
  263. package/dist/web/sessions/vertex_ai_session_service.js +416 -0
  264. package/dist/web/skills/gcp_skill_registry.js +78 -0
  265. package/dist/web/skills/loader.js +64 -0
  266. package/dist/web/skills/skill_registry.js +7 -0
  267. package/dist/web/tools/agent_tool.js +10 -5
  268. package/dist/web/tools/exit_loop_tool.js +9 -0
  269. package/dist/web/tools/function_tool.js +7 -2
  270. package/dist/web/tools/google_maps_grounding_tool.js +54 -0
  271. package/dist/web/tools/long_running_tool.js +2 -1
  272. package/dist/web/tools/mcp/mcp_session_manager.js +11 -0
  273. package/dist/web/tools/mcp/mcp_tool.js +10 -6
  274. package/dist/web/tools/mcp/mcp_toolset.js +26 -3
  275. package/dist/web/tools/openapi_tool/auth/auth_helpers.js +48 -0
  276. package/dist/web/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +60 -0
  277. package/dist/web/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +111 -0
  278. package/dist/web/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +221 -0
  279. package/dist/web/tools/openapi_tool/openapi_spec_parser/operation_parser.js +198 -0
  280. package/dist/web/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +101 -0
  281. package/dist/web/tools/openapi_tool/openapi_toolset.js +97 -0
  282. package/dist/web/tools/openapi_tool/rest_api_tool.js +229 -0
  283. package/dist/web/tools/skill/load_skill_resource_tool.js +26 -27
  284. package/dist/web/tools/skill/load_skill_tool.js +12 -1
  285. package/dist/web/tools/skill/run_skill_script_tool.js +12 -1
  286. package/dist/web/tools/skill/search_skills_tool.js +82 -0
  287. package/dist/web/tools/skill/skill_toolset.js +40 -5
  288. package/dist/web/tools/vertex_rag_retrieval_tool.js +36 -0
  289. package/dist/web/utils/async_queue.js +60 -0
  290. package/dist/web/utils/case_utils.js +25 -0
  291. package/dist/web/utils/env_aware_utils.js +4 -0
  292. package/dist/web/utils/file_utils.js +26 -0
  293. package/dist/web/utils/gemini_schema_util.js +18 -0
  294. package/dist/web/utils/live_connection_utils.js +254 -0
  295. package/dist/web/utils/model_name.js +8 -0
  296. package/dist/web/utils/partial_copy.js +23 -0
  297. package/dist/web/utils/streaming_utils.js +221 -122
  298. package/dist/web/utils/vertex_ai_utils.js +22 -0
  299. package/dist/web/version.js +1 -1
  300. package/package.json +4 -1
@@ -46,6 +46,13 @@ function isGemini2OrAbove(modelString) {
46
46
  const parsedVersion = parseVersion(versionString);
47
47
  return parsedVersion.valid && parsedVersion.major >= 2;
48
48
  }
49
+ function isGemini3xFlashLive(modelString) {
50
+ if (!modelString) {
51
+ return false;
52
+ }
53
+ const modelName = extractModelName(modelString);
54
+ return modelName.startsWith("gemini-3.") && modelName.includes("-flash-live");
55
+ }
49
56
  function isGeminiModelIdCheckDisabled() {
50
57
  return getBooleanEnvVar("ADK_DISABLE_GEMINI_MODEL_ID_CHECK");
51
58
  }
@@ -53,6 +60,7 @@ export {
53
60
  extractModelName,
54
61
  isGemini1Model,
55
62
  isGemini2OrAbove,
63
+ isGemini3xFlashLive,
56
64
  isGeminiModel,
57
65
  isGeminiModelIdCheckDisabled
58
66
  };
@@ -0,0 +1,23 @@
1
+ import {createRequire as topLevelCreateRequire} from 'module';
2
+ const require = topLevelCreateRequire(import.meta.url);
3
+ /**
4
+ * @license
5
+ * Copyright 2026 Google LLC
6
+ * SPDX-License-Identifier: Apache-2.0
7
+ */
8
+ function partialCopy(source, targetKeys) {
9
+ const result = {};
10
+ const sourceAsUnknown = source;
11
+ targetKeys.forEach((key) => {
12
+ const keyStr = key;
13
+ if (keyStr in source) {
14
+ result[key] = sourceAsUnknown[keyStr];
15
+ } else {
16
+ result[key] = void 0;
17
+ }
18
+ });
19
+ return result;
20
+ }
21
+ export {
22
+ partialCopy
23
+ };
@@ -12,15 +12,9 @@ import { JSONPath } from "jsonpath-plus";
12
12
  import { generateClientFunctionCallId } from "../agents/functions.js";
13
13
  import { FeatureName, isFeatureEnabled } from "../features/feature_registry.js";
14
14
  import { createLlmResponse } from "../models/llm_response.js";
15
- class StreamingResponseAggregator {
16
- constructor(isProgressiveMode = isFeatureEnabled(
17
- FeatureName.PROGRESSIVE_SSE_STREAMING
18
- )) {
19
- this.isProgressiveMode = isProgressiveMode;
20
- // For non-progressive SSE streaming mode
21
- this.text = "";
22
- this.thoughtText = "";
23
- // For progressive SSE streaming mode: accumulate parts in order
15
+ const UNSAFE_PROPERTY_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
16
+ class ProgressiveStrategy {
17
+ constructor() {
24
18
  this.partsSequence = [];
25
19
  this.currentTextBuffer = "";
26
20
  this.currentFcArgs = {};
@@ -85,10 +79,13 @@ class StreamingResponseAggregator {
85
79
  const pathParts = JSONPath.toPathArray(jsonPath).filter(
86
80
  (p) => p !== "$" && p !== "$["
87
81
  );
82
+ if (pathParts.some((part) => UNSAFE_PROPERTY_KEYS.has(String(part)))) {
83
+ return;
84
+ }
88
85
  let current = this.currentFcArgs;
89
86
  for (let i = 0; i < pathParts.length - 1; i++) {
90
87
  const part = pathParts[i];
91
- if (!(part in current)) {
88
+ if (!Object.prototype.hasOwnProperty.call(current, part)) {
92
89
  current[part] = {};
93
90
  }
94
91
  current = current[part];
@@ -147,11 +144,6 @@ class StreamingResponseAggregator {
147
144
  if (!fc) {
148
145
  return;
149
146
  }
150
- if (part.thoughtSignature) {
151
- this.lastThoughtSignature = part.thoughtSignature;
152
- } else if (this.lastThoughtSignature) {
153
- part.thoughtSignature = this.lastThoughtSignature.toString();
154
- }
155
147
  if (fc.partialArgs || fc.willContinue) {
156
148
  if (!fc.id && !this.currentFcId) {
157
149
  fc.id = generateClientFunctionCallId();
@@ -170,63 +162,103 @@ class StreamingResponseAggregator {
170
162
  }
171
163
  }
172
164
  }
173
- async *processResponse(response) {
174
- var _a, _b, _c;
175
- this.response = response;
176
- const llmResponse = createLlmResponse(response);
177
- this.usageMetadata = llmResponse.usageMetadata;
178
- if (llmResponse.groundingMetadata) {
179
- this.groundingMetadata = llmResponse.groundingMetadata;
180
- }
181
- if (llmResponse.citationMetadata) {
182
- this.citationMetadata = llmResponse.citationMetadata;
183
- }
184
- if (llmResponse.finishReason) {
185
- this.finishReason = llmResponse.finishReason;
186
- }
165
+ async *processResponse(llmResponse) {
166
+ var _a;
187
167
  if (llmResponse.content && llmResponse.content.parts) {
188
168
  for (const part of llmResponse.content.parts) {
189
- if (part.thoughtSignature) {
190
- this.lastThoughtSignature = part.thoughtSignature;
191
- } else if (part.functionCall && this.lastThoughtSignature) {
192
- part.thoughtSignature = this.lastThoughtSignature.toString();
169
+ if (part.text) {
170
+ const isThought = (_a = part.thought) != null ? _a : false;
171
+ if (this.currentTextBuffer && isThought !== this.currentTextIsThought) {
172
+ this.flushTextBufferToSequence();
173
+ }
174
+ if (!this.currentTextBuffer) {
175
+ this.currentTextIsThought = isThought;
176
+ }
177
+ this.currentTextBuffer += part.text;
178
+ } else if (part.functionCall) {
179
+ this.processFunctionCallPart(part);
180
+ } else {
181
+ this.flushTextBufferToSequence();
182
+ this.partsSequence.push(part);
193
183
  }
194
184
  }
195
185
  }
196
- if (this.isProgressiveMode) {
197
- if (llmResponse.content && llmResponse.content.parts) {
198
- for (const part of llmResponse.content.parts) {
199
- if (part.text) {
200
- const isThought = (_a = part.thought) != null ? _a : false;
201
- if (this.currentTextBuffer && isThought !== this.currentTextIsThought) {
202
- this.flushTextBufferToSequence();
203
- }
204
- if (!this.currentTextBuffer) {
205
- this.currentTextIsThought = isThought;
206
- }
207
- this.currentTextBuffer += part.text;
208
- } else if (part.functionCall) {
209
- this.processFunctionCallPart(part);
186
+ llmResponse.partial = true;
187
+ yield llmResponse;
188
+ }
189
+ close() {
190
+ this.flushTextBufferToSequence();
191
+ this.flushFunctionCallToSequence();
192
+ const finalParts = this.partsSequence;
193
+ if (finalParts.length === 0) {
194
+ return void 0;
195
+ }
196
+ return finalParts;
197
+ }
198
+ }
199
+ class NonProgressiveStrategy {
200
+ constructor() {
201
+ this.text = "";
202
+ this.thoughtText = "";
203
+ }
204
+ async *processResponse(llmResponse) {
205
+ var _a;
206
+ if ((_a = llmResponse.content) == null ? void 0 : _a.parts) {
207
+ const nonTextParts = [];
208
+ let sawTextPart = false;
209
+ for (const part of llmResponse.content.parts) {
210
+ if (typeof part.text === "string") {
211
+ sawTextPart = true;
212
+ if (part.thought) {
213
+ this.thoughtText += part.text;
210
214
  } else {
211
- this.flushTextBufferToSequence();
212
- this.partsSequence.push(part);
215
+ this.text += part.text;
213
216
  }
217
+ continue;
218
+ }
219
+ if (part.functionCall && !part.functionCall.id) {
220
+ part.functionCall.id = generateClientFunctionCallId();
214
221
  }
222
+ nonTextParts.push(part);
215
223
  }
216
- llmResponse.partial = true;
217
- yield llmResponse;
218
- return;
219
- }
220
- if (llmResponse.content && llmResponse.content.parts && typeof ((_b = llmResponse.content.parts[0]) == null ? void 0 : _b.text) === "string") {
221
- const part0 = llmResponse.content.parts[0];
222
- const partText = part0.text || "";
223
- if (part0.thought) {
224
- this.thoughtText += partText;
225
- } else {
226
- this.text += partText;
224
+ if (nonTextParts.length > 0) {
225
+ if (this.thoughtText || this.text) {
226
+ const parts = [];
227
+ if (this.thoughtText) {
228
+ parts.push({ text: this.thoughtText, thought: true });
229
+ }
230
+ if (this.text) {
231
+ parts.push({ text: this.text });
232
+ }
233
+ yield {
234
+ content: {
235
+ role: "model",
236
+ parts
237
+ },
238
+ usageMetadata: llmResponse.usageMetadata,
239
+ partial: false
240
+ };
241
+ this.thoughtText = "";
242
+ this.text = "";
243
+ }
244
+ yield {
245
+ ...llmResponse,
246
+ content: {
247
+ role: llmResponse.content.role,
248
+ parts: nonTextParts
249
+ },
250
+ partial: false
251
+ };
252
+ return;
253
+ }
254
+ if (sawTextPart) {
255
+ llmResponse.partial = true;
227
256
  }
228
- llmResponse.partial = true;
229
- } else if ((this.thoughtText || this.text) && (!llmResponse.content || !llmResponse.content.parts || !((_c = llmResponse.content.parts[0]) == null ? void 0 : _c.inlineData))) {
257
+ }
258
+ yield llmResponse;
259
+ }
260
+ close() {
261
+ if (this.text || this.thoughtText) {
230
262
  const parts = [];
231
263
  if (this.thoughtText) {
232
264
  parts.push({ text: this.thoughtText, thought: true });
@@ -234,74 +266,88 @@ class StreamingResponseAggregator {
234
266
  if (this.text) {
235
267
  parts.push({ text: this.text });
236
268
  }
237
- yield {
238
- content: {
239
- role: "model",
240
- parts
241
- },
242
- usageMetadata: llmResponse.usageMetadata,
243
- partial: false
244
- };
245
- this.thoughtText = "";
246
- this.text = "";
269
+ return parts;
247
270
  }
248
- yield llmResponse;
271
+ return void 0;
249
272
  }
250
- close() {
273
+ }
274
+ class StreamingResponseAggregator {
275
+ constructor(isProgressiveMode = isFeatureEnabled(
276
+ FeatureName.PROGRESSIVE_SSE_STREAMING
277
+ )) {
278
+ this.isProgressiveMode = isProgressiveMode;
279
+ this.lastThoughtSignature = {};
280
+ this.strategy = this.isProgressiveMode ? new ProgressiveStrategy() : new NonProgressiveStrategy();
281
+ }
282
+ async *processResponse(response) {
251
283
  var _a, _b;
252
- if (!((_a = this.response) == null ? void 0 : _a.candidates) || this.response.candidates.length === 0) {
284
+ const llmResponse = createLlmResponse(response);
285
+ const parts = (_b = (_a = llmResponse.content) == null ? void 0 : _a.parts) != null ? _b : [];
286
+ if (parts.every(isEmptyContentPart) && (llmResponse.finishReason === void 0 || llmResponse.finishReason === FinishReason.STOP)) {
287
+ if (llmResponse.usageMetadata) {
288
+ this.usageMetadata = llmResponse.usageMetadata;
289
+ }
290
+ if (llmResponse.groundingMetadata) {
291
+ this.groundingMetadata = llmResponse.groundingMetadata;
292
+ }
293
+ if (llmResponse.citationMetadata) {
294
+ this.citationMetadata = llmResponse.citationMetadata;
295
+ }
296
+ if (llmResponse.finishReason) {
297
+ this.finishReason = llmResponse.finishReason;
298
+ }
253
299
  return;
254
300
  }
255
- if (this.isProgressiveMode) {
256
- this.flushTextBufferToSequence();
257
- this.flushFunctionCallToSequence();
258
- const finalParts = this.partsSequence;
259
- if (finalParts.length === 0) {
260
- return;
261
- }
262
- const candidate = this.response.candidates[0];
263
- const finishReason = (_b = this.finishReason) != null ? _b : candidate.finishReason;
264
- return {
265
- content: {
266
- role: "model",
267
- parts: finalParts
268
- },
269
- groundingMetadata: this.groundingMetadata,
270
- citationMetadata: this.citationMetadata,
271
- errorCode: finishReason === FinishReason.STOP ? void 0 : finishReason,
272
- errorMessage: finishReason === FinishReason.STOP ? void 0 : candidate.finishMessage,
273
- usageMetadata: this.usageMetadata,
274
- finishReason,
275
- partial: false
276
- };
301
+ this.response = response;
302
+ this.usageMetadata = llmResponse.usageMetadata;
303
+ if (llmResponse.groundingMetadata) {
304
+ this.groundingMetadata = llmResponse.groundingMetadata;
277
305
  }
278
- if ((this.text || this.thoughtText) && this.response.candidates && this.response.candidates.length > 0) {
279
- const parts = [];
280
- if (this.thoughtText) {
281
- parts.push({ text: this.thoughtText, thought: true });
282
- }
283
- if (this.text) {
284
- parts.push({ text: this.text });
306
+ if (llmResponse.citationMetadata) {
307
+ this.citationMetadata = llmResponse.citationMetadata;
308
+ }
309
+ if (llmResponse.finishReason) {
310
+ this.finishReason = llmResponse.finishReason;
311
+ }
312
+ if (llmResponse.content && llmResponse.content.parts) {
313
+ for (const part of llmResponse.content.parts) {
314
+ if (part.thoughtSignature) {
315
+ this.lastThoughtSignature.value = part.thoughtSignature;
316
+ } else if (part.functionCall && this.lastThoughtSignature.value) {
317
+ part.thoughtSignature = this.lastThoughtSignature.value.toString();
318
+ }
285
319
  }
286
- const candidate = this.response.candidates[0];
287
- const finishReason = candidate.finishReason;
288
- return {
289
- content: {
290
- role: "model",
291
- parts
292
- },
293
- groundingMetadata: this.groundingMetadata,
294
- citationMetadata: this.citationMetadata,
295
- errorCode: finishReason === FinishReason.STOP ? void 0 : finishReason,
296
- errorMessage: finishReason === FinishReason.STOP ? void 0 : candidate.finishMessage,
297
- usageMetadata: this.usageMetadata,
298
- finishReason,
299
- partial: false
300
- };
301
320
  }
302
- return void 0;
321
+ yield* this.strategy.processResponse(llmResponse);
322
+ }
323
+ close() {
324
+ var _a, _b, _c;
325
+ const finalParts = this.strategy.close();
326
+ const hasMetadata = this.usageMetadata !== void 0 || this.groundingMetadata !== void 0 || this.citationMetadata !== void 0;
327
+ if (!finalParts && !hasMetadata) {
328
+ return void 0;
329
+ }
330
+ const candidate = (_b = (_a = this.response) == null ? void 0 : _a.candidates) == null ? void 0 : _b[0];
331
+ const finishReason = (_c = this.finishReason) != null ? _c : candidate == null ? void 0 : candidate.finishReason;
332
+ return {
333
+ content: {
334
+ role: "model",
335
+ parts: finalParts != null ? finalParts : []
336
+ },
337
+ groundingMetadata: this.groundingMetadata,
338
+ citationMetadata: this.citationMetadata,
339
+ errorCode: finishReason === FinishReason.STOP ? void 0 : finishReason,
340
+ errorMessage: finishReason === FinishReason.STOP ? void 0 : candidate == null ? void 0 : candidate.finishMessage,
341
+ usageMetadata: this.usageMetadata,
342
+ finishReason,
343
+ partial: false
344
+ };
303
345
  }
304
346
  }
347
+ function isEmptyContentPart(part) {
348
+ return !part.functionCall && !part.functionResponse && !part.fileData && !part.inlineData && !part.executableCode && !part.codeExecutionResult && (!part.text || part.text === "");
349
+ }
305
350
  export {
306
- StreamingResponseAggregator
351
+ StreamingResponseAggregator,
352
+ isEmptyContentPart
307
353
  };
@@ -0,0 +1,22 @@
1
+ import {createRequire as topLevelCreateRequire} from 'module';
2
+ const require = topLevelCreateRequire(import.meta.url);
3
+ /**
4
+ * @license
5
+ * Copyright 2026 Google LLC
6
+ * SPDX-License-Identifier: Apache-2.0
7
+ */
8
+ import { getBooleanEnvVar } from "./env_aware_utils.js";
9
+ function getExpressModeApiKey(project, location, expressModeApiKey) {
10
+ if ((project || location) && expressModeApiKey) {
11
+ throw new Error(
12
+ "Cannot specify project or location and expressModeApiKey. Either use project and location, or just the expressModeApiKey."
13
+ );
14
+ }
15
+ if (getBooleanEnvVar("GOOGLE_GENAI_USE_VERTEXAI")) {
16
+ return expressModeApiKey || process.env.GOOGLE_API_KEY;
17
+ }
18
+ return void 0;
19
+ }
20
+ export {
21
+ getExpressModeApiKey
22
+ };
@@ -5,7 +5,7 @@ const require = topLevelCreateRequire(import.meta.url);
5
5
  * Copyright 2025 Google LLC
6
6
  * SPDX-License-Identifier: Apache-2.0
7
7
  */
8
- const version = "1.1.0";
8
+ const version = "1.3.0";
9
9
  export {
10
10
  version
11
11
  };
@@ -16,11 +16,25 @@ export type A2AStreamEventData = Message | Task | TaskStatusUpdateEvent | TaskAr
16
16
  /**
17
17
  * Callback called before sending a request to the remote agent.
18
18
  * Allows modifying the request parameters.
19
+ *
20
+ * @param ctx - The current invocation context, providing access to session
21
+ * state, agent metadata, and services.
22
+ * @param params - The A2A message send parameters that will be sent to the
23
+ * remote agent. Mutations to this object are reflected in the outgoing
24
+ * request.
25
+ * @returns A Promise or void. Returning a rejected Promise aborts the request.
19
26
  */
20
27
  export type BeforeA2ARequestCallback = (ctx: InvocationContext, params: MessageSendParams) => Promise<void> | void;
21
28
  /**
22
29
  * Callback called after receiving a response from the remote agent.
23
30
  * Allows inspecting or modifying the response.
31
+ *
32
+ * @param ctx - The current invocation context, providing access to session
33
+ * state, agent metadata, and services.
34
+ * @param resp - The raw A2A stream event data received from the remote agent,
35
+ * before conversion to an ADK event.
36
+ * @returns A Promise or void. Returning a rejected Promise stops further
37
+ * processing of the response.
24
38
  */
25
39
  export type AfterA2ARequestCallback = (ctx: InvocationContext, resp: A2AStreamEventData) => Promise<void> | void;
26
40
  /**
@@ -13,26 +13,51 @@ export interface UserFunctionCall {
13
13
  contextId: string;
14
14
  }
15
15
  /**
16
- * Returns a UserFunctionCall when the event at index has a FunctionResponse.
16
+ * Returns a UserFunctionCall when the event at `index` contains a
17
+ * FunctionResponse that can be traced back to a preceding FunctionCall event.
18
+ *
19
+ * @param session - The session whose event history to inspect.
20
+ * @param index - Index of the candidate event to examine.
21
+ * @returns The matching `UserFunctionCall`, or `undefined` if the event at
22
+ * `index` is not a user function-response event or has no preceding call.
17
23
  */
18
24
  export declare function getUserFunctionCallAt(session: Session, index: number): UserFunctionCall | undefined;
19
25
  /**
20
26
  * Checks if an event contains a function call with the given ID.
27
+ *
28
+ * @param event - The event to inspect.
29
+ * @param callId - The function call ID to look for.
30
+ * @returns `true` if a part in the event has a matching `functionCall.id`.
21
31
  */
22
32
  export declare function isFunctionCallEvent(event: AdkEvent, callId: string): boolean;
23
33
  /**
24
34
  * Finds the first part with a FunctionResponse and returns the call ID.
35
+ *
36
+ * @param event - The event to inspect.
37
+ * @returns The `id` of the first FunctionResponse part, or `undefined` if
38
+ * none is found.
25
39
  */
26
40
  export declare function getFunctionResponseCallId(event: AdkEvent): string | undefined;
27
41
  /**
28
- * Returns content parts for all events not present in the remote session
29
- * and a2a contextId if found in a remote agent event metadata.
42
+ * Returns A2A content parts for all events not yet seen by the remote agent,
43
+ * along with the A2A context ID found in the most recent remote agent event.
44
+ *
45
+ * @param ctx - The current invocation context, used to identify the remote
46
+ * agent's authored events.
47
+ * @param session - The local session whose event history to diff.
48
+ * @returns An object with the missing `parts` and an optional `contextId`.
30
49
  */
31
50
  export declare function toMissingRemoteSessionParts(ctx: InvocationContext, session: Session): {
32
51
  parts: A2APart[];
33
52
  contextId?: string;
34
53
  };
35
54
  /**
36
- * Wraps an agent event as a user message for context.
55
+ * Wraps an agent event as a user message so it can be sent as context to a
56
+ * remote agent that only accepts user-role messages.
57
+ *
58
+ * @param ctx - The current invocation context.
59
+ * @param agentEvent - The agent-authored event to reframe as a user message.
60
+ * @returns A new event with `author: 'user'` whose parts summarise the
61
+ * original agent event's text, function calls, and function responses.
37
62
  */
38
63
  export declare function presentAsUserMessage(ctx: InvocationContext, agentEvent: AdkEvent): AdkEvent;
@@ -8,6 +8,12 @@ import { Event as AdkEvent } from '../events/event.js';
8
8
  import { A2AEvent } from './a2a_event.js';
9
9
  /**
10
10
  * Converts a session Event to an A2A Message.
11
+ *
12
+ * @param event - The ADK event to convert.
13
+ * @param appName - The name of the ADK application.
14
+ * @param userId - The ID of the current user.
15
+ * @param sessionId - The ID of the current session.
16
+ * @returns An A2A message with the event's parts and metadata.
11
17
  */
12
18
  export declare function toA2AMessage(event: AdkEvent, { appName, userId, sessionId, }: {
13
19
  appName: string;
@@ -15,6 +21,13 @@ export declare function toA2AMessage(event: AdkEvent, { appName, userId, session
15
21
  sessionId: string;
16
22
  }): Message;
17
23
  /**
18
- * Converts an A2A Event to a Session Event.
24
+ * Converts an A2A Event to an ADK Session Event.
25
+ *
26
+ * @param event - The A2A event to convert (message, task, artifact update, or
27
+ * status update).
28
+ * @param invocationId - The ADK invocation ID to attach to the resulting event.
29
+ * @param agentName - The name of the agent to use as the event author.
30
+ * @returns The converted ADK event, or `undefined` if the A2A event type
31
+ * produces no content.
19
32
  */
20
33
  export declare function toAdkEvent(event: A2AEvent, invocationId: string, agentName: string): AdkEvent | undefined;
@@ -39,10 +39,19 @@ export declare enum AdkMetadataKeys {
39
39
  }
40
40
  /**
41
41
  * Creates ADK Event metadata from an A2A Event.
42
+ *
43
+ * @param a2aEvent - The A2A event to extract metadata from.
44
+ * @returns A record containing the ADK task ID and context ID keys.
42
45
  */
43
46
  export declare function getAdkEventMetadata(a2aEvent: A2AEvent): Record<string, unknown>;
44
47
  /**
45
48
  * Creates A2A Event metadata from an ADK Event.
49
+ *
50
+ * @param adkEvent - The ADK event to extract metadata from.
51
+ * @param appName - The name of the ADK application.
52
+ * @param userId - The ID of the current user.
53
+ * @param sessionId - The ID of the current session.
54
+ * @returns A record of A2A metadata keys populated from the ADK event.
46
55
  */
47
56
  export declare function getA2AEventMetadata(adkEvent: AdkEvent, { appName, userId, sessionId, }: {
48
57
  appName: string;
@@ -51,6 +60,11 @@ export declare function getA2AEventMetadata(adkEvent: AdkEvent, { appName, userI
51
60
  }): Record<string, unknown>;
52
61
  /**
53
62
  * Creates A2A Session metadata from ADK Event invocation metadata.
63
+ *
64
+ * @param appName - The name of the ADK application.
65
+ * @param userId - The ID of the current user.
66
+ * @param sessionId - The ID of the current session.
67
+ * @returns A record of A2A metadata keys for app name, user ID, and session ID.
54
68
  */
55
69
  export declare function getA2ASessionMetadata({ appName, userId, sessionId, }: {
56
70
  appName: string;
@@ -59,5 +73,9 @@ export declare function getA2ASessionMetadata({ appName, userId, sessionId, }: {
59
73
  }): Record<string, unknown>;
60
74
  /**
61
75
  * Creates A2A Event metadata from ADK Event actions.
76
+ *
77
+ * @param actions - The ADK event actions to extract escalation and transfer
78
+ * metadata from.
79
+ * @returns A record with escalate and transfer-to-agent A2A metadata keys.
62
80
  */
63
81
  export declare function getA2AEventMetadataFromActions(actions: AdkEventActions): Record<string, unknown>;
@@ -6,43 +6,88 @@
6
6
  import { DataPart as A2ADataPart, FilePart as A2AFilePart, Part as A2APart, TextPart as A2ATextPart, Message } from '@a2a-js/sdk';
7
7
  import { Content as GenAIContent, Part as GenAIPart } from '@google/genai';
8
8
  /**
9
- * Converts GenAI Parts to A2A Parts.
9
+ * Converts an array of GenAI Parts to A2A Parts.
10
+ *
11
+ * @param parts - The GenAI parts to convert. Defaults to an empty array.
12
+ * @param longRunningToolIDs - IDs of function calls that are long-running.
13
+ * @returns An array of A2A parts.
10
14
  */
11
15
  export declare function toA2AParts(parts?: GenAIPart[], longRunningToolIDs?: string[]): A2APart[];
12
16
  /**
13
- * Converts a GenAI Part to an A2A Part.
17
+ * Converts a single GenAI Part to the appropriate A2A Part type.
18
+ *
19
+ * @param part - The GenAI part to convert.
20
+ * @param longRunningToolIDs - IDs of function calls that are long-running.
21
+ * @returns The corresponding A2A part (text, file, or data).
14
22
  */
15
23
  export declare function toA2APart(part: GenAIPart, longRunningToolIDs?: string[]): A2APart;
16
24
  /**
17
25
  * Converts a GenAI Text Part to an A2A Text Part.
26
+ *
27
+ * @param part - The GenAI part containing a text field.
28
+ * @returns An A2A text part, with thought metadata attached if applicable.
18
29
  */
19
30
  export declare function toA2ATextPart(part: GenAIPart): A2APart;
20
31
  /**
21
32
  * Converts a GenAI File Part to an A2A File Part.
33
+ *
34
+ * @param part - The GenAI part containing `fileData` or `inlineData`.
35
+ * @returns An A2A file part with URI or bytes depending on the source.
36
+ * @throws {Error} If the part contains neither `fileData` nor `inlineData`.
22
37
  */
23
38
  export declare function toA2AFilePart(part: GenAIPart): A2APart;
24
39
  /**
25
- * Converts a GenAI Data Part to an A2A Data Part.
40
+ * Converts a GenAI Data Part (function call/response or code) to an A2A Data Part.
41
+ *
42
+ * @param part - The GenAI part containing structured data.
43
+ * @param longRunningToolIDs - IDs of function calls that are long-running.
44
+ * @returns An A2A data part with the appropriate type metadata.
26
45
  */
27
46
  export declare function toA2ADataPart(part: GenAIPart, longRunningToolIDs?: string[]): A2APart;
47
+ /**
48
+ * Converts an A2A Message to a GenAI Content object.
49
+ *
50
+ * @param a2aMessage - The A2A message to convert.
51
+ * @returns A GenAI user or model content object based on the message role.
52
+ */
28
53
  export declare function toGenAIContent(a2aMessage: Message): GenAIContent;
29
54
  /**
30
- * Converts an A2A Part to a GenAI Part.
55
+ * Converts an array of A2A Parts to GenAI Parts.
56
+ *
57
+ * @param a2aParts - The A2A parts to convert.
58
+ * @returns An array of GenAI parts.
31
59
  */
32
60
  export declare function toGenAIParts(a2aParts: A2APart[]): GenAIPart[];
33
61
  /**
34
- * Converts an A2A Part to a GenAI Part.
62
+ * Converts a single A2A Part to the appropriate GenAI Part type.
63
+ *
64
+ * @param a2aPart - The A2A part to convert.
65
+ * @returns The corresponding GenAI part.
66
+ * @throws {Error} If the A2A part has an unrecognized `kind`.
35
67
  */
36
68
  export declare function toGenAIPart(a2aPart: A2APart): GenAIPart;
37
69
  /**
38
70
  * Converts an A2A Text Part to a GenAI Part.
71
+ *
72
+ * @param a2aPart - The A2A text part to convert.
73
+ * @returns A GenAI part with `text` and optional `thought` flag.
39
74
  */
40
75
  export declare function toGenAIPartText(a2aPart: A2ATextPart): GenAIPart;
41
76
  /**
42
77
  * Converts an A2A File Part to a GenAI Part.
78
+ *
79
+ * @param a2aPart - The A2A file part containing bytes or a URI.
80
+ * @returns A GenAI part with `inlineData` or `fileData` depending on the
81
+ * source, with optional video metadata attached.
82
+ * @throws {Error} If the file part contains neither bytes nor a URI.
43
83
  */
44
84
  export declare function toGenAIPartFile(a2aPart: A2AFilePart): GenAIPart;
45
85
  /**
46
- * Converts an A2A Data Part to a GenAI Part.
86
+ * Converts an A2A Data Part to the appropriate GenAI Part.
87
+ *
88
+ * @param a2aPart - The A2A data part containing structured data and type metadata.
89
+ * @returns A GenAI part with the appropriate function call, function response,
90
+ * or code execution fields, falling back to a JSON text part if the type is
91
+ * unrecognized.
47
92
  */
48
93
  export declare function toGenAIPartData(a2aPart: A2ADataPart): GenAIPart;