@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,152 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ "use strict";
8
+ var __defProp = Object.defineProperty;
9
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
+ var __getOwnPropNames = Object.getOwnPropertyNames;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
13
+ var __export = (target, all) => {
14
+ for (var name in all)
15
+ __defProp(target, name, { get: all[name], enumerable: true });
16
+ };
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") {
19
+ for (let key of __getOwnPropNames(from))
20
+ if (!__hasOwnProp.call(to, key) && key !== except)
21
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
+ }
23
+ return to;
24
+ };
25
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
26
+ var langgraph_agent_exports = {};
27
+ __export(langgraph_agent_exports, {
28
+ LangGraphAgent: () => LangGraphAgent,
29
+ getLastHumanMessages: () => getLastHumanMessages,
30
+ isLangGraphAgent: () => isLangGraphAgent
31
+ });
32
+ module.exports = __toCommonJS(langgraph_agent_exports);
33
+ var import_event = require("../events/event.js");
34
+ var import_base_agent = require("./base_agent.js");
35
+ /**
36
+ * @license
37
+ * Copyright 2026 Google LLC
38
+ * SPDX-License-Identifier: Apache-2.0
39
+ */
40
+ var _a, _b;
41
+ function getLastHumanMessages(events) {
42
+ var _a2, _b2, _c;
43
+ const messages = [];
44
+ for (let i = events.length - 1; i >= 0; i--) {
45
+ const event = events[i];
46
+ if (messages.length > 0 && event.author !== "user") {
47
+ break;
48
+ }
49
+ const text = (_c = (_b2 = (_a2 = event.content) == null ? void 0 : _a2.parts) == null ? void 0 : _b2[0]) == null ? void 0 : _c.text;
50
+ if (event.author === "user" && text !== void 0) {
51
+ messages.push({ type: "human", content: text });
52
+ }
53
+ }
54
+ return messages.reverse();
55
+ }
56
+ __name(getLastHumanMessages, "getLastHumanMessages");
57
+ function extractMessageText(content) {
58
+ if (typeof content === "string") {
59
+ return content;
60
+ }
61
+ return content.map((part) => {
62
+ var _a2;
63
+ return typeof part === "string" ? part : (_a2 = part.text) != null ? _a2 : "";
64
+ }).join("");
65
+ }
66
+ __name(extractMessageText, "extractMessageText");
67
+ const LANGGRAPH_AGENT_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for(
68
+ "google.adk.langGraphAgent"
69
+ );
70
+ function isLangGraphAgent(obj) {
71
+ return typeof obj === "object" && obj !== null && LANGGRAPH_AGENT_SIGNATURE_SYMBOL in obj && obj[LANGGRAPH_AGENT_SIGNATURE_SYMBOL] === true;
72
+ }
73
+ __name(isLangGraphAgent, "isLangGraphAgent");
74
+ const _LangGraphAgent = class _LangGraphAgent extends (_b = import_base_agent.BaseAgent, _a = LANGGRAPH_AGENT_SIGNATURE_SYMBOL, _b) {
75
+ constructor(config) {
76
+ var _a2;
77
+ super(config);
78
+ this[_a] = true;
79
+ this.graph = config.graph;
80
+ this.instruction = (_a2 = config.instruction) != null ? _a2 : "";
81
+ }
82
+ async *runAsyncImpl(ctx) {
83
+ var _a2, _b2, _c;
84
+ const config = {
85
+ // LangGraph.js checkpointers read `configurable.thread_id`.
86
+ configurable: { thread_id: ctx.session.id }
87
+ };
88
+ let currentGraphState;
89
+ if (this.graph.checkpointer) {
90
+ if (typeof this.graph.getState !== "function") {
91
+ throw new Error(
92
+ `LangGraphAgent '${this.name}' requires graph.getState() when graph.checkpointer is configured.`
93
+ );
94
+ }
95
+ currentGraphState = await this.graph.getState(config);
96
+ }
97
+ const graphMessages = (_b2 = (_a2 = currentGraphState == null ? void 0 : currentGraphState.values) == null ? void 0 : _a2.messages) != null ? _b2 : [];
98
+ const messages = this.instruction && graphMessages.length === 0 ? [{ type: "system", content: this.instruction }] : [];
99
+ messages.push(...this.getMessages(ctx.session.events));
100
+ const finalState = await this.graph.invoke({ messages }, config);
101
+ const finalMessages = (_c = finalState.messages) != null ? _c : [];
102
+ const lastMessage = finalMessages[finalMessages.length - 1];
103
+ if (!lastMessage) {
104
+ throw new Error(
105
+ `LangGraphAgent '${this.name}' received no messages from graph.invoke().`
106
+ );
107
+ }
108
+ yield (0, import_event.createEvent)({
109
+ invocationId: ctx.invocationId,
110
+ author: this.name,
111
+ branch: ctx.branch,
112
+ content: {
113
+ role: "model",
114
+ parts: [{ text: extractMessageText(lastMessage.content) }]
115
+ }
116
+ });
117
+ }
118
+ async *runLiveImpl(_ctx) {
119
+ yield* [];
120
+ throw new Error("This is not supported yet for LangGraphAgent.");
121
+ }
122
+ getMessages(events) {
123
+ if (this.graph.checkpointer) {
124
+ return getLastHumanMessages(events);
125
+ }
126
+ return this.getConversationWithAgent(events);
127
+ }
128
+ getConversationWithAgent(events) {
129
+ var _a2, _b2, _c;
130
+ const messages = [];
131
+ for (const event of events) {
132
+ const text = (_c = (_b2 = (_a2 = event.content) == null ? void 0 : _a2.parts) == null ? void 0 : _b2[0]) == null ? void 0 : _c.text;
133
+ if (text === void 0) {
134
+ continue;
135
+ }
136
+ if (event.author === "user") {
137
+ messages.push({ type: "human", content: text });
138
+ } else if (event.author === this.name) {
139
+ messages.push({ type: "ai", content: text });
140
+ }
141
+ }
142
+ return messages;
143
+ }
144
+ };
145
+ __name(_LangGraphAgent, "LangGraphAgent");
146
+ let LangGraphAgent = _LangGraphAgent;
147
+ // Annotate the CommonJS export names for ESM import in node:
148
+ 0 && (module.exports = {
149
+ LangGraphAgent,
150
+ getLastHumanMessages,
151
+ isLangGraphAgent
152
+ });
@@ -29,6 +29,7 @@ __export(llm_agent_exports, {
29
29
  isLlmAgent: () => isLlmAgent
30
30
  });
