@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
@@ -0,0 +1,164 @@
1
+ import {createRequire as topLevelCreateRequire} from 'module';
2
+ const require = topLevelCreateRequire(import.meta.url);
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __decorateClass = (decorators, target, key, kind) => {
7
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
8
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
9
+ if (decorator = decorators[i])
10
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
11
+ if (kind && result) __defProp(target, key, result);
12
+ return result;
13
+ };
14
+ /**
15
+ * @license
16
+ * Copyright 2026 Google LLC
17
+ * SPDX-License-Identifier: Apache-2.0
18
+ */
19
+ var _a, _b;
20
+ import {
21
+ createEvent,
22
+ transformToCamelCaseEvent,
23
+ transformToSnakeCaseEvent
24
+ } from "../events/event.js";
25
+ import { experimental } from "../utils/experimental.js";
26
+ import { BaseAgent } from "./base_agent.js";
27
+ const DEFAULT_REMOTE_AGENT_TIMEOUT_MS = 12e4;
28
+ const MILLIS_PER_SECOND = 1e3;
29
+ const SESSION_PRESERVE_KEYS = /* @__PURE__ */ new Set(["state", "events"]);
30
+ const EVENT_PRESERVE_KEYS = /* @__PURE__ */ new Set([
31
+ "actions.state_delta",
32
+ "actions.artifact_delta",
33
+ "actions.requested_auth_configs",
34
+ "actions.requested_tool_confirmations",
35
+ "actions.custom_metadata",
36
+ "custom_metadata",
37
+ "content.parts.function_call.args",
38
+ "content.parts.function_response.response",
39
+ "output",
40
+ "route",
41
+ "actions.agent_state"
42
+ ]);
43
+ const REMOTE_AGENT_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for("google.adk.remoteAgent");
44
+ function isRemoteAgent(obj) {
45
+ return typeof obj === "object" && obj !== null && REMOTE_AGENT_SIGNATURE_SYMBOL in obj && obj[REMOTE_AGENT_SIGNATURE_SYMBOL] === true;
46
+ }
47
+ __name(isRemoteAgent, "isRemoteAgent");
48
+ function isRecord(value) {
49
+ return typeof value === "object" && value !== null && !Array.isArray(value);
50
+ }
51
+ __name(isRecord, "isRecord");
52
+ function stripNullish(value, preserveKeys, parentKey = "") {
53
+ if (Array.isArray(value)) {
54
+ return value.map((item) => stripNullish(item, preserveKeys, parentKey));
55
+ }
56
+ if (value !== null && typeof value === "object") {
57
+ return stripNullishRecord(value, preserveKeys, parentKey);
58
+ }
59
+ return value;
60
+ }
61
+ __name(stripNullish, "stripNullish");
62
+ function stripNullishRecord(record, preserveKeys, parentKey = "") {
63
+ const result = {};
64
+ for (const [key, entryValue] of Object.entries(record)) {
65
+ if (entryValue === void 0 || entryValue === null) {
66
+ continue;
67
+ }
68
+ const fullPath = parentKey !== "" ? `${parentKey}.${key}` : key;
69
+ result[key] = preserveKeys.has(fullPath) ? entryValue : stripNullish(entryValue, preserveKeys, fullPath);
70
+ }
71
+ return result;
72
+ }
73
+ __name(stripNullishRecord, "stripNullishRecord");
74
+ function serializeEventToSnakeCase(event) {
75
+ const snakeEvent = transformToSnakeCaseEvent(event);
76
+ snakeEvent["timestamp"] = event.timestamp / MILLIS_PER_SECOND;
77
+ return stripNullishRecord(snakeEvent, EVENT_PRESERVE_KEYS);
78
+ }
79
+ __name(serializeEventToSnakeCase, "serializeEventToSnakeCase");
80
+ function serializeSessionToSnakeCase(session) {
81
+ return stripNullishRecord(
82
+ {
83
+ id: session.id,
84
+ app_name: session.appName,
85
+ user_id: session.userId,
86
+ state: session.state,
87
+ events: session.events.map((event) => serializeEventToSnakeCase(event)),
88
+ last_update_time: session.lastUpdateTime / MILLIS_PER_SECOND
89
+ },
90
+ SESSION_PRESERVE_KEYS
91
+ );
92
+ }
93
+ __name(serializeSessionToSnakeCase, "serializeSessionToSnakeCase");
94
+ let RemoteAgent = class extends (_b = BaseAgent, _a = REMOTE_AGENT_SIGNATURE_SYMBOL, _b) {
95
+ constructor(config) {
96
+ var _a2, _b2;
97
+ const runtimeSubAgents = config.subAgents;
98
+ if (Array.isArray(runtimeSubAgents) ? runtimeSubAgents.length > 0 : Boolean(runtimeSubAgents)) {
99
+ throw new Error("subAgents is disabled in RemoteAgent.");
100
+ }
101
+ super({ ...config, subAgents: [] });
102
+ this[_a] = true;
103
+ this.url = config.url;
104
+ this.timeoutMs = (_a2 = config.timeoutMs) != null ? _a2 : DEFAULT_REMOTE_AGENT_TIMEOUT_MS;
105
+ this.fetchImpl = (_b2 = config.fetchImpl) != null ? _b2 : globalThis.fetch;
106
+ }
107
+ async *runAsyncImpl(ctx) {
108
+ var _a2;
109
+ const data = {
110
+ invocation_id: ctx.invocationId,
111
+ session: serializeSessionToSnakeCase(ctx.session)
112
+ };
113
+ const timeoutSignal = AbortSignal.timeout(this.timeoutMs);
114
+ const signal = ctx.abortSignal ? AbortSignal.any([ctx.abortSignal, timeoutSignal]) : timeoutSignal;
115
+ const response = await this.fetchImpl(this.url, {
116
+ method: "POST",
117
+ headers: { "Content-Type": "application/json" },
118
+ body: JSON.stringify(data),
119
+ signal
120
+ });
121
+ if (response.status >= 400) {
122
+ throw new Error(
123
+ `RemoteAgent request to '${this.url}' failed with HTTP status ${response.status}.`
124
+ );
125
+ }
126
+ const rawEvents = await response.json();
127
+ if (!Array.isArray(rawEvents)) {
128
+ throw new Error(
129
+ `RemoteAgent expected a JSON array of events from '${this.url}'.`
130
+ );
131
+ }
132
+ for (const rawEvent of rawEvents) {
133
+ if (!isRecord(rawEvent)) {
134
+ throw new Error(
135
+ `RemoteAgent expected each item in the response from '${this.url}' to be a JSON event object.`
136
+ );
137
+ }
138
+ if ((_a2 = ctx.abortSignal) == null ? void 0 : _a2.aborted) {
139
+ return;
140
+ }
141
+ const camelEvent = transformToCamelCaseEvent(rawEvent);
142
+ const invocationId = camelEvent.invocationId !== void 0 && camelEvent.invocationId !== "" ? camelEvent.invocationId : ctx.invocationId;
143
+ const timestamp = typeof camelEvent.timestamp === "number" ? camelEvent.timestamp * MILLIS_PER_SECOND : void 0;
144
+ yield createEvent({
145
+ ...camelEvent,
146
+ invocationId,
147
+ timestamp,
148
+ author: this.name
149
+ });
150
+ }
151
+ }
152
+ async *runLiveImpl(_ctx) {
153
+ yield* [];
154
+ throw new Error("This is not supported yet for RemoteAgent.");
155
+ }
156
+ };
157
+ __name(RemoteAgent, "RemoteAgent");
158
+ RemoteAgent = __decorateClass([
159
+ experimental
160
+ ], RemoteAgent);
161
+ export {
162
+ RemoteAgent,
163
+ isRemoteAgent
164
+ };
@@ -36,6 +36,13 @@ const _InMemoryArtifactService = class _InMemoryArtifactService {
36
36
  const version = this.artifacts[path].length;
37
37
  const metadata = {
38
38
  version,
39
+ canonicalUri: getCanonicalUri(
40
+ appName,
41
+ userId,
42
+ sessionId,
43
+ filename,
44
+ version
45
+ ),
39
46
  customMetadata
40
47
  };
41
48
  if (!artifact.inlineData && artifact.text === void 0) {
@@ -162,6 +169,13 @@ function artifactPrefix(scope, ...parts) {
162
169
  return `${[scope, ...parts].map(encodeURIComponent).join("/")}/`;
163
170
  }
164
171
  __name(artifactPrefix, "artifactPrefix");
172
+ function getCanonicalUri(appName, userId, sessionId, filename, version) {
173
+ if (fileHasUserNamespace(filename)) {
174
+ return `memory://apps/${appName}/users/${userId}/artifacts/${filename}/versions/${version}`;
175
+ }
176
+ return `memory://apps/${appName}/users/${userId}/sessions/${sessionId}/artifacts/${filename}/versions/${version}`;
177
+ }
178
+ __name(getCanonicalUri, "getCanonicalUri");
165
179
  function fileHasUserNamespace(filename) {
166
180
  return filename.startsWith("user:");
167
181
  }
@@ -7,6 +7,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7
7
  * Copyright 2025 Google LLC
8
8
  * SPDX-License-Identifier: Apache-2.0
9
9
  */
10
+ import { cloneDeep } from "lodash-es";
10
11
  import { randomUUID } from "../utils/env_aware_utils.js";
11
12
  import { OAuth2CredentialExchanger } from "./oauth2/oauth2_credential_exchanger.js";
12
13
  import {
@@ -15,6 +16,11 @@ import {
15
16
  } from "./oauth2/oauth2_utils.js";
16
17
  const S256_CODE_CHALLENGE_METHOD = "S256";
17
18
  const _AuthHandler = class _AuthHandler {
19
+ /**
20
+ * @param authConfig The auth config this handler reads. It stays readable
21
+ * and replaceable after construction; each method reads the current
22
+ * value.
23
+ */
18
24
  constructor(authConfig) {
19
25
  this.authConfig = authConfig;
20
26
  }
@@ -47,14 +53,32 @@ const _AuthHandler = class _AuthHandler {
47
53
  state.set(credentialKey, exchangedCredential.credential);
48
54
  }
49
55
  }
56
+ /**
57
+ * Builds the auth request to send to the client.
58
+ *
59
+ * The result is always a new object, and its `exchangedAuthCredential` is
60
+ * never an object held by {@link authConfig}. A caller that fills in the
61
+ * response, for example `exchangedAuthCredential.oauth2.authResponseUri`,
62
+ * therefore leaves the handler's credentials unchanged.
63
+ *
64
+ * When the config is returned as is, because the scheme is not OAuth2 or
65
+ * OpenID Connect or the exchanged credential already has an auth URI, the
66
+ * result is a deep copy of the whole config. In the other branches only the
67
+ * exchanged credential is guaranteed independent: `authScheme` and
68
+ * `rawAuthCredential` are the handler's own objects.
69
+ *
70
+ * @return The auth config to request from the client.
71
+ * @throws Error: If an OAuth2 or OpenID Connect scheme has no raw
72
+ * credential, no `oauth2` on it, or no client ID and secret.
73
+ */
50
74
  generateAuthRequest() {
51
75
  var _a, _b;
52
76
  const authSchemeType = this.authConfig.authScheme.type;
53
77
  if (!["oauth2", "openIdConnect"].includes(authSchemeType)) {
54
- return this.authConfig;
78
+ return cloneDeep(this.authConfig);
55
79
  }
56
80
  if ((_b = (_a = this.authConfig.exchangedAuthCredential) == null ? void 0 : _a.oauth2) == null ? void 0 : _b.authUri) {
57
- return this.authConfig;
81
+ return cloneDeep(this.authConfig);
58
82
  }
59
83
  if (!this.authConfig.rawAuthCredential) {
60
84
  throw new Error(`Auth Scheme ${authSchemeType} requires authCredential.`);
@@ -69,7 +93,7 @@ const _AuthHandler = class _AuthHandler {
69
93
  credentialKey: this.authConfig.credentialKey,
70
94
  authScheme: this.authConfig.authScheme,
71
95
  rawAuthCredential: this.authConfig.rawAuthCredential,
72
- exchangedAuthCredential: this.authConfig.rawAuthCredential
96
+ exchangedAuthCredential: cloneDeep(this.authConfig.rawAuthCredential)
73
97
  };
74
98
  }
75
99
  if (!this.authConfig.rawAuthCredential.oauth2.clientId || !this.authConfig.rawAuthCredential.oauth2.clientSecret) {
@@ -91,6 +115,10 @@ const _AuthHandler = class _AuthHandler {
91
115
  * challenge derived from the credential's code verifier, and the returned
92
116
  * credential carries the verifier the later token exchange must send.
93
117
  *
118
+ * The URI leaves out `redirect_uri` when the credential has no
119
+ * `redirectUri`, so the provider uses the redirect registered for the
120
+ * client, and leaves out `scope` when the scheme lists no scopes.
121
+ *
94
122
  * @return An AuthCredential object containing the auth URI and state.
95
123
  * @throws Error: If the authorization endpoint is not configured in the
96
124
  * auth scheme, or the credential requests a code challenge method other
@@ -134,9 +162,13 @@ const _AuthHandler = class _AuthHandler {
134
162
  const state = randomUUID();
135
163
  const url = new URL(authorizationEndpoint);
136
164
  url.searchParams.set("client_id", oauth2.clientId || "");
137
- url.searchParams.set("redirect_uri", oauth2.redirectUri || "");
165
+ if (oauth2.redirectUri) {
166
+ url.searchParams.set("redirect_uri", oauth2.redirectUri);
167
+ }
138
168
  url.searchParams.set("response_type", "code");
139
- url.searchParams.set("scope", scopes.join(" "));
169
+ if (scopes.length > 0) {
170
+ url.searchParams.set("scope", scopes.join(" "));
171
+ }
140
172
  url.searchParams.set("state", state);
141
173
  url.searchParams.set("access_type", "offline");
142
174
  url.searchParams.set("prompt", "consent");
@@ -7,6 +7,13 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7
7
  * Copyright 2025 Google LLC
8
8
  * SPDX-License-Identifier: Apache-2.0
9
9
  */
10
+ var AuthSchemeType = /* @__PURE__ */ ((AuthSchemeType2) => {
11
+ AuthSchemeType2["API_KEY"] = "apiKey";
12
+ AuthSchemeType2["HTTP"] = "http";
13
+ AuthSchemeType2["OAUTH2"] = "oauth2";
14
+ AuthSchemeType2["OPEN_ID_CONNECT"] = "openIdConnect";
15
+ return AuthSchemeType2;
16
+ })(AuthSchemeType || {});
10
17
  var OAuthGrantType = /* @__PURE__ */ ((OAuthGrantType2) => {
11
18
  OAuthGrantType2["CLIENT_CREDENTIALS"] = "client_credentials";
12
19
  OAuthGrantType2["AUTHORIZATION_CODE"] = "authorization_code";
@@ -31,6 +38,7 @@ function getOAuthGrantTypeFromFlow(flow) {
31
38
  }
32
39
  __name(getOAuthGrantTypeFromFlow, "getOAuthGrantTypeFromFlow");
33
40
  export {
41
+ AuthSchemeType,
34
42
  OAuthGrantType,
35
43
  getOAuthGrantTypeFromFlow
36
44
  };