@google/adk 2.2.0 → 2.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 (241) hide show
  1. package/dist/cjs/a2a/a2a_remote_agent.js +4 -1
  2. package/dist/cjs/a2a/agent_card.js +102 -26
  3. package/dist/cjs/a2a/agent_to_a2a.js +1 -1
  4. package/dist/cjs/a2a/event_converter_utils.js +5 -1
  5. package/dist/cjs/a2a/metadata_converter_utils.js +2 -1
  6. package/dist/cjs/agents/functions.js +199 -25
  7. package/dist/cjs/agents/instructions.js +4 -1
  8. package/dist/cjs/agents/invocation_context.js +26 -4
  9. package/dist/cjs/agents/langgraph_agent.js +152 -0
  10. package/dist/cjs/agents/llm_agent.js +175 -101
  11. package/dist/cjs/agents/processors/code_execution_request_processor.js +10 -6
  12. package/dist/cjs/agents/remote_agent.js +187 -0
  13. package/dist/cjs/artifacts/in_memory_artifact_service.js +14 -0
  14. package/dist/cjs/auth/auth_handler.js +37 -5
  15. package/dist/cjs/auth/auth_schemes.js +9 -0
  16. package/dist/cjs/cli/cli_eval.js +532 -0
  17. package/dist/cjs/cli/utils/envs.js +116 -0
  18. package/dist/cjs/cli/utils/evals.js +137 -0
  19. package/dist/cjs/cli/utils/logs.js +150 -0
  20. package/dist/cjs/code_executors/agent_engine_sandbox_code_executor.js +7 -2
  21. package/dist/cjs/code_executors/code_execution_utils.js +48 -16
  22. package/dist/cjs/code_executors/code_executor_context.js +6 -2
  23. package/dist/cjs/common.js +90 -0
  24. package/dist/cjs/context/summarizers/llm_summarizer.js +12 -10
  25. package/dist/cjs/context/token_based_context_compactor.js +2 -1
  26. package/dist/cjs/events/abort_events.js +135 -0
  27. package/dist/cjs/events/event.js +4 -2
  28. package/dist/cjs/events/internal_metadata.js +131 -0
  29. package/dist/cjs/examples/example_util.js +23 -2
  30. package/dist/cjs/flows/llm_flows/audio_transcriber.js +170 -0
  31. package/dist/cjs/index.js +97 -1
  32. package/dist/cjs/integrations/agent_registry/helpers.js +1 -1
  33. package/dist/cjs/models/gemini_llm_connection.js +16 -8
  34. package/dist/cjs/models/google_llm.js +13 -16
  35. package/dist/cjs/models/llm_response.js +9 -1
  36. package/dist/cjs/models/registry.js +1 -1
  37. package/dist/cjs/models/routed_llm.js +9 -8
  38. package/dist/cjs/planners/plan_re_act_planner.js +1 -1
  39. package/dist/cjs/plugins/debug_logging_plugin.js +653 -0
  40. package/dist/cjs/plugins/plugin_manager.js +1 -1
  41. package/dist/cjs/plugins/tool_call_integrity_plugin.js +364 -0
  42. package/dist/cjs/runner/in_memory_runner.js +6 -11
  43. package/dist/cjs/runner/runner.js +121 -35
  44. package/dist/cjs/sessions/db/operations.js +1 -1
  45. package/dist/cjs/sessions/in_memory_session_service.js +3 -1
  46. package/dist/cjs/sessions/state.js +8 -4
  47. package/dist/cjs/sessions/vertex_ai_session_service.js +34 -15
  48. package/dist/cjs/telemetry/tracing.js +97 -66
  49. package/dist/cjs/tools/agent_tool.js +44 -0
  50. package/dist/cjs/tools/apihub_tool/apihub_toolset.js +142 -0
  51. package/dist/cjs/tools/apihub_tool/clients/apihub_client.js +272 -0
  52. package/dist/cjs/tools/apihub_tool/clients/secret_client.js +148 -0
  53. package/dist/cjs/tools/apihub_tool/clients/service_account.js +48 -0
  54. package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +185 -0
  55. package/dist/cjs/tools/application_integration_tool/clients/cloud_request.js +133 -0
  56. package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +603 -0
  57. package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +219 -0
  58. package/dist/cjs/tools/crewai_tool.js +132 -0
  59. package/dist/cjs/tools/example_tool.js +10 -0
  60. package/dist/cjs/tools/function_tool.js +319 -0
  61. package/dist/cjs/tools/google_api_tool/google_api_tool.js +97 -0
  62. package/dist/cjs/tools/google_api_tool/google_api_tool_set.js +226 -0
  63. package/dist/cjs/tools/google_api_tool/google_api_tool_sets.js +58 -0
  64. package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +440 -0
  65. package/dist/cjs/tools/google_api_tool/index.js +64 -0
  66. package/dist/cjs/tools/langchain_tool.js +172 -0
  67. package/dist/cjs/tools/mcp/index.js +12 -0
  68. package/dist/cjs/tools/mcp/mcp_session_manager.js +25 -0
  69. package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +1 -2
  70. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +46 -2
  71. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -1
  72. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
  73. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +14 -2
  74. package/dist/cjs/tools/retrieval/base_retrieval_tool.js +18 -3
  75. package/dist/cjs/tools/toolbox_tool.js +108 -0
  76. package/dist/cjs/utils/env_aware_utils.js +6 -8
  77. package/dist/cjs/utils/error_utils.js +11 -11
  78. package/dist/cjs/utils/file_extension_utils.js +11 -0
  79. package/dist/cjs/utils/file_utils.js +2 -24
  80. package/dist/cjs/utils/gemini_schema_util.js +4 -1
  81. package/dist/cjs/utils/json_utils.js +49 -0
  82. package/dist/cjs/utils/live_connection_utils.js +4 -5
  83. package/dist/cjs/utils/logger_node.js +7 -1
  84. package/dist/cjs/utils/object_notation_utils.js +6 -3
  85. package/dist/cjs/utils/streaming_utils.js +12 -12
  86. package/dist/cjs/version.js +1 -1
  87. package/dist/esm/a2a/a2a_remote_agent.js +4 -1
  88. package/dist/esm/a2a/agent_card.js +103 -27
  89. package/dist/esm/a2a/agent_to_a2a.js +5 -2
  90. package/dist/esm/a2a/event_converter_utils.js +5 -1
  91. package/dist/esm/a2a/metadata_converter_utils.js +2 -1
  92. package/dist/esm/agents/functions.js +198 -25
  93. package/dist/esm/agents/instructions.js +4 -1
  94. package/dist/esm/agents/invocation_context.js +24 -4
  95. package/dist/esm/agents/langgraph_agent.js +123 -0
  96. package/dist/esm/agents/llm_agent.js +185 -104
  97. package/dist/esm/agents/processors/code_execution_request_processor.js +13 -8
  98. package/dist/esm/agents/remote_agent.js +164 -0
  99. package/dist/esm/artifacts/in_memory_artifact_service.js +14 -0
  100. package/dist/esm/auth/auth_handler.js +37 -5
  101. package/dist/esm/auth/auth_schemes.js +8 -0
  102. package/dist/esm/cli/cli_eval.js +510 -0
  103. package/dist/esm/cli/utils/envs.js +78 -0
  104. package/dist/esm/cli/utils/evals.js +109 -0
  105. package/dist/esm/cli/utils/logs.js +111 -0
  106. package/dist/esm/code_executors/agent_engine_sandbox_code_executor.js +7 -2
  107. package/dist/esm/code_executors/code_execution_utils.js +46 -16
  108. package/dist/esm/code_executors/code_executor_context.js +5 -2
  109. package/dist/esm/common.js +87 -3
  110. package/dist/esm/context/summarizers/llm_summarizer.js +12 -10
  111. package/dist/esm/context/token_based_context_compactor.js +2 -1
  112. package/dist/esm/events/abort_events.js +110 -0
  113. package/dist/esm/events/event.js +4 -2
  114. package/dist/esm/events/internal_metadata.js +97 -0
  115. package/dist/esm/examples/example_util.js +21 -1
  116. package/dist/esm/flows/llm_flows/audio_transcriber.js +142 -0
  117. package/dist/esm/index.js +99 -1
  118. package/dist/esm/integrations/agent_registry/helpers.js +1 -1
  119. package/dist/esm/models/gemini_llm_connection.js +16 -8
  120. package/dist/esm/models/google_llm.js +14 -17
  121. package/dist/esm/models/llm_response.js +9 -1
  122. package/dist/esm/models/registry.js +1 -1
  123. package/dist/esm/models/routed_llm.js +9 -8
  124. package/dist/esm/planners/plan_re_act_planner.js +1 -1
  125. package/dist/esm/plugins/debug_logging_plugin.js +615 -0
  126. package/dist/esm/plugins/plugin_manager.js +1 -1
  127. package/dist/esm/plugins/tool_call_integrity_plugin.js +339 -0
  128. package/dist/esm/runner/in_memory_runner.js +6 -11
  129. package/dist/esm/runner/runner.js +124 -35
  130. package/dist/esm/sessions/db/operations.js +1 -1
  131. package/dist/esm/sessions/in_memory_session_service.js +3 -1
  132. package/dist/esm/sessions/state.js +8 -4
  133. package/dist/esm/sessions/vertex_ai_session_service.js +34 -15
  134. package/dist/esm/telemetry/tracing.js +97 -66
  135. package/dist/esm/tools/agent_tool.js +44 -0
  136. package/dist/esm/tools/apihub_tool/apihub_toolset.js +106 -0
  137. package/dist/esm/tools/apihub_tool/clients/apihub_client.js +244 -0
  138. package/dist/esm/tools/apihub_tool/clients/secret_client.js +132 -0
  139. package/dist/esm/tools/apihub_tool/clients/service_account.js +21 -0
  140. package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +163 -0
  141. package/dist/esm/tools/application_integration_tool/clients/cloud_request.js +103 -0
  142. package/dist/esm/tools/application_integration_tool/clients/connections_client.js +561 -0
  143. package/dist/esm/tools/application_integration_tool/clients/integration_client.js +215 -0
  144. package/dist/esm/tools/crewai_tool.js +107 -0
  145. package/dist/esm/tools/example_tool.js +13 -1
  146. package/dist/esm/tools/function_tool.js +316 -0
  147. package/dist/esm/tools/google_api_tool/google_api_tool.js +70 -0
  148. package/dist/esm/tools/google_api_tool/google_api_tool_set.js +188 -0
  149. package/dist/esm/tools/google_api_tool/google_api_tool_sets.js +24 -0
  150. package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +393 -0
  151. package/dist/esm/tools/google_api_tool/index.js +33 -0
  152. package/dist/esm/tools/langchain_tool.js +148 -0
  153. package/dist/esm/tools/mcp/index.js +6 -0
  154. package/dist/esm/tools/mcp/mcp_session_manager.js +25 -0
  155. package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +1 -2
  156. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +50 -3
  157. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -1
  158. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
  159. package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +15 -2
  160. package/dist/esm/tools/retrieval/base_retrieval_tool.js +16 -2
  161. package/dist/esm/tools/toolbox_tool.js +80 -0
  162. package/dist/esm/utils/env_aware_utils.js +6 -8
  163. package/dist/esm/utils/error_utils.js +9 -10
  164. package/dist/esm/utils/file_extension_utils.js +11 -0
  165. package/dist/esm/utils/file_utils.js +2 -23
  166. package/dist/esm/utils/gemini_schema_util.js +4 -1
  167. package/dist/esm/utils/json_utils.js +21 -0
  168. package/dist/esm/utils/live_connection_utils.js +4 -5
  169. package/dist/esm/utils/logger_node.js +7 -1
  170. package/dist/esm/utils/object_notation_utils.js +4 -2
  171. package/dist/esm/utils/streaming_utils.js +11 -11
  172. package/dist/esm/version.js +1 -1
  173. package/dist/types/a2a/a2a_remote_agent.d.ts +9 -0
  174. package/dist/types/a2a/agent_card.d.ts +44 -1
  175. package/dist/types/a2a/agent_to_a2a.d.ts +9 -0
  176. package/dist/types/a2a/index.d.ts +1 -0
  177. package/dist/types/agents/functions.d.ts +33 -1
  178. package/dist/types/agents/invocation_context.d.ts +20 -1
  179. package/dist/types/agents/langgraph_agent.d.ts +153 -0
  180. package/dist/types/agents/remote_agent.d.ts +68 -0
  181. package/dist/types/auth/auth_handler.d.ts +28 -1
  182. package/dist/types/auth/auth_schemes.d.ts +13 -0
  183. package/dist/types/cli/cli_eval.d.ts +173 -0
  184. package/dist/types/cli/utils/envs.d.ts +23 -0
  185. package/dist/types/cli/utils/evals.d.ts +47 -0
  186. package/dist/types/cli/utils/logs.d.ts +38 -0
  187. package/dist/types/code_executors/code_execution_utils.d.ts +39 -0
  188. package/dist/types/code_executors/code_executor_context.d.ts +1 -0
  189. package/dist/types/common.d.ts +30 -4
  190. package/dist/types/events/abort_events.d.ts +43 -0
  191. package/dist/types/events/event.d.ts +4 -0
  192. package/dist/types/events/internal_metadata.d.ts +78 -0
  193. package/dist/types/examples/example_util.d.ts +17 -0
  194. package/dist/types/flows/llm_flows/audio_transcriber.d.ts +85 -0
  195. package/dist/types/index.d.ts +16 -1
  196. package/dist/types/models/gemini_llm_connection.d.ts +6 -7
  197. package/dist/types/models/routed_llm.d.ts +1 -1
  198. package/dist/types/plugins/debug_logging_plugin.d.ts +157 -0
  199. package/dist/types/plugins/tool_call_integrity_plugin.d.ts +116 -0
  200. package/dist/types/runner/in_memory_runner.d.ts +2 -1
  201. package/dist/types/runner/runner.d.ts +34 -0
  202. package/dist/types/sessions/state.d.ts +5 -1
  203. package/dist/types/sessions/vertex_ai_session_service.d.ts +8 -0
  204. package/dist/types/skills/skill.d.ts +1 -1
  205. package/dist/types/telemetry/tracing.d.ts +4 -2
  206. package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +122 -0
  207. package/dist/types/tools/apihub_tool/clients/apihub_client.d.ts +142 -0
  208. package/dist/types/tools/apihub_tool/clients/secret_client.d.ts +55 -0
  209. package/dist/types/tools/apihub_tool/clients/service_account.d.ts +11 -0
  210. package/dist/types/tools/application_integration_tool/application_integration_toolset.d.ts +86 -0
  211. package/dist/types/tools/application_integration_tool/clients/cloud_request.d.ts +53 -0
  212. package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +215 -0
  213. package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +72 -0
  214. package/dist/types/tools/crewai_tool.d.ts +85 -0
  215. package/dist/types/tools/example_tool.d.ts +10 -0
  216. package/dist/types/tools/function_tool.d.ts +32 -0
  217. package/dist/types/tools/google_api_tool/google_api_tool.d.ts +30 -0
  218. package/dist/types/tools/google_api_tool/google_api_tool_set.d.ts +78 -0
  219. package/dist/types/tools/google_api_tool/google_api_tool_sets.d.ts +33 -0
  220. package/dist/types/tools/google_api_tool/googleapi_to_openapi_converter.d.ts +164 -0
  221. package/dist/types/tools/google_api_tool/index.d.ts +11 -0
  222. package/dist/types/tools/langchain_tool.d.ts +103 -0
  223. package/dist/types/tools/mcp/index.d.ts +3 -0
  224. package/dist/types/tools/mcp/mcp_session_manager.d.ts +34 -1
  225. package/dist/types/tools/mcp/mcp_toolset.d.ts +15 -0
  226. package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +19 -0
  227. package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +18 -1
  228. package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +2 -1
  229. package/dist/types/tools/retrieval/base_retrieval_tool.d.ts +15 -0
  230. package/dist/types/tools/toolbox_tool.d.ts +73 -0
  231. package/dist/types/utils/env_aware_utils.d.ts +18 -2
  232. package/dist/types/utils/error_utils.d.ts +7 -0
  233. package/dist/types/utils/file_utils.d.ts +6 -1
  234. package/dist/types/utils/gemini_schema_util.d.ts +1 -2
  235. package/dist/types/utils/json_utils.d.ts +11 -0
  236. package/dist/types/utils/object_notation_utils.d.ts +7 -0
  237. package/dist/types/utils/streaming_utils.d.ts +11 -4
  238. package/dist/types/version.d.ts +1 -1
  239. package/dist/web/index_web.js +105 -106
  240. package/dist/web/index_web.js.map +4 -4
  241. package/package.json +8 -3