31
31
  module.exports = __toCommonJS(llm_agent_exports);
32
+ var import_genai = require("@google/genai");
32
33
  var import_api = require("@opentelemetry/api");
33
34
  var import_finish_task_tool = require("../tools/finish_task_tool.js");
34
35
  var import_function_tool = require("../tools/function_tool.js");
@@ -52,6 +53,7 @@ var import_base_agent = require("./base_agent.js");
52
53
  var import_functions = require("./functions.js");
53
54
  var import_auth_preprocessor = require("../auth/auth_preprocessor.js");
54
55
  var import_invocation_context = require("./invocation_context.js");
56
+ var import_live_request_queue = require("./live_request_queue.js");
55
57
  var import_agent_transfer_llm_request_processor = require("./processors/agent_transfer_llm_request_processor.js");
56
58
  var import_basic_llm_request_processor = require("./processors/basic_llm_request_processor.js");
57
59
  var import_code_execution_request_processor = require("./processors/code_execution_request_processor.js");
@@ -120,6 +122,9 @@ function applyLiveRunConfig(runConfig, llmRequest) {
120
122
  liveConfig[k] = runConfig[k];
121
123
  }
122
124
  }
125
+ if (runConfig.supportCfc) {
126
+ liveConfig.responseModalities = [import_genai.Modality.TEXT];
127
+ }
123
128
  }
124
129
  __name(applyLiveRunConfig, "applyLiveRunConfig");
125
130
  const ADK_AGENT_NAME_LABEL_KEY = "adk_agent_name";
@@ -202,7 +207,9 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
202
207
  }
203
208
  }
204
209
  this.responseProcessors = (_j = config.responseProcessors) != null ? _j : [
205
- import_nl_planning_processor.NL_PLANNING_RESPONSE_PROCESSOR
210
+ import_nl_planning_processor.NL_PLANNING_RESPONSE_PROCESSOR,
211
+ // Runs the code blocks that a client-side code executor receives.
212
+ import_code_execution_request_processor.responseProcessor
206
213
  ];
207
214
  const agentTransferDisabled = this.disallowTransferToParent && this.disallowTransferToPeers && !((_k = this.subAgents) == null ? void 0 : _k.length);
