@google/adk 0.3.0 → 0.4.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 (183) hide show
  1. package/dist/cjs/a2a/part_converter_utils.js +210 -0
  2. package/dist/cjs/agents/active_streaming_tool.js +1 -1
  3. package/dist/cjs/agents/base_agent.js +3 -3
  4. package/dist/cjs/agents/base_llm_processor.js +1 -1
  5. package/dist/cjs/agents/callback_context.js +1 -1
  6. package/dist/cjs/agents/content_processor_utils.js +1 -1
  7. package/dist/cjs/agents/functions.js +2 -1
  8. package/dist/cjs/agents/instructions.js +1 -1
  9. package/dist/cjs/agents/invocation_context.js +1 -1
  10. package/dist/cjs/agents/live_request_queue.js +1 -1
  11. package/dist/cjs/agents/llm_agent.js +58 -40
  12. package/dist/cjs/agents/loop_agent.js +1 -1
  13. package/dist/cjs/agents/parallel_agent.js +1 -1
  14. package/dist/cjs/agents/readonly_context.js +13 -1
  15. package/dist/cjs/agents/run_config.js +2 -1
  16. package/dist/cjs/agents/sequential_agent.js +1 -1
  17. package/dist/cjs/agents/transcription_entry.js +1 -1
  18. package/dist/cjs/artifacts/base_artifact_service.js +1 -1
  19. package/dist/cjs/artifacts/file_artifact_service.js +491 -0
  20. package/dist/cjs/artifacts/gcs_artifact_service.js +127 -48
  21. package/dist/cjs/artifacts/in_memory_artifact_service.js +54 -6
  22. package/dist/cjs/artifacts/registry.js +55 -0
  23. package/dist/cjs/auth/auth_credential.js +1 -1
  24. package/dist/cjs/auth/auth_handler.js +1 -1
  25. package/dist/cjs/auth/auth_schemes.js +1 -1
  26. package/dist/cjs/auth/auth_tool.js +1 -1
  27. package/dist/cjs/auth/credential_service/base_credential_service.js +1 -1
  28. package/dist/cjs/auth/credential_service/in_memory_credential_service.js +1 -1
  29. package/dist/cjs/auth/exchanger/base_credential_exchanger.js +1 -1
  30. package/dist/cjs/auth/exchanger/credential_exchanger_registry.js +1 -1
  31. package/dist/cjs/code_executors/base_code_executor.js +1 -1
  32. package/dist/cjs/code_executors/built_in_code_executor.js +1 -1
  33. package/dist/cjs/code_executors/code_execution_utils.js +1 -1
  34. package/dist/cjs/code_executors/code_executor_context.js +1 -1
  35. package/dist/cjs/common.js +14 -1
  36. package/dist/cjs/events/event.js +33 -4
  37. package/dist/cjs/events/event_actions.js +2 -2
  38. package/dist/cjs/events/structured_events.js +105 -0
  39. package/dist/cjs/examples/base_example_provider.js +1 -1
  40. package/dist/cjs/examples/example.js +1 -1
  41. package/dist/cjs/examples/example_util.js +1 -1
  42. package/dist/cjs/index.js +54 -83
  43. package/dist/cjs/index_web.js +1 -1
  44. package/dist/cjs/memory/base_memory_service.js +1 -1
  45. package/dist/cjs/memory/in_memory_memory_service.js +1 -1
  46. package/dist/cjs/memory/memory_entry.js +1 -1
  47. package/dist/cjs/models/apigee_llm.js +182 -0
  48. package/dist/cjs/models/base_llm.js +1 -1
  49. package/dist/cjs/models/base_llm_connection.js +1 -1
  50. package/dist/cjs/models/gemini_llm_connection.js +1 -1
  51. package/dist/cjs/models/google_llm.js +70 -51
  52. package/dist/cjs/models/llm_request.js +1 -1
  53. package/dist/cjs/models/llm_response.js +1 -1
  54. package/dist/cjs/models/registry.js +3 -1
  55. package/dist/cjs/plugins/base_plugin.js +1 -1
  56. package/dist/cjs/plugins/logging_plugin.js +1 -1
  57. package/dist/cjs/plugins/plugin_manager.js +1 -1
  58. package/dist/cjs/plugins/security_plugin.js +1 -1
  59. package/dist/cjs/runner/in_memory_runner.js +1 -1
  60. package/dist/cjs/runner/runner.js +32 -1
  61. package/dist/cjs/sessions/base_session_service.js +53 -3
  62. package/dist/cjs/sessions/database_session_service.js +364 -0
  63. package/dist/cjs/sessions/db/operations.js +114 -0
  64. package/dist/cjs/sessions/db/schema.js +204 -0
  65. package/dist/cjs/sessions/in_memory_session_service.js +24 -22
  66. package/dist/cjs/sessions/registry.js +49 -0
  67. package/dist/cjs/sessions/session.js +1 -1
  68. package/dist/cjs/sessions/state.js +1 -1
  69. package/dist/cjs/telemetry/google_cloud.js +1 -1
  70. package/dist/cjs/telemetry/setup.js +1 -1
  71. package/dist/cjs/telemetry/tracing.js +1 -1
  72. package/dist/cjs/tools/agent_tool.js +1 -1
  73. package/dist/cjs/tools/base_tool.js +1 -1
  74. package/dist/cjs/tools/base_toolset.js +1 -1
  75. package/dist/cjs/tools/forwarding_artifact_service.js +17 -1
  76. package/dist/cjs/tools/function_tool.js +1 -1
  77. package/dist/cjs/tools/google_search_tool.js +1 -1
  78. package/dist/cjs/tools/long_running_tool.js +1 -1
  79. package/dist/cjs/tools/mcp/mcp_session_manager.js +1 -1
  80. package/dist/cjs/tools/mcp/mcp_tool.js +1 -1
  81. package/dist/cjs/tools/mcp/mcp_toolset.js +1 -1
  82. package/dist/cjs/tools/tool_confirmation.js +1 -1
  83. package/dist/cjs/tools/tool_context.js +1 -1
  84. package/dist/cjs/utils/client_labels.js +1 -1
  85. package/dist/cjs/utils/env_aware_utils.js +10 -1
  86. package/dist/cjs/utils/gemini_schema_util.js +1 -1
  87. package/dist/cjs/utils/logger.js +1 -1
  88. package/dist/cjs/utils/model_name.js +1 -1
  89. package/dist/cjs/utils/object_notation_utils.js +78 -0
  90. package/dist/cjs/utils/simple_zod_to_json.js +1 -1
  91. package/dist/cjs/utils/variant_utils.js +3 -9
  92. package/dist/cjs/version.js +2 -2
  93. package/dist/esm/a2a/part_converter_utils.js +171 -0
  94. package/dist/esm/agents/base_agent.js +2 -2
  95. package/dist/esm/agents/functions.js +1 -0
  96. package/dist/esm/agents/llm_agent.js +58 -40
  97. package/dist/esm/agents/readonly_context.js +12 -0
  98. package/dist/esm/agents/run_config.js +1 -0
  99. package/dist/esm/artifacts/file_artifact_service.js +451 -0
  100. package/dist/esm/artifacts/gcs_artifact_service.js +126 -47
  101. package/dist/esm/artifacts/in_memory_artifact_service.js +51 -4
  102. package/dist/esm/artifacts/registry.js +28 -0
  103. package/dist/esm/common.js +9 -1
  104. package/dist/esm/events/event.js +29 -2
  105. package/dist/esm/events/event_actions.js +1 -1
  106. package/dist/esm/events/structured_events.js +74 -0
  107. package/dist/esm/index.js +18 -88
  108. package/dist/esm/models/apigee_llm.js +152 -0
  109. package/dist/esm/models/google_llm.js +67 -49
  110. package/dist/esm/models/registry.js +2 -0
  111. package/dist/esm/runner/runner.js +31 -0
  112. package/dist/esm/sessions/base_session_service.js +49 -1
  113. package/dist/esm/sessions/database_session_service.js +350 -0
  114. package/dist/esm/sessions/db/operations.js +87 -0
  115. package/dist/esm/sessions/db/schema.js +172 -0
  116. package/dist/esm/sessions/in_memory_session_service.js +23 -21
  117. package/dist/esm/sessions/registry.js +25 -0
  118. package/dist/esm/tools/forwarding_artifact_service.js +16 -0
  119. package/dist/esm/utils/env_aware_utils.js +8 -0
  120. package/dist/esm/utils/object_notation_utils.js +47 -0
  121. package/dist/esm/utils/variant_utils.js +1 -7
  122. package/dist/esm/version.js +1 -1
  123. package/dist/types/a2a/part_converter_utils.d.ts +47 -0
  124. package/dist/types/agents/llm_agent.d.ts +11 -11
  125. package/dist/types/agents/readonly_context.d.ts +8 -0
  126. package/dist/types/agents/run_config.d.ts +6 -0
  127. package/dist/types/artifacts/base_artifact_service.d.ts +31 -0
  128. package/dist/types/artifacts/file_artifact_service.d.ts +43 -0
  129. package/dist/types/artifacts/gcs_artifact_service.d.ts +3 -1
  130. package/dist/types/artifacts/in_memory_artifact_service.d.ts +5 -2
  131. package/dist/types/artifacts/registry.d.ts +7 -0
  132. package/dist/types/common.d.ts +11 -2
  133. package/dist/types/events/event.d.ts +15 -1
  134. package/dist/types/events/event_actions.d.ts +1 -1
  135. package/dist/types/events/structured_events.d.ts +106 -0
  136. package/dist/types/index.d.ts +5 -1
  137. package/dist/types/models/apigee_llm.d.ts +59 -0
  138. package/dist/types/models/google_llm.d.ts +5 -2
  139. package/dist/types/runner/runner.d.ts +15 -0
  140. package/dist/types/sessions/base_session_service.d.ts +20 -0
  141. package/dist/types/sessions/database_session_service.d.ts +31 -0
  142. package/dist/types/sessions/db/operations.d.ts +29 -0
  143. package/dist/types/sessions/db/schema.d.ts +45 -0
  144. package/dist/types/sessions/in_memory_session_service.d.ts +4 -1
  145. package/dist/types/sessions/registry.d.ts +7 -0
  146. package/dist/types/tools/forwarding_artifact_service.d.ts +3 -1
  147. package/dist/types/utils/env_aware_utils.d.ts +7 -0
  148. package/dist/types/utils/object_notation_utils.d.ts +21 -0
  149. package/dist/types/version.d.ts +1 -1
  150. package/dist/web/a2a/part_converter_utils.js +171 -0
  151. package/dist/web/agents/base_agent.js +2 -2
  152. package/dist/web/agents/functions.js +1 -0
  153. package/dist/web/agents/llm_agent.js +79 -59
  154. package/dist/web/agents/readonly_context.js +12 -0
  155. package/dist/web/agents/run_config.js +2 -1
  156. package/dist/web/artifacts/file_artifact_service.js +506 -0
  157. package/dist/web/artifacts/gcs_artifact_service.js +123 -46
  158. package/dist/web/artifacts/in_memory_artifact_service.js +51 -4
  159. package/dist/web/artifacts/registry.js +28 -0
  160. package/dist/web/common.js +9 -1
  161. package/dist/web/events/event.js +29 -2
  162. package/dist/web/events/event_actions.js +1 -1
  163. package/dist/web/events/structured_events.js +74 -0
  164. package/dist/web/index.js +18 -8
  165. package/dist/web/models/apigee_llm.js +219 -0
  166. package/dist/web/models/google_llm.js +67 -46
  167. package/dist/web/models/registry.js +2 -0
  168. package/dist/web/runner/runner.js +33 -0
  169. package/dist/web/sessions/base_session_service.js +49 -1
  170. package/dist/web/sessions/database_session_service.js +368 -0
  171. package/dist/web/sessions/db/operations.js +87 -0
  172. package/dist/web/sessions/db/schema.js +172 -0
  173. package/dist/web/sessions/in_memory_session_service.js +23 -21
  174. package/dist/web/sessions/registry.js +25 -0
  175. package/dist/web/tools/forwarding_artifact_service.js +16 -0
  176. package/dist/web/utils/env_aware_utils.js +8 -0
  177. package/dist/web/utils/object_notation_utils.js +47 -0
  178. package/dist/web/utils/variant_utils.js +1 -7
  179. package/dist/web/version.js +1 -1
  180. package/package.json +13 -4
  181. package/dist/cjs/index.js.map +0 -7
  182. package/dist/esm/index.js.map +0 -7
  183. package/dist/web/index.js.map +0 -7
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -29,6 +29,7 @@ __export(gcs_artifact_service_exports, {
29
29
  module.exports = __toCommonJS(gcs_artifact_service_exports);
30
30
  var import_storage = require("@google-cloud/storage");
31
31
  var import_genai = require("@google/genai");
32
+ var import_logger = require("../utils/logger.js");
32
33
  /**
33
34
  * @license
34
35
  * Copyright 2025 Google LLC
@@ -39,6 +40,9 @@ class GcsArtifactService {
39
40
  this.bucket = new import_storage.Storage().bucket(bucket);
40
41
  }
41
42
  async saveArtifact(request) {
43
+ if (!request.artifact.inlineData && !request.artifact.text) {
44
+ throw new Error("Artifact must have either inlineData or text content.");
45
+ }
42
46
  const versions = await this.listVersions(request);
43
47
  const version = versions.length > 0 ? Math.max(...versions) + 1 : 0;
44
48
  const file = this.bucket.file(
@@ -47,62 +51,69 @@ class GcsArtifactService {
47
51
  version
48
52
  })
49
53
  );
54
+ const metadata = request.customMetadata || {};
50
55
  if (request.artifact.inlineData) {
51
- await file.save(JSON.stringify(request.artifact.inlineData.data), {
52
- contentType: request.artifact.inlineData.mimeType
53
- });
54
- return version;
55
- }
56
- if (request.artifact.text) {
57
- await file.save(request.artifact.text, {
58
- contentType: "text/plain"
59
- });
56
+ await file.save(
57
+ Buffer.from(request.artifact.inlineData.data || "", "base64"),
58
+ {
59
+ contentType: request.artifact.inlineData.mimeType,
60
+ metadata
61
+ }
62
+ );
60
63
  return version;
61
64
  }
62
- throw new Error("Artifact must have either inlineData or text.");
65
+ await file.save(request.artifact.text, {
66
+ contentType: "text/plain",
67
+ metadata
68
+ });
69
+ return version;
63
70
  }
64
71
  async loadArtifact(request) {
65
- let version = request.version;
66
- if (version === void 0) {
67
- const versions = await this.listVersions(request);
68
- if (versions.length === 0) {
69
- return void 0;
72
+ try {
73
+ let version = request.version;
74
+ if (version === void 0) {
75
+ const versions = await this.listVersions(request);
76
+ if (versions.length === 0) {
77
+ return void 0;
78
+ }
79
+ version = Math.max(...versions);
70
80
  }
71
- version = Math.max(...versions);
72
- }
73
- const file = this.bucket.file(
74
- getFileName({
75
- ...request,
76
- version
77
- })
78
- );
79
- const [[metadata], [rawDataBuffer]] = await Promise.all([
80
- file.getMetadata(),
81
- file.download()
82
- ]);
83
- if (metadata.contentType === "text/plain") {
84
- return (0, import_genai.createPartFromText)(rawDataBuffer.toString("utf-8"));
81
+ const file = this.bucket.file(
82
+ getFileName({
83
+ ...request,
84
+ version
85
+ })
86
+ );
87
+ const [[metadata], [rawDataBuffer]] = await Promise.all([
88
+ file.getMetadata(),
89
+ file.download()
90
+ ]);
91
+ if (metadata.contentType === "text/plain") {
92
+ return (0, import_genai.createPartFromText)(rawDataBuffer.toString("utf-8"));
93
+ }
94
+ return (0, import_genai.createPartFromBase64)(
95
+ rawDataBuffer.toString("base64"),
96
+ metadata.contentType
97
+ );
98
+ } catch (e) {
99
+ import_logger.logger.warn(
100
+ `[GcsArtifactService] loadArtifact: Failed to load artifact ${request.filename}`,
101
+ e
102
+ );
103
+ return void 0;
85
104
  }
86
- return (0, import_genai.createPartFromBase64)(
87
- rawDataBuffer.toString("base64"),
88
- metadata.contentType
89
- );
90
105
  }
91
106
  async listArtifactKeys(request) {
92
- const fileNames = [];
93
107
  const sessionPrefix = `${request.appName}/${request.userId}/${request.sessionId}/`;
94
108
  const usernamePrefix = `${request.appName}/${request.userId}/user/`;
95
109
  const [[sessionFiles], [userSessionFiles]] = await Promise.all([
96
110
  this.bucket.getFiles({ prefix: sessionPrefix }),
97
111
  this.bucket.getFiles({ prefix: usernamePrefix })
98
112
  ]);
99
- for (const file of sessionFiles) {
100
- fileNames.push(file.name.split("/").pop());
101
- }
102
- for (const file of userSessionFiles) {
103
- fileNames.push(file.name.split("/").pop());
104
- }
105
- return fileNames.sort((a, b) => a.localeCompare(b));
113
+ return [
114
+ ...extractArtifactKeys(sessionFiles, sessionPrefix),
115
+ ...extractArtifactKeys(userSessionFiles, usernamePrefix, "user:")
116
+ ].sort((a, b) => a.localeCompare(b));
106
117
  }
107
118
  async deleteArtifact(request) {
108
119
  const versions = await this.listVersions(request);
@@ -121,13 +132,62 @@ class GcsArtifactService {
121
132
  }
122
133
  async listVersions(request) {
123
134
  const prefix = getFileName(request);
124
- const [files] = await this.bucket.getFiles({ prefix });
135
+ const searchPrefix = prefix + "/";
136
+ const [files] = await this.bucket.getFiles({ prefix: searchPrefix });
125
137
  const versions = [];
126
138
  for (const file of files) {
127
139
  const version = file.name.split("/").pop();
128
- versions.push(parseInt(version, 10));
140
+ const v = parseInt(version, 10);
141
+ if (!isNaN(v)) {
142
+ versions.push(v);
143
+ }
144
+ }
145
+ return versions.sort((a, b) => a - b);
146
+ }
147
+ async listArtifactVersions(request) {
148
+ const versions = await this.listVersions(request);
149
+ const artifactVersions = [];
150
+ for (const version of versions) {
151
+ const artifactVersion = await this.getArtifactVersion({
152
+ ...request,
153
+ version
154
+ });
155
+ if (artifactVersion) {
156
+ artifactVersions.push(artifactVersion);
157
+ }
158
+ }
159
+ return artifactVersions;
160
+ }
161
+ async getArtifactVersion(request) {
162
+ try {
163
+ let version = request.version;
164
+ if (version === void 0) {
165
+ const versions = await this.listVersions(request);
166
+ if (versions.length === 0) {
167
+ return void 0;
168
+ }
169
+ version = Math.max(...versions);
170
+ }
171
+ const file = this.bucket.file(
172
+ getFileName({
173
+ ...request,
174
+ version
175
+ })
176
+ );
177
+ const [metadata] = await file.getMetadata();
178
+ return {
179
+ version,
180
+ mimeType: metadata.contentType,
181
+ customMetadata: metadata.metadata,
182
+ canonicalUri: file.publicUrl()
183
+ };
184
+ } catch (e) {
185
+ import_logger.logger.warn(
186
+ `[GcsArtifactService] getArtifactVersion: Failed to get artifact version for userId: ${request.userId} sessionId: ${request.sessionId} filename: ${request.filename} version: ${request.version}`,
187
+ e
188
+ );
189
+ return void 0;
129
190
  }
130
- return versions;
131
191
  }
132
192
  }
133
193
  function getFileName({
@@ -137,10 +197,29 @@ function getFileName({
137
197
  filename,
138
198
  version
139
199
  }) {
140
- if (filename.startsWith("user:")) {
141
- return `${appName}/${userId}/user/${filename}/${version}`;
200
+ const isUser = filename.startsWith("user:");
201
+ const cleanFilename = isUser ? filename.substring(5) : filename;
202
+ const prefix = isUser ? `${appName}/${userId}/user/${cleanFilename}` : `${appName}/${userId}/${sessionId}/${cleanFilename}`;
203
+ return version !== void 0 ? `${prefix}/${version}` : prefix;
204
+ }
205
+ function extractArtifactKeys(files, fileNamePrefix, keyPrefix = "") {
206
+ const keys = /* @__PURE__ */ new Set();
207
+ for (const file of files) {
208
+ if (!file.name.startsWith(fileNamePrefix)) {
209
+ continue;
210
+ }
211
+ const relative = file.name.substring(fileNamePrefix.length);
212
+ const name = getFileNameFromPath(relative);
213
+ keys.add(`${keyPrefix}${name}`);
214
+ }
215
+ return [...keys];
216
+ }
217
+ function getFileNameFromPath(filePath) {
218
+ const parts = filePath.split("/");
219
+ if (parts.length < 2) {
220
+ return filePath;
142
221
  }
143
- return `${appName}/${userId}/${sessionId}/${filename}/${version}`;
222
+ return parts.slice(0, -1).join("/");
144
223
  }
145
224
  // Annotate the CommonJS export names for ESM import in node:
146
225
  0 && (module.exports = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -24,7 +24,8 @@ var __copyProps = (to, from, except, desc) => {
24
24
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
25
  var in_memory_artifact_service_exports = {};
26
26
  __export(in_memory_artifact_service_exports, {
27
- InMemoryArtifactService: () => InMemoryArtifactService
27
+ InMemoryArtifactService: () => InMemoryArtifactService,
28
+ isInMemoryConnectionString: () => isInMemoryConnectionString
28
29
  });
29
30
  module.exports = __toCommonJS(in_memory_artifact_service_exports);
30
31
  /**
@@ -32,6 +33,9 @@ module.exports = __toCommonJS(in_memory_artifact_service_exports);
32
33
  * Copyright 2025 Google LLC
33
34
  * SPDX-License-Identifier: Apache-2.0
34
35
  */
36
+ function isInMemoryConnectionString(uri) {
37
+ return uri === "memory://";
38
+ }
35
39
  class InMemoryArtifactService {
36
40
  constructor() {
37
41
  this.artifacts = {};
@@ -41,14 +45,24 @@ class InMemoryArtifactService {
41
45
  userId,
42
46
  sessionId,
43
47
  filename,
44
- artifact
48
+ artifact,
49
+ customMetadata
45
50
  }) {
51
+ if (!artifact.inlineData && !artifact.text) {
52
+ return Promise.reject(
53
+ new Error("Artifact must have either inlineData or text content.")
54
+ );
55
+ }
46
56
  const path = artifactPath(appName, userId, sessionId, filename);
47
57
  if (!this.artifacts[path]) {
48
58
  this.artifacts[path] = [];
49
59
  }
50
60
  const version = this.artifacts[path].length;
51
- this.artifacts[path].push(artifact);
61
+ const metadata = {
62
+ version,
63
+ customMetadata
64
+ };
65
+ this.artifacts[path].push({ part: artifact, metadata });
52
66
  return Promise.resolve(version);
53
67
  }
54
68
  loadArtifact({
@@ -66,7 +80,7 @@ class InMemoryArtifactService {
66
80
  if (version === void 0) {
67
81
  version = versions.length - 1;
68
82
  }
69
- return Promise.resolve(versions[version]);
83
+ return Promise.resolve(versions[version].part);
70
84
  }
71
85
  listArtifactKeys({
72
86
  appName,
@@ -117,6 +131,39 @@ class InMemoryArtifactService {
117
131
  }
118
132
  return Promise.resolve(versions);
119
133
  }
134
+ listArtifactVersions({
135
+ appName,
136
+ userId,
137
+ sessionId,
138
+ filename
139
+ }) {
140
+ const path = artifactPath(appName, userId, sessionId, filename);
141
+ const artifacts = this.artifacts[path];
142
+ if (!artifacts) {
143
+ return Promise.resolve([]);
144
+ }
145
+ return Promise.resolve(artifacts.map((a) => a.metadata));
146
+ }
147
+ getArtifactVersion({
148
+ appName,
149
+ userId,
150
+ sessionId,
151
+ filename,
152
+ version
153
+ }) {
154
+ const path = artifactPath(appName, userId, sessionId, filename);
155
+ const versions = this.artifacts[path];
156
+ if (!versions) {
157
+ return Promise.resolve(void 0);
158
+ }
159
+ if (version === void 0) {
160
+ version = versions.length - 1;
161
+ }
162
+ if (versions[version]) {
163
+ return Promise.resolve(versions[version].metadata);
164
+ }
165
+ return Promise.resolve(void 0);
166
+ }
120
167
  }
121
168
  function artifactPath(appName, userId, sessionId, filename) {
122
169
  if (fileHasUserNamespace(filename)) {
@@ -129,5 +176,6 @@ function fileHasUserNamespace(filename) {
129
176
  }
130
177
  // Annotate the CommonJS export names for ESM import in node:
131
178
  0 && (module.exports = {
132
- InMemoryArtifactService
179
+ InMemoryArtifactService,
180
+ isInMemoryConnectionString
133
181
  });
@@ -0,0 +1,55 @@
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 __export = (target, all) => {
13
+ for (var name in all)
14
+ __defProp(target, name, { get: all[name], enumerable: true });
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var registry_exports = {};
26
+ __export(registry_exports, {
27
+ getArtifactServiceFromUri: () => getArtifactServiceFromUri
28
+ });
29
+ module.exports = __toCommonJS(registry_exports);
30
+ var import_file_artifact_service = require("./file_artifact_service.js");
31
+ var import_gcs_artifact_service = require("./gcs_artifact_service.js");
32
+ var import_in_memory_artifact_service = require("./in_memory_artifact_service.js");
33
+ /**
34
+ * @license
35
+ * Copyright 2026 Google LLC
36
+ * SPDX-License-Identifier: Apache-2.0
37
+ */
38
+ function getArtifactServiceFromUri(uri) {
39
+ if ((0, import_in_memory_artifact_service.isInMemoryConnectionString)(uri)) {
40
+ return new import_in_memory_artifact_service.InMemoryArtifactService();
41
+ }
42
+ if (uri.startsWith("gs://")) {
43
+ const bucket = uri.split("://")[1];
44
+ return new import_gcs_artifact_service.GcsArtifactService(bucket);
45
+ }
46
+ if (uri.startsWith("file://")) {
47
+ const rootDir = uri.split("://")[1];
48
+ return new import_file_artifact_service.FileArtifactService(rootDir);
49
+ }
50
+ throw new Error(`Unsupported artifact service URI: ${uri}`);
51
+ }
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ getArtifactServiceFromUri
55
+ });
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -27,6 +27,7 @@ var common_exports = {};
27
27
  __export(common_exports, {
28
28
  ActiveStreamingTool: () => import_active_streaming_tool.ActiveStreamingTool,
29
29
  AgentTool: () => import_agent_tool.AgentTool,
30
+ ApigeeLlm: () => import_apigee_llm.ApigeeLlm,
30
31
  AuthCredentialTypes: () => import_auth_credential.AuthCredentialTypes,
31
32
  BaseAgent: () => import_base_agent.BaseAgent,
32
33
  BaseCodeExecutor: () => import_base_code_executor.BaseCodeExecutor,
@@ -35,10 +36,12 @@ __export(common_exports, {
35
36
  BaseLlmRequestProcessor: () => import_base_llm_processor.BaseLlmRequestProcessor,
36
37
  BaseLlmResponseProcessor: () => import_base_llm_processor.BaseLlmResponseProcessor,
37
38
  BasePlugin: () => import_base_plugin.BasePlugin,
39
+ BaseSessionService: () => import_base_session_service.BaseSessionService,
38
40
  BaseTool: () => import_base_tool.BaseTool,
39
41
  BaseToolset: () => import_base_toolset.BaseToolset,
40
42
  BuiltInCodeExecutor: () => import_built_in_code_executor.BuiltInCodeExecutor,
41
43
  CallbackContext: () => import_callback_context.CallbackContext,
44
+ EventType: () => import_structured_events.EventType,
42
45
  FunctionTool: () => import_function_tool.FunctionTool,
43
46
  GOOGLE_SEARCH: () => import_google_search_tool.GOOGLE_SEARCH,
44
47
  Gemini: () => import_google_llm.Gemini,
@@ -73,6 +76,7 @@ __export(common_exports, {
73
76
  createEventActions: () => import_event_actions.createEventActions,
74
77
  createSession: () => import_session.createSession,
75
78
  functionsExportedForTestingOnly: () => import_functions.functionsExportedForTestingOnly,
79
+ geminiInitParams: () => import_google_llm.geminiInitParams,
76
80
  getAskUserConfirmationFunctionCalls: () => import_security_plugin.getAskUserConfirmationFunctionCalls,
77
81
  getFunctionCalls: () => import_event.getFunctionCalls,
78
82
  getFunctionResponses: () => import_event.getFunctionResponses,
@@ -93,6 +97,7 @@ __export(common_exports, {
93
97
  setLogLevel: () => import_logger.setLogLevel,
94
98
  setLogger: () => import_logger.setLogger,
95
99
  stringifyContent: () => import_event.stringifyContent,
100
+ toStructuredEvents: () => import_structured_events.toStructuredEvents,
96
101
  version: () => import_version.version,
97
102
  zodObjectToSchema: () => import_simple_zod_to_json.zodObjectToSchema
98
103
  });
@@ -116,8 +121,10 @@ var import_base_code_executor = require("./code_executors/base_code_executor.js"
116
121
  var import_built_in_code_executor = require("./code_executors/built_in_code_executor.js");
117
122
  var import_event = require("./events/event.js");
118
123
  var import_event_actions = require("./events/event_actions.js");
124
+ var import_structured_events = require("./events/structured_events.js");
119
125
  var import_base_example_provider = require("./examples/base_example_provider.js");
120
126
  var import_in_memory_memory_service = require("./memory/in_memory_memory_service.js");
127
+ var import_apigee_llm = require("./models/apigee_llm.js");
121
128
  var import_base_llm = require("./models/base_llm.js");
122
129
  var import_google_llm = require("./models/google_llm.js");
123
130
  var import_registry = require("./models/registry.js");
@@ -127,6 +134,7 @@ var import_plugin_manager = require("./plugins/plugin_manager.js");
127
134
  var import_security_plugin = require("./plugins/security_plugin.js");
128
135
  var import_in_memory_runner = require("./runner/in_memory_runner.js");
129
136
  var import_runner = require("./runner/runner.js");
137
+ var import_base_session_service = require("./sessions/base_session_service.js");
130
138
  var import_in_memory_session_service = require("./sessions/in_memory_session_service.js");
131
139
  var import_session = require("./sessions/session.js");
132
140
  var import_state = require("./sessions/state.js");
@@ -156,6 +164,7 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
156
164
  0 && (module.exports = {
157
165
  ActiveStreamingTool,
158
166
  AgentTool,
167
+ ApigeeLlm,
159
168
  AuthCredentialTypes,
160
169
  BaseAgent,
161
170
  BaseCodeExecutor,
@@ -164,10 +173,12 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
164
173
  BaseLlmRequestProcessor,
165
174
  BaseLlmResponseProcessor,
166
175
  BasePlugin,
176
+ BaseSessionService,
167
177
  BaseTool,
168
178
  BaseToolset,
169
179
  BuiltInCodeExecutor,
170
180
  CallbackContext,
181
+ EventType,
171
182
  FunctionTool,
172
183
  GOOGLE_SEARCH,
173
184
  Gemini,
@@ -202,6 +213,7 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
202
213
  createEventActions,
203
214
  createSession,
204
215
  functionsExportedForTestingOnly,
216
+ geminiInitParams,
205
217
  getAskUserConfirmationFunctionCalls,
206
218
  getFunctionCalls,
207
219
  getFunctionResponses,
@@ -222,6 +234,7 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
222
234
  setLogLevel,
223
235
  setLogger,
224
236
  stringifyContent,
237
+ toStructuredEvents,
225
238
  version,
226
239
  zodObjectToSchema,
227
240
  ...require("./artifacts/base_artifact_service.js"),
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
@@ -30,13 +30,16 @@ __export(event_exports, {
30
30
  getFunctionResponses: () => getFunctionResponses,
31
31
  hasTrailingCodeExecutionResult: () => hasTrailingCodeExecutionResult,
32
32
  isFinalResponse: () => isFinalResponse,
33
- stringifyContent: () => stringifyContent
33
+ stringifyContent: () => stringifyContent,
34
+ transformToCamelCaseEvent: () => transformToCamelCaseEvent,
35
+ transformToSnakeCaseEvent: () => transformToSnakeCaseEvent
34
36
  });
35
37
  module.exports = __toCommonJS(event_exports);
38
+ var import_object_notation_utils = require("../utils/object_notation_utils.js");
36
39
  var import_event_actions = require("./event_actions.js");
37
40
  /**
38
41
  * @license
39
- * Copyright 2025 Google LLC
42
+ * Copyright 2026 Google LLC
40
43
  * SPDX-License-Identifier: Apache-2.0
41
44
  */
42
45
  function createEvent(params = {}) {
@@ -105,6 +108,30 @@ function createNewEventId() {
105
108
  }
106
109
  return id;
107
110
  }
111
+ const PRESERVE_KEYS_CAMEL_CASE = [
112
+ "actions.stateDelta",
113
+ "actions.artifactDelta",
114
+ "actions.requestedAuthConfigs",
115
+ "actions.requestedToolConfirmations",
116
+ "actions.customMetadata",
117
+ "content.parts.functionCall.args",
118
+ "content.parts.functionResponse.response"
119
+ ];
120
+ const PRESERVE_KEYS_SNAKE_CASE = [
121
+ "actions.state_delta",
122
+ "actions.artifact_delta",
123
+ "actions.requested_auth_configs",
124
+ "actions.requested_tool_confirmations",
125
+ "actions.custom_metadata",
126
+ "content.parts.function_call.args",
127
+ "content.parts.function_response.response"
128
+ ];
129
+ function transformToCamelCaseEvent(event) {
130
+ return (0, import_object_notation_utils.toCamelCase)(event, PRESERVE_KEYS_SNAKE_CASE);
131
+ }
132
+ function transformToSnakeCaseEvent(event) {
133
+ return (0, import_object_notation_utils.toSnakeCase)(event, PRESERVE_KEYS_CAMEL_CASE);
134
+ }
108
135
  // Annotate the CommonJS export names for ESM import in node:
109
136
  0 && (module.exports = {
110
137
  createEvent,
@@ -113,5 +140,7 @@ function createNewEventId() {
113
140
  getFunctionResponses,
114
141
  hasTrailingCodeExecutionResult,
115
142
  isFinalResponse,
116
- stringifyContent
143
+ stringifyContent,
144
+ transformToCamelCaseEvent,
145
+ transformToSnakeCaseEvent
117
146
  });