@@ -206,7 +206,7 @@ const _NonProgressiveStrategy = class _NonProgressiveStrategy {
206
206
  this.thoughtText = "";
207
207
  }
208
208
  async *processResponse(llmResponse) {
209
- var _a;
209
+ var _a, _b;
210
210
  if ((_a = llmResponse.content) == null ? void 0 : _a.parts) {
211
211
  const nonTextParts = [];
212
212
  let sawTextPart = false;
@@ -226,7 +226,8 @@ const _NonProgressiveStrategy = class _NonProgressiveStrategy {
226
226
  nonTextParts.push(part);
227
227
  }
228
228
  if (nonTextParts.length > 0) {
229
- if (this.thoughtText || this.text) {
229
+ const startsWithInlineData = !!((_b = llmResponse.content.parts[0]) == null ? void 0 : _b.inlineData);
230
+ if (!startsWithInlineData && (this.thoughtText || this.text)) {
230
231
  const parts = [];
231
232
  if (this.thoughtText) {
232
233
  parts.push({ text: this.thoughtText, thought: true });
@@ -277,13 +278,12 @@ const _NonProgressiveStrategy = class _NonProgressiveStrategy {
277
278
  };
278
279
  __name(_NonProgressiveStrategy, "NonProgressiveStrategy");
279
280
  let NonProgressiveStrategy = _NonProgressiveStrategy;
280
- const _StreamingResponseAggregator = class _StreamingResponseAggregator {
281
- constructor(isProgressiveMode = isFeatureEnabled(
282
- FeatureName.PROGRESSIVE_SSE_STREAMING
283
- )) {
284
- this.isProgressiveMode = isProgressiveMode;
281
+ const _GeminiStreamingResponseAggregator = class _GeminiStreamingResponseAggregator {
282
+ constructor({
283
+ isProgressiveMode = isFeatureEnabled(FeatureName.PROGRESSIVE_SSE_STREAMING)
284
+ } = {}) {
285
285
  this.lastThoughtSignature = {};
286
- this.strategy = this.isProgressiveMode ? new ProgressiveStrategy() : new NonProgressiveStrategy();
286
+ this.strategy = isProgressiveMode ? new ProgressiveStrategy() : new NonProgressiveStrategy();
287
287
  }
288
288
  async *processResponse(response) {
289
289
  var _a, _b;
@@ -356,13 +356,13 @@ const _StreamingResponseAggregator = class _StreamingResponseAggregator {
356
356
  };
357
357
  }
358
358
  };
359
- __name(_StreamingResponseAggregator, "StreamingResponseAggregator");
360
- let StreamingResponseAggregator = _StreamingResponseAggregator;
359
+ __name(_GeminiStreamingResponseAggregator, "GeminiStreamingResponseAggregator");
360
+ let GeminiStreamingResponseAggregator = _GeminiStreamingResponseAggregator;
361
361
  function isEmptyContentPart(part) {
362
362
  return !part.functionCall && !part.functionResponse && !part.fileData && !part.inlineData && !part.executableCode && !part.codeExecutionResult && (!part.text || part.text === "");
363
363
  }
364
364
  __name(isEmptyContentPart, "isEmptyContentPart");
365
365
  export {
366
- StreamingResponseAggregator,
366
+ GeminiStreamingResponseAggregator,
367
367
  isEmptyContentPart
368
368
  };
@@ -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 = "2.2.0";
8
+ const version = "2.3.0";
9
9
  export {
10
10
  version
11
11
  };
@@ -8,6 +8,7 @@ import { Client, ClientFactory } from '@a2a-js/sdk/client';
8
8
  import { BaseAgent, BaseAgentConfig } from '../agents/base_agent.js';
9
9
  import { InvocationContext } from '../agents/invocation_context.js';
10
10
  import { Event as AdkEvent } from '../events/event.js';
11
+ import { ResolveAgentCardOptions } from './agent_card.js';
11
12
  export { AGENT_CARD_PATH };
12
13
  /**
13
14
  * Type alias for A2A stream event data.
@@ -45,6 +46,14 @@ export interface RemoteA2AAgentConfig extends BaseAgentConfig {
45
46
  * Loaded AgentCard or URL to AgentCard.
46
47
  */
47
48
  agentCard?: AgentCard | string;
49
+ /**
50
+ * Controls how a fetched agent card's RPC URL(s) are validated against
51
+ * the location the card was fetched from. Only relevant when
52
+ * {@link RemoteA2AAgentConfig.agentCard} is a URL rather than an
53
+ * already-loaded card object; see {@link ResolveAgentCardOptions} for
54
+ * what each option relaxes and why both default to failing closed.
55
+ */
56
+ resolveAgentCardOptions?: ResolveAgentCardOptions;
48
57
  /**
49
58
  * Optional pre-initialized Client for connection pooling.
50
59
  */
@@ -5,6 +5,49 @@
5
5
  */
6
6
  import { AgentCard, AgentInterface, AgentSkill } from '@a2a-js/sdk';
7
7
  import { RunnableRoot } from '../workflow/run_node_as_invocation.js';
8
+ /**
9
+ * Options controlling how a fetched agent card's RPC URL(s) are validated
10
+ * against the location the card was fetched from. See `validateCardRpcTargets`
11
+ * for what each check defends against and why
12
+ * both default to failing closed.
13
+ */
14
+ export interface ResolveAgentCardOptions {
15
+ /**
16
+ * Explicit escape hatch to accept a plaintext http:// RPC URL on a
17
+ * non-loopback host.
18
+ *
19
+ * This is intentionally insecure: an RPC URL that isn't https and isn't
20
+ * on this machine can be intercepted or altered by anything on the
21
+ * network path, even when its origin matches the card's own. Only set
22
+ * this for a card source you know serves plain http on a host you
23
+ * trust (e.g. a private, internal service reached over a channel
24
+ * that's secured some other way). When set to `true`, a loud warning is
25
+ * logged for each RPC URL this affects.
26
+ *
27
+ * Defaults to `false`: RPC URLs must be https, or http on a loopback
28
+ * host (localhost, 127.0.0.0/8, ::1, 0.0.0.0, or ::).
29
+ */
30
+ allowInsecureRpc?: boolean;
31
+ /**
32
+ * Explicit escape hatch to accept an RPC URL whose origin differs from
33
+ * the location the card was fetched from.
34
+ *
35
+ * This is intentionally permissive: it is what lets a compromised or
36
+ * misconfigured card-hosting endpoint redirect all subsequent A2A
37
+ * traffic for this agent, including whatever credential material the
38
+ * request-forwarding path carries, to a different origin than the one
39
+ * that was actually configured and fetched. The A2A spec allows a card
40
+ * to point RPC at a different origin than where the card itself is
41
+ * served from (e.g. static card hosting separate from the API
42
+ * backend), which is the legitimate case this exists for -- only set
43
+ * this when that's a shape you actually expect. When set to `true`, a
44
+ * loud warning is logged for each RPC URL this affects.
45
+ *
46
+ * Defaults to `false`: every RPC URL must share the origin the card
47
+ * was fetched from.
48
+ */
49
+ allowCrossOriginRpc?: boolean;
50
+ }
8
51
  /**
9
52
  * Resolves the AgentCard from the provided source.
10
53
  *
@@ -17,7 +60,7 @@ import { RunnableRoot } from '../workflow/run_node_as_invocation.js';
17
60
  * private addresses stay allowed: they are where a locally served or
18
61
  * VPC-internal peer agent lives.
19
62
  */
20
- export declare function resolveAgentCard(agentCard: AgentCard | string): Promise<AgentCard>;
63
+ export declare function resolveAgentCard(agentCard: AgentCard | string, options?: ResolveAgentCardOptions): Promise<AgentCard>;
21
64
  /**
22
65
  * Converts an ADK agent to an A2A AgentCard.
23
66
  */
@@ -11,6 +11,7 @@ import { BaseMemoryService } from '../memory/base_memory_service.js';
11
11
  import { Runner } from '../runner/runner.js';
12
12
  import { BaseSessionService } from '../sessions/base_session_service.js';
13
13
  import { RunnableRoot } from '../workflow/run_node_as_invocation.js';
14
+ import { ResolveAgentCardOptions } from './agent_card.js';
14
15
  import { AdkDefaultRequestHandler, getA2aRequestMetadata } from './request_metadata.js';
15
16
  export { AdkDefaultRequestHandler, getA2aRequestMetadata };
16
17
  /**
@@ -39,6 +40,14 @@ export interface ToA2aOptions {
39
40
  basePath?: string;
40
41
  /** Optional pre-built AgentCard object or path to agent card JSON */
41
42
  agentCard?: AgentCard | string;
43
+ /**
44
+ * Controls how a fetched agent card's RPC URL(s) are validated against
45
+ * the location the card was fetched from. Only relevant when
46
+ * {@link ToA2aOptions.agentCard} is a URL rather than an already-loaded
47
+ * card object or file path; see {@link ResolveAgentCardOptions} for
48
+ * what each option relaxes and why both default to failing closed.
49
+ */
50
+ resolveAgentCardOptions?: ResolveAgentCardOptions;
42
51
  /** Optional pre-built Runner object */
43
52
  runner?: Runner;
44
53
  /** Optional session service */
@@ -10,6 +10,7 @@
10
10
  export { AGENT_CARD_PATH, RemoteA2AAgent } from './a2a_remote_agent.js';
11
11
  export type { A2AStreamEventData, AfterA2ARequestCallback, BeforeA2ARequestCallback, RemoteA2AAgentConfig, } from './a2a_remote_agent.js';
12
12
  export { getA2AAgentCard } from './agent_card.js';
13
+ export type { ResolveAgentCardOptions } from './agent_card.js';
13
14
  export { A2AAgentExecutor } from './agent_executor.js';
14
15
  export type { AfterEventCallback, AfterExecuteCallback, AgentExecutorConfig, BeforeExecuteCallback, RunnerOrRunnerConfig, } from './agent_executor.js';
15
16
  export { AdkDefaultRequestHandler, getA2aRequestMetadata, toA2a, } from './agent_to_a2a.js';
@@ -9,11 +9,14 @@ import { Event } from '../events/event.js';
9
9
  import { BaseTool } from '../tools/base_tool.js';
10
10
  import { ResumeInputs } from '../tools/resume_inputs.js';
11
11
  import { ToolConfirmation } from '../tools/tool_confirmation.js';
12
+ import { Context } from './context.js';
12
13
  import { SingleAfterToolCallback, SingleBeforeToolCallback } from './llm_agent.js';
13
14
  export { AF_FUNCTION_CALL_ID_PREFIX, generateClientFunctionCallId, populateClientFunctionCallId, } from '../events/event.js';
14
15
  export { REQUEST_CONFIRMATION_FUNCTION_CALL_NAME, REQUEST_CREDENTIAL_FUNCTION_CALL_NAME, REQUEST_INPUT_FUNCTION_CALL_NAME, reservedFunctionCallName, } from './framework_function_calls.js';
15
16
  export declare const functionsExportedForTestingOnly: {
16
17
  handleFunctionCallList: typeof handleFunctionCallList;
18
+ handleFunctionCallsLive: typeof handleFunctionCallsLive;
19
+ processFunctionLiveHelper: typeof processFunctionLiveHelper;
17
20
  generateAuthEvent: typeof generateAuthEvent;
18
21
  generateRequestConfirmationEvent: typeof generateRequestConfirmationEvent;
19
22
  };
@@ -63,6 +66,23 @@ export declare function handleFunctionCallsAsync({ invocationContext, functionCa
63
66
  toolConfirmationDict?: Record<string, ToolConfirmation>;
64
67
  resumeInputsDict?: Record<string, ResumeInputs>;
65
68
  }): Promise<Event | null>;
69
+ /**
70
+ * Handles function calls in a live (bidirectional streaming) session.
71
+ *
72
+ * Supports regular sync/async tools, async-generator streaming tools that push
73
+ * incremental results onto `invocationContext.liveRequestQueue`, and the
74
+ * `stop_streaming` control call that cancels an active streaming tool task.
75
+ */
76
+ export declare function handleFunctionCallsLive({ invocationContext, functionCallEvent, toolsDict, beforeToolCallbacks, afterToolCallbacks, filters, toolConfirmationDict, resumeInputsDict, }: {
77
+ invocationContext: InvocationContext;
78
+ functionCallEvent: Event;
79
+ toolsDict: Record<string, BaseTool>;
80
+ beforeToolCallbacks: SingleBeforeToolCallback[];
81
+ afterToolCallbacks: SingleAfterToolCallback[];
82
+ filters?: Set<string>;
83
+ toolConfirmationDict?: Record<string, ToolConfirmation>;
84
+ resumeInputsDict?: Record<string, ResumeInputs>;
85
+ }): Promise<Event | null>;
66
86
  /**
67
87
  * Whether `tool` is the placeholder handed to the on-tool-error callbacks for a
68
88
  * function call naming a tool this agent cannot call.
@@ -76,7 +96,7 @@ export declare function isToolNotFound(tool: unknown): boolean;
76
96
  * function calls instead of an event.
77
97
  * This is also used by llm_agent execution flow in preprocessing.
78
98
  */
79
- export declare function handleFunctionCallList({ invocationContext, functionCalls, toolsDict, beforeToolCallbacks, afterToolCallbacks, filters, toolConfirmationDict, resumeInputsDict, }: {
99
+ export declare function handleFunctionCallList({ invocationContext, functionCalls, toolsDict, beforeToolCallbacks, afterToolCallbacks, filters, toolConfirmationDict, resumeInputsDict, isLive, }: {
80
100
  invocationContext: InvocationContext;
81
101
  functionCalls: FunctionCall[];
82
102
  toolsDict: Record<string, BaseTool>;
@@ -91,11 +111,23 @@ export declare function handleFunctionCallList({ invocationContext, functionCall
91
111
  * approval; see {@link ResumeInputs}.
92
112
  */
93
113
  resumeInputsDict?: Record<string, ResumeInputs>;
114
+ isLive?: boolean;
94
115
  }): Promise<Event | null>;
95
116
  /**
96
117
  * Merges a list of function response events into a single event.
97
118
  */
98
119
  export declare function mergeParallelFunctionResponseEvents(functionResponseEvents: Event[]): Event;
120
+ /**
121
+ * Executes a single tool call in live mode, supporting `stop_streaming`,
122
+ * async-generator streaming tools, and standard sync/async tools.
123
+ */
124
+ declare function processFunctionLiveHelper({ tool, toolContext, functionCall, functionArgs, invocationContext, }: {
125
+ tool: BaseTool;
126
+ toolContext: Context;
127
+ functionCall: FunctionCall;
128
+ functionArgs: Record<string, unknown>;
129
+ invocationContext: InvocationContext;
130
+ }): Promise<unknown>;
99
131
  /**
100
132
  * Finds the most recent event before `endIndex` that contains a function call
101
133
  * with the given ID.
@@ -59,6 +59,24 @@ export interface InvocationContextParams {
59
59
  */
60
60
  a2aMetadata?: Record<string, unknown>;
61
61
  }
62
+ /**
63
+ * A unique symbol to identify {@link LlmCallsLimitExceededError} instances.
64
+ */
65
+ declare const LLM_CALLS_LIMIT_EXCEEDED_ERROR_SIGNATURE_SYMBOL: unique symbol;
66
+ /**
67
+ * Error thrown when the number of LLM calls in an invocation exceeds {@link RunConfig.maxLlmCalls}.
68
+ */
69
+ export declare class LlmCallsLimitExceededError extends Error {
70
+ readonly [LLM_CALLS_LIMIT_EXCEEDED_ERROR_SIGNATURE_SYMBOL] = true;
71
+ constructor(message: string);
72
+ }
73
+ /**
74
+ * Type guard to check if an object is an instance of {@link LlmCallsLimitExceededError}.
75
+ *
76
+ * @param obj The object to check.
77
+ * @returns True if the object is an instance of {@link LlmCallsLimitExceededError}.
78
+ */
79
+ export declare function isLlmCallsLimitExceededError(obj: unknown): obj is LlmCallsLimitExceededError;
62
80
  /**
63
81
  * An invocation context represents the data of a single invocation of an agent.
64
82
  *
@@ -198,7 +216,7 @@ export declare class InvocationContext {
198
216
  * The live request queue feeding the model on the bidirectional (live) path.
199
217
  * Set only for invocations started via `runner.runLive`.
200
218
  */
201
- readonly liveRequestQueue?: LiveRequestQueue;
219
+ liveRequestQueue?: LiveRequestQueue;
202
220
  /**
203
221
  * The most recent session resumption handle observed on the live path.
204
222
  * Updated as the server emits resumption updates so a reconnect can restore
@@ -255,3 +273,4 @@ export declare function newInvocationContextId(): string;
255
273
  * @throws if the invocation is driving a bare node rather than an agent.
256
274
  */
257
275
  export declare function requireAgent(ctx: InvocationContext): BaseAgent;
276
+ export {};
@@ -0,0 +1,153 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Event } from '../events/event.js';
7
+ import { BaseAgent, BaseAgentConfig } from './base_agent.js';
8
+ import { InvocationContext } from './invocation_context.js';
9
+ /**
10
+ * Text or structured content part inside a LangGraph message content array.
11
+ */
12
+ export interface LangGraphContentPart {
13
+ readonly type?: string;
14
+ readonly text?: string;
15
+ }
16
+ /**
17
+ * Content carried by a LangGraph message (`string` or an array of content parts).
18
+ */
19
+ export type LangGraphMessageContent = string | ReadonlyArray<string | LangGraphContentPart>;
20
+ /**
21
+ * Structural representation of a message exchanged with a LangGraph graph.
22
+ */
23
+ export interface LangGraphMessageLike {
24
+ /**
25
+ * Text or structured content of the message.
26
+ */
27
+ readonly content: LangGraphMessageContent;
28
+ /**
29
+ * Optional role or message type identifier (`'human'`, `'ai'`, or `'system'`).
30
+ */
31
+ readonly type?: string;
32
+ }
33
+ /**
34
+ * Represents a human user message passed to a LangGraph graph.
35
+ */
36
+ export interface LangGraphHumanMessage extends LangGraphMessageLike {
37
+ readonly type: 'human';
38
+ readonly content: string;
39
+ }
40
+ /**
41
+ * Represents an AI assistant message passed to or returned by a LangGraph graph.
42
+ */
43
+ export interface LangGraphAIMessage extends LangGraphMessageLike {
44
+ readonly type: 'ai';
45
+ readonly content: LangGraphMessageContent;
46
+ }
47
+ /**
48
+ * Represents a system instruction message passed to a LangGraph graph.
49
+ */
50
+ export interface LangGraphSystemMessage extends LangGraphMessageLike {
51
+ readonly type: 'system';
52
+ readonly content: string;
53
+ }
54
+ /**
55
+ * Runnable configuration passed to a compiled LangGraph graph invocation.
56
+ */
57
+ export interface LangGraphRunnableConfig {
58
+ readonly configurable: {
59
+ /**
60
+ * Thread identifier expected in `snake_case` by LangGraph.js checkpointers.
61
+ */
62
+ readonly thread_id: string;
63
+ };
64
+ }
65
+ /**
66
+ * State snapshot returned by a compiled LangGraph graph's `getState` method.
67
+ */
68
+ export interface LangGraphStateSnapshot {
69
+ readonly values?: {
70
+ readonly messages?: readonly LangGraphMessageLike[];
71
+ };
72
+ }
73
+ /**
74
+ * Input state passed to a compiled LangGraph graph's `invoke` method.
75
+ */
76
+ export interface LangGraphInvokeInput {
77
+ readonly messages: readonly LangGraphMessageLike[];
78
+ }
79
+ /**
80
+ * Output state returned by a compiled LangGraph graph's `invoke` method.
81
+ */
82
+ export interface LangGraphInvokeOutput {
83
+ readonly messages?: readonly LangGraphMessageLike[];
84
+ }
85
+ /**
86
+ * Structural interface for a compiled LangGraph graph.
87
+ */
88
+ export interface CompiledGraphLike {
89
+ /**
90
+ * Optional checkpointer configured on the compiled graph for multi-turn state persistence.
91
+ */
92
+ readonly checkpointer?: unknown;
93
+ /**
94
+ * Optional helper returning the underlying graph representation.
95
+ */
96
+ getGraph?(...args: unknown[]): unknown;
97
+ /**
98
+ * Retrieves the current graph state for the given runnable configuration.
99
+ */
100
+ getState?(config: LangGraphRunnableConfig): LangGraphStateSnapshot | undefined | Promise<LangGraphStateSnapshot | undefined>;
101
+ /**
102
+ * Invokes the compiled graph with the given message list and runnable configuration.
103
+ */
104
+ invoke(input: LangGraphInvokeInput, config: LangGraphRunnableConfig): LangGraphInvokeOutput | Promise<LangGraphInvokeOutput>;
105
+ }
106
+ /**
107
+ * Configuration options for {@link LangGraphAgent}.
108
+ */
109
+ export interface LangGraphAgentConfig extends BaseAgentConfig {
110
+ /**
111
+ * The compiled LangGraph graph to execute.
112
+ */
113
+ graph: CompiledGraphLike;
114
+ /**
115
+ * Optional system instruction prepended when the graph state has no existing messages.
116
+ */
117
+ instruction?: string;
118
+ }
119
+ /**
120
+ * Extracts the trailing contiguous sequence of human user messages from `events`.
121
+ *
122
+ * @param events The session events to inspect.
123
+ * @returns The trailing user messages in chronological order.
124
+ */
125
+ export declare function getLastHumanMessages(events: readonly Event[]): LangGraphHumanMessage[];
126
+ declare const LANGGRAPH_AGENT_SIGNATURE_SYMBOL: unique symbol;
127
+ /**
128
+ * Type guard to check if an object is an instance of {@link LangGraphAgent}.
129
+ *
130
+ * @param obj The object to check.
131
+ * @returns True if the object is an instance of {@link LangGraphAgent}.
132
+ */
133
+ export declare function isLangGraphAgent(obj: unknown): obj is LangGraphAgent;
134
+ /**
135
+ * An agent that wraps a compiled LangGraph graph for single-turn and multi-turn execution.
136
+ */
137
+ export declare class LangGraphAgent extends BaseAgent<LangGraphAgentConfig> {
138
+ readonly [LANGGRAPH_AGENT_SIGNATURE_SYMBOL] = true;
139
+ /**
140
+ * The compiled LangGraph graph executed by this agent.
141
+ */
142
+ readonly graph: CompiledGraphLike;
143
+ /**
144
+ * System instruction prepended when the graph state contains no prior messages.
145
+ */
146
+ readonly instruction: string;
147
+ constructor(config: LangGraphAgentConfig);
148
+ protected runAsyncImpl(ctx: InvocationContext): AsyncGenerator<Event, void, void>;
149
+ protected runLiveImpl(_ctx: InvocationContext): AsyncGenerator<Event, void, void>;
150
+ private getMessages;
151
+ private getConversationWithAgent;
152
+ }
153
+ export {};
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Event } from '../events/event.js';
7
+ import { BaseAgent, BaseAgentConfig } from './base_agent.js';
8
+ import { InvocationContext } from './invocation_context.js';
9
+ /**
10
+ * Custom `fetch` function signature accepted by {@link RemoteAgentConfig.fetchImpl}.
11
+ */
12
+ export type RemoteAgentFetch = typeof fetch;
13
+ /**
14
+ * Configuration options for {@link RemoteAgent}.
15
+ */
16
+ export interface RemoteAgentConfig extends BaseAgentConfig {
17
+ /**
18
+ * Remote HTTP endpoint URL that accepts an invocation payload and returns a JSON array of events.
19
+ */
20
+ url: string;
21
+ /**
22
+ * Request timeout in milliseconds; defaults to `120_000` (120 seconds).
23
+ */
24
+ timeoutMs?: number;
25
+ /**
26
+ * Optional custom `fetch` implementation used for HTTP requests.
27
+ */
28
+ fetchImpl?: RemoteAgentFetch;
29
+ /**
30
+ * Sub-agents are disabled on {@link RemoteAgent}.
31
+ */
32
+ subAgents?: never;
33
+ }
34
+ declare const REMOTE_AGENT_SIGNATURE_SYMBOL: unique symbol;
35
+ /**
36
+ * Type guard to check if an object is an instance of {@link RemoteAgent}.
37
+ *
38
+ * @param obj The object to check.
39
+ * @returns True if the object is an instance of {@link RemoteAgent}.
40
+ */
41
+ export declare function isRemoteAgent(obj: unknown): obj is RemoteAgent;
42
+ /**
43
+ * Experimental agent that forwards invocation context and session state to a
44
+ * remote HTTP endpoint.
45
+ *
46
+ * Trust assumption: returned event payloads (including `id`, `timestamp`, and
47
+ * `actions` such as `stateDelta`, `artifactDelta`, `transferToAgent`, and
48
+ * `escalate`) are deserialized via `transformToCamelCaseEvent` and passed
49
+ * to {@link createEvent} without schema or authorization filtering; only
50
+ * `author` is overwritten with this agent's `name`. Configure `url` only with a
51
+ * trusted remote endpoint.
52
+ */
53
+ export declare class RemoteAgent extends BaseAgent<RemoteAgentConfig> {
54
+ readonly [REMOTE_AGENT_SIGNATURE_SYMBOL] = true;
55
+ /**
56
+ * Remote HTTP endpoint URL.
57
+ */
58
+ readonly url: string;
59
+ /**
60
+ * Request timeout in milliseconds.
61
+ */
62
+ readonly timeoutMs: number;
63
+ private readonly fetchImpl;
64
+ constructor(config: RemoteAgentConfig);
65
+ protected runAsyncImpl(ctx: InvocationContext): AsyncGenerator<Event, void, void>;
66
+ protected runLiveImpl(_ctx: InvocationContext): AsyncGenerator<Event, void, void>;
67
+ }
68
+ export {};
@@ -12,7 +12,12 @@ import { AuthConfig } from './auth_tool.js';
12
12
  * This class should only be used by Agent Development Kit.
13
13
  */
14
14
  export declare class AuthHandler {
15
- private readonly authConfig;
15
+ authConfig: AuthConfig;
16
+ /**
17
+ * @param authConfig The auth config this handler reads. It stays readable
18
+ * and replaceable after construction; each method reads the current
19
+ * value.
20
+ */
16
21
  constructor(authConfig: AuthConfig);
17
22
  getAuthResponse(state: State): AuthCredential | undefined;
18
23
  /**
@@ -22,6 +27,24 @@ export declare class AuthHandler {
22
27
  * @throws Error: If the auth config has no credentialKey.
23
28
  */
24
29
  parseAndStoreAuthResponse(state: State): Promise<void>;
30
+ /**
31
+ * Builds the auth request to send to the client.
32
+ *
33
+ * The result is always a new object, and its `exchangedAuthCredential` is
34
+ * never an object held by {@link authConfig}. A caller that fills in the
35
+ * response, for example `exchangedAuthCredential.oauth2.authResponseUri`,
36
+ * therefore leaves the handler's credentials unchanged.
37
+ *
38
+ * When the config is returned as is, because the scheme is not OAuth2 or
39
+ * OpenID Connect or the exchanged credential already has an auth URI, the
40
+ * result is a deep copy of the whole config. In the other branches only the
41
+ * exchanged credential is guaranteed independent: `authScheme` and
42
+ * `rawAuthCredential` are the handler's own objects.
43
+ *
44
+ * @return The auth config to request from the client.
45
+ * @throws Error: If an OAuth2 or OpenID Connect scheme has no raw
46
+ * credential, no `oauth2` on it, or no client ID and secret.
47
+ */
25
48
  generateAuthRequest(): AuthConfig;
26
49
  /**
27
50
  * Generates an response containing the auth uri for user to sign in.
@@ -30,6 +53,10 @@ export declare class AuthHandler {
30
53
  * challenge derived from the credential's code verifier, and the returned
31
54
  * credential carries the verifier the later token exchange must send.
32
55
  *
56
+ * The URI leaves out `redirect_uri` when the credential has no
57
+ * `redirectUri`, so the provider uses the redirect registered for the
58
+ * client, and leaves out `scope` when the scheme lists no scopes.
59
+ *
33
60
  * @return An AuthCredential object containing the auth URI and state.
34
61
  * @throws Error: If the authorization endpoint is not configured in the
35
62
  * auth scheme, or the credential requests a code challenge method other
@@ -23,6 +23,19 @@ export interface OpenIdConnectWithConfig extends OpenAPIV3.OpenIdSecurityScheme
23
23
  * OpenIdConnectWithConfig.
24
24
  */
25
25
  export type AuthScheme = OpenAPIV3.SecuritySchemeObject | OpenIdConnectWithConfig;
26
+ /**
27
+ * The OpenAPI security scheme types an {@link AuthScheme} can declare.
28
+ *
29
+ * The values are the exact strings of the OpenAPI `type` field, so a member
30
+ * compares equal to `authScheme.type` and can be enumerated at runtime with
31
+ * `Object.values(AuthSchemeType)`.
32
+ */
33
+ export declare enum AuthSchemeType {
34
+ API_KEY = "apiKey",
35
+ HTTP = "http",
36
+ OAUTH2 = "oauth2",
37
+ OPEN_ID_CONNECT = "openIdConnect"
38
+ }
26
39
  /**
27
40
  * Represents the OAuth2 flow (or grant type).
28
41
  */