208
215
  if (!agentTransferDisabled) {
@@ -465,14 +472,18 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
465
472
  while (true) {
466
473
  let lastEvent = void 0;
467
474
  let stepHadToolCalls = false;
475
+ let stepTransferred = false;
468
476
  for await (const event of this.runOneStepAsync(context2)) {
469
477
  if ((_a2 = context2.abortSignal) == null ? void 0 : _a2.aborted) {
470
478
  return;
471
479
  }
472
480
  lastEvent = event;
473
- if ((0, import_event.getFunctionCalls)(event).length > 0 || (0, import_event.getFunctionResponses)(event).length > 0) {
481
+ if ((0, import_event.getFunctionCalls)(event).length > 0 || (0, import_event.getFunctionResponses)(event).length > 0 || !event.partial && (0, import_event.hasTrailingCodeExecutionResult)(event)) {
474
482
  stepHadToolCalls = true;
475
483
  }
484
+ if (event.author === this.name && event.actions.transferToAgent) {
485
+ stepTransferred = true;
486
+ }
476
487
  this.maybeSaveOutputToState(event);
477
488
  yield event;
478
489
  }
@@ -480,7 +491,7 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
480
491
  break;
481
492
  }
482
493
  const isEmptyMetadataEvent = lastEvent.author === this.name && !lastEvent.partial && (!((_b2 = lastEvent.content) == null ? void 0 : _b2.parts) || lastEvent.content.parts.length === 0) && (0, import_event_actions.isDefaultEventActions)(lastEvent.actions);
483
- if ((0, import_event.isFinalResponse)(lastEvent) && !(isEmptyMetadataEvent && stepHadToolCalls)) {
494
+ if ((0, import_event.isFinalResponse)(lastEvent) && !(isEmptyMetadataEvent && stepHadToolCalls && !stepTransferred)) {
484
495
  break;
485
496
  }
486
497
  if (lastEvent.partial) {
@@ -520,7 +531,7 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
520
531
  * already holds the conversation state associated with the handle.
521
532
  */
522
533
  async *runLiveFlow(invocationContext) {
523
- var _a2, _b2, _c, _d;
534
+ var _a2, _b2, _c, _d, _e;
524
535
  if (!invocationContext.liveRequestQueue) {
525
536
  throw new Error("liveRequestQueue is required for LlmAgent.runLiveFlow.");
526
537
  }
@@ -575,16 +586,29 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
575
586
  throw err;
576
587
  }
577
588
  if (llmRequest.contents.length > 0 && !invocationContext.liveSessionResumptionHandle) {
578
- await connection.sendHistory(llmRequest.contents);
589
+ await import_tracing.tracer.startActiveSpan("send_data", async (span) => {
590
+ try {
591
+ await connection.sendHistory(llmRequest.contents);
592
+ (0, import_tracing.traceSendData)({
593
+ invocationContext,
594
+ eventId: (0, import_event.createNewEventId)(),
595
+ data: llmRequest.contents
596
+ });
597
+ } finally {
598
+ span.end();
599
+ }
600
+ });
579
601
  }
580
602
  let sendError;
581
603
  const sendAbort = new AbortController();
582
604
  const combinedAbort = invocationContext.abortSignal ? AbortSignal.any([invocationContext.abortSignal, sendAbort.signal]) : sendAbort.signal;
605
+ (_d = invocationContext.activeStreamingTools) != null ? _d : invocationContext.activeStreamingTools = {};
583
606
  const sendTask = this.runSendLoop(
584
607
  connection,
585
608
  invocationContext.liveRequestQueue,
586
609
  combinedAbort,
587
- invocationContext.abortSignal
610
+ invocationContext.abortSignal,
611
+ invocationContext.activeStreamingTools
588
612
  );
589
613
  sendTask.catch((error) => {
590
614
  import_logger.logger.error("Error in live send loop:", error);
@@ -616,7 +640,7 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
616
640
  }
617
641
  }
618
642
  await this.teardownLiveConnection(sendAbort, connection, sendTask);
619
- if ((_d = invocationContext.abortSignal) == null ? void 0 : _d.aborted) {
643
+ if ((_e = invocationContext.abortSignal) == null ? void 0 : _e.aborted) {
620
644
  return;
621
645
  }
622
646
  if (sendError) {
@@ -662,7 +686,7 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
662
686
  }
663
687
  }
664
688
  }
665
- async runSendLoop(connection, liveRequestQueue, sendAbortSignal, invocationAbortSignal) {
689
+ async runSendLoop(connection, liveRequestQueue, sendAbortSignal, invocationAbortSignal, activeStreamingTools) {
666
690
  while (true) {
667
691
  if ((sendAbortSignal == null ? void 0 : sendAbortSignal.aborted) || (invocationAbortSignal == null ? void 0 : invocationAbortSignal.aborted)) {
668
692
  return;
@@ -676,6 +700,13 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
676
700
  }
677
701
  throw error;
678
702
  }
703
+ if (activeStreamingTools) {
704
+ for (const activeStreamingTool of Object.values(activeStreamingTools)) {
705
+ if (activeStreamingTool.stream) {
706
+ activeStreamingTool.stream.send(liveRequest);
707
+ }
708
+ }
709
+ }
679
710
  try {
680
711
  await this.dispatchLiveRequest(connection, liveRequest);
681
712
  } catch (error) {
@@ -730,67 +761,74 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
730
761
  }
731
762
  async *runReceiveLoop(invocationContext, connection, llmRequest, sendAbort) {
732
763
  var _a2, _b2, _c, _d;
733
- for await (const llmResponse of connection.receive()) {
734
- if ((_a2 = invocationContext.abortSignal) == null ? void 0 : _a2.aborted) {
735
- return;
736
- }
737
- if (sendAbort.signal.aborted) {
738
- return;
739
- }
740
- if ((_b2 = llmResponse.liveSessionResumptionUpdate) == null ? void 0 : _b2.newHandle) {
741
- invocationContext.liveSessionResumptionHandle = llmResponse.liveSessionResumptionUpdate.newHandle;
742
- }
743
- if (llmResponse.goAway) {
744
- import_logger.logger.info("Received goAway from live server; triggering reconnect.");
745
- throw new LiveReconnectSignal("goAway");
746
- }
747
- const author = llmResponse.inputTranscription || ((_c = llmResponse.content) == null ? void 0 : _c.role) === "user" ? "user" : this.name;
748
- const modelResponseEvent = (0, import_event.createEvent)({
749
- invocationId: invocationContext.invocationId,
750
- author,
751
- branch: invocationContext.branch
752
- });
753
- for await (const event of this.postprocessLive(
754
- invocationContext,
755
- llmRequest,
756
- llmResponse,
757
- modelResponseEvent
758
- )) {
759
- yield event;
760
- if (event.content && (0, import_event.getFunctionResponses)(event).length > 0) {
761
- await connection.sendContent(event.content);
764
+ let receivedAny = true;
765
+ while (receivedAny) {
766
+ receivedAny = false;
767
+ for await (const llmResponse of connection.receive()) {
768
+ receivedAny = true;
769
+ if ((_a2 = invocationContext.abortSignal) == null ? void 0 : _a2.aborted) {
770
+ return;
762
771
  }
763
- const taskCompleted = (0, import_event.getFunctionResponses)(event).some(
764
- (r) => r.name === "task_completed"
765
- );
766
- if (taskCompleted) {
767
- await sleep(TRANSFER_AGENT_DELAY_MS);
772
+ if (sendAbort.signal.aborted) {
768
773
  return;
769
774
  }
770
- const transferTo = (_d = event.actions) == null ? void 0 : _d.transferToAgent;
771
- if (transferTo) {
772
- await sleep(TRANSFER_AGENT_DELAY_MS);
773
- sendAbort.abort();
774
- await connection.close();
775
- const agent = (0, import_invocation_context.requireAgent)(invocationContext);
776
- const subAgent = agent.rootAgent.findAgent(transferTo);
777
- if (subAgent) {
778
- const previousAgent = invocationContext.agent;
779
- invocationContext.agent = subAgent;
780
- const previousHandle = invocationContext.liveSessionResumptionHandle;
781
- invocationContext.liveSessionResumptionHandle = void 0;
782
- try {
783
- for await (const subEvent of subAgent.runLive(
784
- invocationContext
785
- )) {
786
- yield subEvent;
775
+ if ((_b2 = llmResponse.liveSessionResumptionUpdate) == null ? void 0 : _b2.newHandle) {
776
+ invocationContext.liveSessionResumptionHandle = llmResponse.liveSessionResumptionUpdate.newHandle;
777
+ }
778
+ if (llmResponse.goAway) {
779
+ import_logger.logger.info(
780
+ "Received goAway from live server; triggering reconnect."
781
+ );
782
+ throw new LiveReconnectSignal("goAway");
783
+ }
784
+ const author = llmResponse.inputTranscription || ((_c = llmResponse.content) == null ? void 0 : _c.role) === "user" ? "user" : this.name;
785
+ const modelResponseEvent = (0, import_event.createEvent)({
786
+ invocationId: invocationContext.invocationId,
787
+ author,
788
+ branch: invocationContext.branch
789
+ });
790
+ for await (const event of this.postprocessLive(
791
+ invocationContext,
792
+ llmRequest,
793
+ llmResponse,
794
+ modelResponseEvent
795
+ )) {
796
+ yield event;
797
+ if (event.content && (0, import_event.getFunctionResponses)(event).length > 0) {
798
+ await connection.sendContent(event.content);
799
+ }
800
+ const taskCompleted = (0, import_event.getFunctionResponses)(event).some(
801
+ (r) => r.name === "task_completed"
802
+ );
803
+ if (taskCompleted) {
804
+ await sleep(TRANSFER_AGENT_DELAY_MS);
805
+ return;
806
+ }
807
+ const transferTo = (_d = event.actions) == null ? void 0 : _d.transferToAgent;
808
+ if (transferTo) {
809
+ await sleep(TRANSFER_AGENT_DELAY_MS);
810
+ sendAbort.abort();
811
+ await connection.close();
812
+ const agent = (0, import_invocation_context.requireAgent)(invocationContext);
813
+ const subAgent = agent.rootAgent.findAgent(transferTo);
814
+ if (subAgent) {
815
+ const previousAgent = invocationContext.agent;
816
+ invocationContext.agent = subAgent;
817
+ const previousHandle = invocationContext.liveSessionResumptionHandle;
818
+ invocationContext.liveSessionResumptionHandle = void 0;
819
+ try {
820
+ for await (const subEvent of subAgent.runLive(
821
+ invocationContext
822
+ )) {
823
+ yield subEvent;
824
+ }
825
+ } finally {
826
+ invocationContext.agent = previousAgent;
827
+ invocationContext.liveSessionResumptionHandle = previousHandle;
787
828
  }
788
- } finally {
789
- invocationContext.agent = previousAgent;
790
- invocationContext.liveSessionResumptionHandle = previousHandle;
791
829
  }
830
+ return;
792
831
  }
793
- return;
794
832
  }
795
833
  }
796
834
  }
@@ -845,7 +883,7 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
845
883
  if (!functionCalls.length) {
846
884
  return;
847
885
  }
848
- const functionResponseEvent = await (0, import_functions.handleFunctionCallsAsync)({
886
+ const functionResponseEvent = await (0, import_functions.handleFunctionCallsLive)({
849
887
  invocationContext,
850
888
  functionCallEvent: mergedEvent,
851
889
  toolsDict: llmRequest.toolsDict,
@@ -927,44 +965,55 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
927
965
  }
928
966
  const span = import_tracing.tracer.startSpan("call_llm");
929
967
  const ctx = import_api.trace.setSpan(import_api.context.active(), span);
930
- yield* (0, import_tracing.runAsyncGeneratorWithOtelContext)(
931
- ctx,
932
- this,
933
- async function* () {
934
- const responsesGenerator = /* @__PURE__ */ __name(async function* () {
935
- var _a3, _b3;
936
- for await (const llmResponse of this.callLlmAsync(
937
- invocationContext,
938
- llmRequest,
939
- modelResponseEvent
940
- )) {
941
- if ((_a3 = invocationContext.abortSignal) == null ? void 0 : _a3.aborted) {
942
- return;
943
- }
944
- for await (const event of this.postprocess(
968
+ try {
969
+ yield* (0, import_tracing.runAsyncGeneratorWithOtelContext)(
970
+ ctx,
971
+ this,
972
+ async function* () {
973
+ const responsesGenerator = /* @__PURE__ */ __name(async function* () {
974
+ var _a3, _b3, _c2;
975
+ for await (const llmResponse of this.callLlmAsync(
945
976
  invocationContext,
946
977
  llmRequest,
947
- llmResponse,
948
978
  modelResponseEvent
949
979
  )) {
950
- if ((_b3 = invocationContext.abortSignal) == null ? void 0 : _b3.aborted) {
980
+ if ((_a3 = invocationContext.abortSignal) == null ? void 0 : _a3.aborted) {
951
981
  return;
952
982
  }
953
- modelResponseEvent.id = (0, import_event.createNewEventId)();
954
- modelResponseEvent.timestamp = (/* @__PURE__ */ new Date()).getTime();
955
- yield event;
983
+ if (((_b3 = invocationContext.runConfig) == null ? void 0 : _b3.supportCfc) && (0, import_event.isEvent)(llmResponse)) {
984
+ modelResponseEvent.id = (0, import_event.createNewEventId)();
985
+ modelResponseEvent.timestamp = (/* @__PURE__ */ new Date()).getTime();
986
+ yield llmResponse;
987
+ continue;
988
+ }
989
+ for await (const event of this.postprocess(
990
+ invocationContext,
991
+ llmRequest,
992
+ llmResponse,
993
+ modelResponseEvent
994
+ )) {
995
+ if ((_c2 = invocationContext.abortSignal) == null ? void 0 : _c2.aborted) {
996
+ return;
997
+ }
998
+ if (!event.partial) {
999
+ modelResponseEvent.id = (0, import_event.createNewEventId)();
1000
+ modelResponseEvent.timestamp = (/* @__PURE__ */ new Date()).getTime();
1001
+ }
1002
+ yield event;
1003
+ }
956
1004
  }
957
- }
958
- }, "responsesGenerator");
959
- yield* this.runAndHandleError(
960
- responsesGenerator.call(this),
961
- invocationContext,
962
- llmRequest,
963
- modelResponseEvent
964
- );
965
- }
966
- );
967
- span.end();
1005
+ }, "responsesGenerator");
1006
+ yield* this.runAndHandleError(
1007
+ responsesGenerator.call(this),
1008
+ invocationContext,
1009
+ llmRequest,
1010
+ modelResponseEvent
1011
+ );
1012
+ }
1013
+ );
1014
+ } finally {
1015
+ span.end();
1016
+ }
968
1017
  }
969
1018
  async *postprocess(invocationContext, llmRequest, llmResponse, modelResponseEvent) {
970
1019
  var _a2, _b2, _c, _d, _e, _f;
@@ -1090,7 +1139,7 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
1090
1139
  return agentToRun;
1091
1140
  }
1092
1141
  async *callLlmAsync(invocationContext, llmRequest, modelResponseEvent) {
1093
- var _a2, _b2, _c, _d, _e, _f, _g, _h;
1142
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
1094
1143
  const beforeModelResponse = await this.handleBeforeModelCallback(
1095
1144
  invocationContext,
1096
1145
  llmRequest,
@@ -1109,14 +1158,39 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
1109
1158
  llmRequest.config.labels[ADK_AGENT_NAME_LABEL_KEY] = this.name;
1110
1159
  }
1111
1160
  const llm = this.canonicalModel;
1161
+ invocationContext.incrementLlmCallCount();
1112
1162
  if ((_e = invocationContext.runConfig) == null ? void 0 : _e.supportCfc) {
1113
- throw new Error("CFC is not yet supported in callLlmAsync");
1163
+ (_f = invocationContext.liveRequestQueue) != null ? _f : invocationContext.liveRequestQueue = new import_live_request_queue.LiveRequestQueue();
1164
+ const liveRequestQueue = invocationContext.liveRequestQueue;
1165
+ try {
1166
+ for await (const llmResponse of this.runLiveFlow(invocationContext)) {
1167
+ if ((_g = invocationContext.abortSignal) == null ? void 0 : _g.aborted) {
1168
+ return;
1169
+ }
1170
+ const alteredLlmResponse = await this.handleAfterModelCallback(
1171
+ invocationContext,
1172
+ llmResponse,
1173
+ modelResponseEvent
1174
+ );
1175
+ if ((_h = invocationContext.abortSignal) == null ? void 0 : _h.aborted) {
1176
+ return;
1177
+ }
1178
+ const effectiveResponse = alteredLlmResponse ? (0, import_event.createEvent)({ ...llmResponse, ...alteredLlmResponse }) : llmResponse;
1179
+ if (invocationContext.runConfig.streamingMode === import_run_config.StreamingMode.SSE || !effectiveResponse.partial) {
1180
+ yield effectiveResponse;
1181
+ }
1182
+ if (effectiveResponse.turnComplete) {
1183
+ liveRequestQueue.close();
1184
+ }
1185
+ }
1186
+ } finally {
1187
+ liveRequestQueue.close();
1188
+ }
1114
1189
  } else {
1115
- invocationContext.incrementLlmCallCount();
1116
1190
  const responsesGenerator = llm.generateContentAsync(
1117
1191
  llmRequest,
1118
1192
  /* stream= */
1119
- ((_f = invocationContext.runConfig) == null ? void 0 : _f.streamingMode) === import_run_config.StreamingMode.SSE,
1193
+ ((_i = invocationContext.runConfig) == null ? void 0 : _i.streamingMode) === import_run_config.StreamingMode.SSE,
1120
1194
  invocationContext.abortSignal
1121
1195
  );
1122
1196
  for await (const llmResponse of responsesGenerator) {
@@ -1126,7 +1200,7 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
1126
1200
  llmRequest,
1127
1201
  llmResponse
1128
1202
  });
1129
- if ((_g = invocationContext.abortSignal) == null ? void 0 : _g.aborted) {
1203
+ if ((_j = invocationContext.abortSignal) == null ? void 0 : _j.aborted) {
1130
1204
  return;
1131
1205
  }
1132
1206
  const alteredLlmResponse = await this.handleAfterModelCallback(
@@ -1134,7 +1208,7 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
1134
1208
  llmResponse,
1135
1209
  modelResponseEvent
1136
1210
  );
1137
- if ((_h = invocationContext.abortSignal) == null ? void 0 : _h.aborted) {
1211
+ if ((_k = invocationContext.abortSignal) == null ? void 0 : _k.aborted) {
1138
1212
  return;
1139
1213
  }
1140
1214
  yield alteredLlmResponse != null ? alteredLlmResponse : llmResponse;
@@ -244,7 +244,7 @@ async function* runPostProcessor(invocationContext, llmResponse) {
244
244
  return;
245
245
  }
246
246
  const responseContent = llmResponse.content;
247
- const codeStr = (0, import_code_execution_utils.extractCodeAndTruncateContent)(
247
+ const { code: codeStr, language } = (0, import_code_execution_utils.extractCodeBlockAndTruncateContent)(
248
248
  responseContent,
249
249
  codeExecutor.codeBlockDelimiters
250
250
  );
@@ -265,7 +265,7 @@ async function* runPostProcessor(invocationContext, llmResponse) {
265
265
  invocationContext,
266
266
  codeExecutionInput: {
267
267
  code: codeStr,
268
- language: import_code_execution_utils.CodeExecutionLanguage.PYTHON,
268
+ language,
269
269
  inputFiles: codeExecutorContext.getInputFiles(),
270
270
  executionId
271
271
  }
@@ -300,14 +300,15 @@ function extractAndReplaceInlineFiles(codeExecutorContext, llmRequest) {
300
300
  continue;
301
301
  }
302
302
  const fileName = `data_${i + 1}_${j + 1}${DATA_FILE_UTIL_MAP[mimeType].extension}`;
303
- part.text = `
304
- Available file: \`${fileName}\`
305
- `;
306
303
  const file = {
307
304
  name: fileName,
308
305
  content: (0, import_env_aware_utils.base64Decode)(part.inlineData.data),
309
306
  mimeType
310
307
  };
308
+ part.text = `
309
+ Available file: \`${fileName}\`
310
+ `;
311
+ delete part.inlineData;
311
312
  if (!savedFileNames.has(fileName)) {
312
313
  codeExecutorContext.addInputFiles([file]);
313
314
  allInputFiles.push(file);
@@ -351,7 +352,10 @@ async function postProcessCodeExecutionResult(invocationContext, codeExecutorCon
351
352
  const version = await invocationContext.artifactService.saveArtifact({
352
353
  filename: outputFile.name,
353
354
  artifact: {
354
- inlineData: { data: outputFile.content, mimeType: outputFile.mimeType }
355
+ inlineData: {
356
+ data: outputFile.contentEncoding === import_code_execution_utils.FileContentEncoding.UTF8 ? (0, import_env_aware_utils.base64Encode)(outputFile.content) : outputFile.content,
357
+ mimeType: outputFile.mimeType
358
+ }
355
359
  }
356
360
  });
357
361
  eventActions.artifactDelta[outputFile.name] = version;