@google/adk 0.2.5 → 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.
- package/dist/cjs/a2a/part_converter_utils.js +210 -0
- package/dist/cjs/agents/active_streaming_tool.js +1 -1
- package/dist/cjs/agents/base_agent.js +46 -24
- package/dist/cjs/agents/base_llm_processor.js +1 -1
- package/dist/cjs/agents/callback_context.js +5 -2
- package/dist/cjs/agents/content_processor_utils.js +16 -8
- package/dist/cjs/agents/functions.js +81 -30
- package/dist/cjs/agents/instructions.js +1 -1
- package/dist/cjs/agents/invocation_context.js +1 -1
- package/dist/cjs/agents/live_request_queue.js +1 -1
- package/dist/cjs/agents/llm_agent.js +106 -62
- package/dist/cjs/agents/loop_agent.js +3 -2
- package/dist/cjs/agents/parallel_agent.js +4 -5
- package/dist/cjs/agents/readonly_context.js +13 -1
- package/dist/cjs/agents/run_config.js +2 -1
- package/dist/cjs/agents/sequential_agent.js +1 -1
- package/dist/cjs/agents/transcription_entry.js +1 -1
- package/dist/cjs/artifacts/base_artifact_service.js +1 -1
- package/dist/cjs/artifacts/file_artifact_service.js +491 -0
- package/dist/cjs/artifacts/gcs_artifact_service.js +145 -58
- package/dist/cjs/artifacts/in_memory_artifact_service.js +72 -10
- package/dist/cjs/artifacts/registry.js +55 -0
- package/dist/cjs/auth/auth_credential.js +1 -1
- package/dist/cjs/auth/auth_handler.js +4 -2
- package/dist/cjs/auth/auth_schemes.js +1 -1
- package/dist/cjs/auth/auth_tool.js +1 -1
- package/dist/cjs/auth/credential_service/base_credential_service.js +1 -1
- package/dist/cjs/auth/credential_service/in_memory_credential_service.js +1 -1
- package/dist/cjs/auth/exchanger/base_credential_exchanger.js +1 -1
- package/dist/cjs/auth/exchanger/credential_exchanger_registry.js +1 -1
- package/dist/cjs/code_executors/base_code_executor.js +4 -2
- package/dist/cjs/code_executors/built_in_code_executor.js +8 -4
- package/dist/cjs/code_executors/code_execution_utils.js +1 -1
- package/dist/cjs/code_executors/code_executor_context.js +6 -6
- package/dist/cjs/common.js +18 -1
- package/dist/cjs/events/event.js +34 -7
- package/dist/cjs/events/event_actions.js +2 -2
- package/dist/cjs/events/structured_events.js +105 -0
- package/dist/cjs/examples/base_example_provider.js +1 -1
- package/dist/cjs/examples/example.js +1 -1
- package/dist/cjs/examples/example_util.js +1 -1
- package/dist/cjs/index.js +54 -83
- package/dist/cjs/index_web.js +1 -1
- package/dist/cjs/memory/base_memory_service.js +1 -1
- package/dist/cjs/memory/in_memory_memory_service.js +4 -2
- package/dist/cjs/memory/memory_entry.js +1 -1
- package/dist/cjs/models/apigee_llm.js +182 -0
- package/dist/cjs/models/base_llm.js +9 -5
- package/dist/cjs/models/base_llm_connection.js +1 -1
- package/dist/cjs/models/gemini_llm_connection.js +2 -1
- package/dist/cjs/models/google_llm.js +73 -54
- package/dist/cjs/models/llm_request.js +1 -1
- package/dist/cjs/models/llm_response.js +1 -1
- package/dist/cjs/models/registry.js +3 -1
- package/dist/cjs/plugins/base_plugin.js +13 -1
- package/dist/cjs/plugins/logging_plugin.js +51 -14
- package/dist/cjs/plugins/plugin_manager.js +57 -25
- package/dist/cjs/plugins/security_plugin.js +2 -2
- package/dist/cjs/runner/in_memory_runner.js +1 -1
- package/dist/cjs/runner/runner.js +142 -96
- package/dist/cjs/sessions/base_session_service.js +53 -3
- package/dist/cjs/sessions/database_session_service.js +364 -0
- package/dist/cjs/sessions/db/operations.js +114 -0
- package/dist/cjs/sessions/db/schema.js +204 -0
- package/dist/cjs/sessions/in_memory_session_service.js +60 -34
- package/dist/cjs/sessions/registry.js +49 -0
- package/dist/cjs/sessions/session.js +1 -1
- package/dist/cjs/sessions/state.js +1 -1
- package/dist/cjs/telemetry/google_cloud.js +8 -10
- package/dist/cjs/telemetry/setup.js +16 -8
- package/dist/cjs/telemetry/tracing.js +38 -16
- package/dist/cjs/tools/agent_tool.js +9 -5
- package/dist/cjs/tools/base_tool.js +5 -3
- package/dist/cjs/tools/base_toolset.js +1 -1
- package/dist/cjs/tools/forwarding_artifact_service.js +18 -2
- package/dist/cjs/tools/function_tool.js +2 -3
- package/dist/cjs/tools/google_search_tool.js +2 -3
- package/dist/cjs/tools/long_running_tool.js +1 -1
- package/dist/cjs/tools/mcp/mcp_session_manager.js +17 -11
- package/dist/cjs/tools/mcp/mcp_tool.js +2 -4
- package/dist/cjs/tools/mcp/mcp_toolset.js +2 -2
- package/dist/cjs/tools/tool_confirmation.js +1 -1
- package/dist/cjs/tools/tool_context.js +1 -1
- package/dist/cjs/utils/client_labels.js +1 -1
- package/dist/cjs/utils/env_aware_utils.js +11 -2
- package/dist/cjs/utils/gemini_schema_util.js +10 -5
- package/dist/cjs/utils/logger.js +48 -4
- package/dist/cjs/utils/model_name.js +1 -1
- package/dist/cjs/utils/object_notation_utils.js +78 -0
- package/dist/cjs/utils/simple_zod_to_json.js +101 -142
- package/dist/cjs/utils/variant_utils.js +3 -9
- package/dist/cjs/version.js +2 -2
- package/dist/esm/a2a/part_converter_utils.js +171 -0
- package/dist/esm/agents/base_agent.js +50 -24
- package/dist/esm/agents/callback_context.js +4 -1
- package/dist/esm/agents/content_processor_utils.js +25 -9
- package/dist/esm/agents/functions.js +84 -29
- package/dist/esm/agents/llm_agent.js +110 -62
- package/dist/esm/agents/loop_agent.js +2 -1
- package/dist/esm/agents/parallel_agent.js +3 -4
- package/dist/esm/agents/readonly_context.js +12 -0
- package/dist/esm/agents/run_config.js +1 -0
- package/dist/esm/artifacts/file_artifact_service.js +451 -0
- package/dist/esm/artifacts/gcs_artifact_service.js +144 -57
- package/dist/esm/artifacts/in_memory_artifact_service.js +69 -8
- package/dist/esm/artifacts/registry.js +28 -0
- package/dist/esm/auth/auth_handler.js +3 -1
- package/dist/esm/code_executors/base_code_executor.js +3 -1
- package/dist/esm/code_executors/built_in_code_executor.js +7 -3
- package/dist/esm/code_executors/code_executor_context.js +5 -5
- package/dist/esm/common.js +12 -2
- package/dist/esm/events/event.js +30 -5
- package/dist/esm/events/event_actions.js +1 -1
- package/dist/esm/events/structured_events.js +74 -0
- package/dist/esm/index.js +18 -88
- package/dist/esm/memory/in_memory_memory_service.js +3 -1
- package/dist/esm/models/apigee_llm.js +152 -0
- package/dist/esm/models/base_llm.js +8 -4
- package/dist/esm/models/gemini_llm_connection.js +1 -0
- package/dist/esm/models/google_llm.js +75 -53
- package/dist/esm/models/registry.js +2 -0
- package/dist/esm/plugins/base_plugin.js +12 -0
- package/dist/esm/plugins/logging_plugin.js +55 -14
- package/dist/esm/plugins/plugin_manager.js +56 -24
- package/dist/esm/plugins/security_plugin.js +1 -1
- package/dist/esm/runner/runner.js +145 -96
- package/dist/esm/sessions/base_session_service.js +49 -1
- package/dist/esm/sessions/database_session_service.js +350 -0
- package/dist/esm/sessions/db/operations.js +87 -0
- package/dist/esm/sessions/db/schema.js +172 -0
- package/dist/esm/sessions/in_memory_session_service.js +61 -33
- package/dist/esm/sessions/registry.js +25 -0
- package/dist/esm/telemetry/google_cloud.js +7 -9
- package/dist/esm/telemetry/setup.js +23 -9
- package/dist/esm/telemetry/tracing.js +37 -15
- package/dist/esm/tools/agent_tool.js +8 -4
- package/dist/esm/tools/base_tool.js +4 -2
- package/dist/esm/tools/forwarding_artifact_service.js +17 -1
- package/dist/esm/tools/function_tool.js +1 -2
- package/dist/esm/tools/google_search_tool.js +2 -5
- package/dist/esm/tools/long_running_tool.js +3 -1
- package/dist/esm/tools/mcp/mcp_session_manager.js +22 -12
- package/dist/esm/tools/mcp/mcp_tool.js +1 -3
- package/dist/esm/tools/mcp/mcp_toolset.js +1 -1
- package/dist/esm/utils/env_aware_utils.js +9 -1
- package/dist/esm/utils/gemini_schema_util.js +9 -4
- package/dist/esm/utils/logger.js +43 -2
- package/dist/esm/utils/object_notation_utils.js +47 -0
- package/dist/esm/utils/simple_zod_to_json.js +102 -141
- package/dist/esm/utils/variant_utils.js +1 -7
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/part_converter_utils.d.ts +47 -0
- package/dist/types/agents/base_agent.d.ts +2 -1
- package/dist/types/agents/callback_context.d.ts +1 -1
- package/dist/types/agents/llm_agent.d.ts +12 -12
- package/dist/types/agents/loop_agent.d.ts +1 -1
- package/dist/types/agents/parallel_agent.d.ts +1 -1
- package/dist/types/agents/readonly_context.d.ts +8 -0
- package/dist/types/agents/run_config.d.ts +6 -0
- package/dist/types/artifacts/base_artifact_service.d.ts +31 -0
- package/dist/types/artifacts/file_artifact_service.d.ts +43 -0
- package/dist/types/artifacts/gcs_artifact_service.d.ts +3 -1
- package/dist/types/artifacts/in_memory_artifact_service.d.ts +8 -5
- package/dist/types/artifacts/registry.d.ts +7 -0
- package/dist/types/code_executors/built_in_code_executor.d.ts +1 -1
- package/dist/types/code_executors/code_executor_context.d.ts +2 -4
- package/dist/types/common.d.ts +13 -3
- package/dist/types/events/event.d.ts +15 -1
- package/dist/types/events/event_actions.d.ts +1 -1
- package/dist/types/events/structured_events.d.ts +106 -0
- package/dist/types/index.d.ts +7 -3
- package/dist/types/models/apigee_llm.d.ts +59 -0
- package/dist/types/models/base_llm_connection.d.ts +1 -1
- package/dist/types/models/google_llm.d.ts +5 -2
- package/dist/types/models/llm_response.d.ts +1 -1
- package/dist/types/plugins/logging_plugin.d.ts +12 -12
- package/dist/types/plugins/plugin_manager.d.ts +12 -12
- package/dist/types/plugins/security_plugin.d.ts +1 -1
- package/dist/types/runner/runner.d.ts +16 -1
- package/dist/types/sessions/base_session_service.d.ts +20 -0
- package/dist/types/sessions/database_session_service.d.ts +31 -0
- package/dist/types/sessions/db/operations.d.ts +29 -0
- package/dist/types/sessions/db/schema.d.ts +45 -0
- package/dist/types/sessions/in_memory_session_service.d.ts +9 -6
- package/dist/types/sessions/registry.d.ts +7 -0
- package/dist/types/telemetry/setup.d.ts +1 -1
- package/dist/types/telemetry/tracing.d.ts +7 -6
- package/dist/types/tools/agent_tool.d.ts +1 -1
- package/dist/types/tools/base_tool.d.ts +1 -1
- package/dist/types/tools/base_toolset.d.ts +2 -1
- package/dist/types/tools/forwarding_artifact_service.d.ts +4 -2
- package/dist/types/tools/function_tool.d.ts +4 -3
- package/dist/types/tools/google_search_tool.d.ts +3 -3
- package/dist/types/tools/mcp/mcp_session_manager.d.ts +10 -3
- package/dist/types/tools/mcp/mcp_toolset.d.ts +1 -2
- package/dist/types/utils/env_aware_utils.d.ts +7 -0
- package/dist/types/utils/gemini_schema_util.d.ts +4 -12
- package/dist/types/utils/logger.d.ts +11 -10
- package/dist/types/utils/object_notation_utils.d.ts +21 -0
- package/dist/types/utils/simple_zod_to_json.d.ts +5 -4
- package/dist/types/version.d.ts +1 -1
- package/dist/web/a2a/part_converter_utils.js +171 -0
- package/dist/web/agents/base_agent.js +96 -35
- package/dist/web/agents/callback_context.js +4 -1
- package/dist/web/agents/content_processor_utils.js +25 -9
- package/dist/web/agents/functions.js +84 -29
- package/dist/web/agents/llm_agent.js +166 -83
- package/dist/web/agents/loop_agent.js +2 -1
- package/dist/web/agents/parallel_agent.js +3 -4
- package/dist/web/agents/readonly_context.js +12 -0
- package/dist/web/agents/run_config.js +2 -1
- package/dist/web/artifacts/file_artifact_service.js +506 -0
- package/dist/web/artifacts/gcs_artifact_service.js +139 -54
- package/dist/web/artifacts/in_memory_artifact_service.js +69 -8
- package/dist/web/artifacts/registry.js +28 -0
- package/dist/web/auth/auth_handler.js +3 -1
- package/dist/web/code_executors/base_code_executor.js +3 -1
- package/dist/web/code_executors/built_in_code_executor.js +7 -3
- package/dist/web/code_executors/code_executor_context.js +5 -5
- package/dist/web/common.js +12 -2
- package/dist/web/events/event.js +30 -5
- package/dist/web/events/event_actions.js +1 -1
- package/dist/web/events/structured_events.js +74 -0
- package/dist/web/index.js +18 -8
- package/dist/web/memory/in_memory_memory_service.js +3 -1
- package/dist/web/models/apigee_llm.js +219 -0
- package/dist/web/models/base_llm.js +8 -4
- package/dist/web/models/gemini_llm_connection.js +1 -0
- package/dist/web/models/google_llm.js +75 -50
- package/dist/web/models/registry.js +2 -0
- package/dist/web/plugins/base_plugin.js +12 -0
- package/dist/web/plugins/logging_plugin.js +55 -14
- package/dist/web/plugins/plugin_manager.js +56 -24
- package/dist/web/plugins/security_plugin.js +1 -1
- package/dist/web/runner/runner.js +192 -108
- package/dist/web/sessions/base_session_service.js +49 -1
- package/dist/web/sessions/database_session_service.js +368 -0
- package/dist/web/sessions/db/operations.js +87 -0
- package/dist/web/sessions/db/schema.js +172 -0
- package/dist/web/sessions/in_memory_session_service.js +61 -33
- package/dist/web/sessions/registry.js +25 -0
- package/dist/web/telemetry/google_cloud.js +7 -9
- package/dist/web/telemetry/setup.js +23 -9
- package/dist/web/telemetry/tracing.js +37 -15
- package/dist/web/tools/agent_tool.js +8 -4
- package/dist/web/tools/base_tool.js +4 -2
- package/dist/web/tools/forwarding_artifact_service.js +17 -1
- package/dist/web/tools/function_tool.js +1 -2
- package/dist/web/tools/google_search_tool.js +2 -5
- package/dist/web/tools/long_running_tool.js +3 -1
- package/dist/web/tools/mcp/mcp_session_manager.js +22 -12
- package/dist/web/tools/mcp/mcp_tool.js +1 -3
- package/dist/web/tools/mcp/mcp_toolset.js +1 -1
- package/dist/web/utils/env_aware_utils.js +9 -1
- package/dist/web/utils/gemini_schema_util.js +9 -4
- package/dist/web/utils/logger.js +43 -2
- package/dist/web/utils/object_notation_utils.js +47 -0
- package/dist/web/utils/simple_zod_to_json.js +102 -155
- package/dist/web/utils/variant_utils.js +1 -7
- package/dist/web/version.js +1 -1
- package/package.json +16 -5
- package/dist/cjs/index.js.map +0 -7
- package/dist/esm/index.js.map +0 -7
- package/dist/web/index.js.map +0 -7
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
function isInMemoryConnectionString(uri) {
|
|
7
|
+
return uri === "memory://";
|
|
8
|
+
}
|
|
6
9
|
class InMemoryArtifactService {
|
|
7
10
|
constructor() {
|
|
8
11
|
this.artifacts = {};
|
|
@@ -12,14 +15,24 @@ class InMemoryArtifactService {
|
|
|
12
15
|
userId,
|
|
13
16
|
sessionId,
|
|
14
17
|
filename,
|
|
15
|
-
artifact
|
|
18
|
+
artifact,
|
|
19
|
+
customMetadata
|
|
16
20
|
}) {
|
|
21
|
+
if (!artifact.inlineData && !artifact.text) {
|
|
22
|
+
return Promise.reject(
|
|
23
|
+
new Error("Artifact must have either inlineData or text content.")
|
|
24
|
+
);
|
|
25
|
+
}
|
|
17
26
|
const path = artifactPath(appName, userId, sessionId, filename);
|
|
18
27
|
if (!this.artifacts[path]) {
|
|
19
28
|
this.artifacts[path] = [];
|
|
20
29
|
}
|
|
21
30
|
const version = this.artifacts[path].length;
|
|
22
|
-
|
|
31
|
+
const metadata = {
|
|
32
|
+
version,
|
|
33
|
+
customMetadata
|
|
34
|
+
};
|
|
35
|
+
this.artifacts[path].push({ part: artifact, metadata });
|
|
23
36
|
return Promise.resolve(version);
|
|
24
37
|
}
|
|
25
38
|
loadArtifact({
|
|
@@ -37,9 +50,13 @@ class InMemoryArtifactService {
|
|
|
37
50
|
if (version === void 0) {
|
|
38
51
|
version = versions.length - 1;
|
|
39
52
|
}
|
|
40
|
-
return Promise.resolve(versions[version]);
|
|
53
|
+
return Promise.resolve(versions[version].part);
|
|
41
54
|
}
|
|
42
|
-
listArtifactKeys({
|
|
55
|
+
listArtifactKeys({
|
|
56
|
+
appName,
|
|
57
|
+
userId,
|
|
58
|
+
sessionId
|
|
59
|
+
}) {
|
|
43
60
|
const sessionPrefix = `${appName}/${userId}/${sessionId}/`;
|
|
44
61
|
const usernamespacePrefix = `${appName}/${userId}/user/`;
|
|
45
62
|
const filenames = [];
|
|
@@ -54,7 +71,12 @@ class InMemoryArtifactService {
|
|
|
54
71
|
}
|
|
55
72
|
return Promise.resolve(filenames.sort());
|
|
56
73
|
}
|
|
57
|
-
deleteArtifact({
|
|
74
|
+
deleteArtifact({
|
|
75
|
+
appName,
|
|
76
|
+
userId,
|
|
77
|
+
sessionId,
|
|
78
|
+
filename
|
|
79
|
+
}) {
|
|
58
80
|
const path = artifactPath(appName, userId, sessionId, filename);
|
|
59
81
|
if (!this.artifacts[path]) {
|
|
60
82
|
return Promise.resolve();
|
|
@@ -62,18 +84,56 @@ class InMemoryArtifactService {
|
|
|
62
84
|
delete this.artifacts[path];
|
|
63
85
|
return Promise.resolve();
|
|
64
86
|
}
|
|
65
|
-
listVersions({
|
|
87
|
+
listVersions({
|
|
88
|
+
appName,
|
|
89
|
+
userId,
|
|
90
|
+
sessionId,
|
|
91
|
+
filename
|
|
92
|
+
}) {
|
|
66
93
|
const path = artifactPath(appName, userId, sessionId, filename);
|
|
67
94
|
const artifacts = this.artifacts[path];
|
|
68
95
|
if (!artifacts) {
|
|
69
96
|
return Promise.resolve([]);
|
|
70
97
|
}
|
|
71
|
-
|
|
98
|
+
const versions = [];
|
|
72
99
|
for (let i = 0; i < artifacts.length; i++) {
|
|
73
100
|
versions.push(i);
|
|
74
101
|
}
|
|
75
102
|
return Promise.resolve(versions);
|
|
76
103
|
}
|
|
104
|
+
listArtifactVersions({
|
|
105
|
+
appName,
|
|
106
|
+
userId,
|
|
107
|
+
sessionId,
|
|
108
|
+
filename
|
|
109
|
+
}) {
|
|
110
|
+
const path = artifactPath(appName, userId, sessionId, filename);
|
|
111
|
+
const artifacts = this.artifacts[path];
|
|
112
|
+
if (!artifacts) {
|
|
113
|
+
return Promise.resolve([]);
|
|
114
|
+
}
|
|
115
|
+
return Promise.resolve(artifacts.map((a) => a.metadata));
|
|
116
|
+
}
|
|
117
|
+
getArtifactVersion({
|
|
118
|
+
appName,
|
|
119
|
+
userId,
|
|
120
|
+
sessionId,
|
|
121
|
+
filename,
|
|
122
|
+
version
|
|
123
|
+
}) {
|
|
124
|
+
const path = artifactPath(appName, userId, sessionId, filename);
|
|
125
|
+
const versions = this.artifacts[path];
|
|
126
|
+
if (!versions) {
|
|
127
|
+
return Promise.resolve(void 0);
|
|
128
|
+
}
|
|
129
|
+
if (version === void 0) {
|
|
130
|
+
version = versions.length - 1;
|
|
131
|
+
}
|
|
132
|
+
if (versions[version]) {
|
|
133
|
+
return Promise.resolve(versions[version].metadata);
|
|
134
|
+
}
|
|
135
|
+
return Promise.resolve(void 0);
|
|
136
|
+
}
|
|
77
137
|
}
|
|
78
138
|
function artifactPath(appName, userId, sessionId, filename) {
|
|
79
139
|
if (fileHasUserNamespace(filename)) {
|
|
@@ -85,5 +145,6 @@ function fileHasUserNamespace(filename) {
|
|
|
85
145
|
return filename.startsWith("user:");
|
|
86
146
|
}
|
|
87
147
|
export {
|
|
88
|
-
InMemoryArtifactService
|
|
148
|
+
InMemoryArtifactService,
|
|
149
|
+
isInMemoryConnectionString
|
|
89
150
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { FileArtifactService } from "./file_artifact_service.js";
|
|
7
|
+
import { GcsArtifactService } from "./gcs_artifact_service.js";
|
|
8
|
+
import {
|
|
9
|
+
InMemoryArtifactService,
|
|
10
|
+
isInMemoryConnectionString
|
|
11
|
+
} from "./in_memory_artifact_service.js";
|
|
12
|
+
function getArtifactServiceFromUri(uri) {
|
|
13
|
+
if (isInMemoryConnectionString(uri)) {
|
|
14
|
+
return new InMemoryArtifactService();
|
|
15
|
+
}
|
|
16
|
+
if (uri.startsWith("gs://")) {
|
|
17
|
+
const bucket = uri.split("://")[1];
|
|
18
|
+
return new GcsArtifactService(bucket);
|
|
19
|
+
}
|
|
20
|
+
if (uri.startsWith("file://")) {
|
|
21
|
+
const rootDir = uri.split("://")[1];
|
|
22
|
+
return new FileArtifactService(rootDir);
|
|
23
|
+
}
|
|
24
|
+
throw new Error(`Unsupported artifact service URI: ${uri}`);
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
getArtifactServiceFromUri
|
|
28
|
+
};
|
|
@@ -37,7 +37,9 @@ class AuthHandler {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
if (!this.authConfig.rawAuthCredential.oauth2.clientId || !this.authConfig.rawAuthCredential.oauth2.clientSecret) {
|
|
40
|
-
throw new Error(
|
|
40
|
+
throw new Error(
|
|
41
|
+
`Auth Scheme ${authSchemeType} requires both clientId and clientSecret in authCredential.oauth2.`
|
|
42
|
+
);
|
|
41
43
|
}
|
|
42
44
|
return {
|
|
43
45
|
credentialKey: this.authConfig.credentialKey,
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
var _a;
|
|
7
|
-
const BASE_CODE_EXECUTOR_SIGNATURE_SYMBOL = Symbol.for(
|
|
7
|
+
const BASE_CODE_EXECUTOR_SIGNATURE_SYMBOL = Symbol.for(
|
|
8
|
+
"google.adk.baseCodeExecutor"
|
|
9
|
+
);
|
|
8
10
|
function isBaseCodeExecutor(obj) {
|
|
9
11
|
return typeof obj === "object" && obj !== null && BASE_CODE_EXECUTOR_SIGNATURE_SYMBOL in obj && obj[BASE_CODE_EXECUTOR_SIGNATURE_SYMBOL] === true;
|
|
10
12
|
}
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
var _a, _b;
|
|
7
7
|
import { isGemini2OrAbove } from "../utils/model_name.js";
|
|
8
8
|
import { BaseCodeExecutor } from "./base_code_executor.js";
|
|
9
|
-
const BUILT_IN_CODE_EXECUTOR_SIGNATURE_SYMBOL = Symbol.for(
|
|
9
|
+
const BUILT_IN_CODE_EXECUTOR_SIGNATURE_SYMBOL = Symbol.for(
|
|
10
|
+
"google.adk.builtInCodeExecutor"
|
|
11
|
+
);
|
|
10
12
|
function isBuiltInCodeExecutor(obj) {
|
|
11
13
|
return typeof obj === "object" && obj !== null && BUILT_IN_CODE_EXECUTOR_SIGNATURE_SYMBOL in obj && obj[BUILT_IN_CODE_EXECUTOR_SIGNATURE_SYMBOL] === true;
|
|
12
14
|
}
|
|
@@ -16,7 +18,7 @@ class BuiltInCodeExecutor extends (_b = BaseCodeExecutor, _a = BUILT_IN_CODE_EXE
|
|
|
16
18
|
/** A unique symbol to identify BuiltInCodeExecutor class. */
|
|
17
19
|
this[_a] = true;
|
|
18
20
|
}
|
|
19
|
-
executeCode(
|
|
21
|
+
executeCode(_params) {
|
|
20
22
|
return Promise.resolve({
|
|
21
23
|
stdout: "",
|
|
22
24
|
stderr: "",
|
|
@@ -30,7 +32,9 @@ class BuiltInCodeExecutor extends (_b = BaseCodeExecutor, _a = BUILT_IN_CODE_EXE
|
|
|
30
32
|
llmRequest.config.tools.push({ codeExecution: {} });
|
|
31
33
|
return;
|
|
32
34
|
}
|
|
33
|
-
throw new Error(
|
|
35
|
+
throw new Error(
|
|
36
|
+
`Gemini code execution tool is not supported for model ${llmRequest.model}`
|
|
37
|
+
);
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
export {
|
|
@@ -142,7 +142,9 @@ class CodeExecutorContext {
|
|
|
142
142
|
if (!(CODE_EXECUTION_RESULTS_KEY in this.sessionState)) {
|
|
143
143
|
this.sessionState.set(CODE_EXECUTION_RESULTS_KEY, {});
|
|
144
144
|
}
|
|
145
|
-
const codeExecutionResults = this.sessionState.get(
|
|
145
|
+
const codeExecutionResults = this.sessionState.get(
|
|
146
|
+
CODE_EXECUTION_RESULTS_KEY
|
|
147
|
+
);
|
|
146
148
|
if (!(invocationId in codeExecutionResults)) {
|
|
147
149
|
codeExecutionResults[invocationId] = [];
|
|
148
150
|
}
|
|
@@ -154,12 +156,10 @@ class CodeExecutorContext {
|
|
|
154
156
|
});
|
|
155
157
|
}
|
|
156
158
|
/**
|
|
157
|
-
* Gets the code
|
|
158
|
-
* @param invocationId The session state to get the code executor context
|
|
159
|
-
* from.
|
|
159
|
+
* Gets the code execution context from the session state.
|
|
160
160
|
* @return The code execution context for the given invocation ID.
|
|
161
161
|
*/
|
|
162
|
-
getCodeExecutionContext(
|
|
162
|
+
getCodeExecutionContext() {
|
|
163
163
|
return this.sessionState.get(CONTEXT_KEY) || {};
|
|
164
164
|
}
|
|
165
165
|
}
|
package/dist/esm/common.js
CHANGED
|
@@ -32,13 +32,15 @@ import {
|
|
|
32
32
|
stringifyContent
|
|
33
33
|
} from "./events/event.js";
|
|
34
34
|
import { createEventActions } from "./events/event_actions.js";
|
|
35
|
+
import { EventType, toStructuredEvents } from "./events/structured_events.js";
|
|
35
36
|
import {
|
|
36
37
|
BaseExampleProvider,
|
|
37
38
|
isBaseExampleProvider
|
|
38
39
|
} from "./examples/base_example_provider.js";
|
|
39
40
|
import { InMemoryMemoryService } from "./memory/in_memory_memory_service.js";
|
|
41
|
+
import { ApigeeLlm } from "./models/apigee_llm.js";
|
|
40
42
|
import { BaseLlm, isBaseLlm } from "./models/base_llm.js";
|
|
41
|
-
import { Gemini } from "./models/google_llm.js";
|
|
43
|
+
import { Gemini, geminiInitParams } from "./models/google_llm.js";
|
|
42
44
|
import { LLMRegistry } from "./models/registry.js";
|
|
43
45
|
import { BasePlugin } from "./plugins/base_plugin.js";
|
|
44
46
|
import { LoggingPlugin } from "./plugins/logging_plugin.js";
|
|
@@ -52,6 +54,7 @@ import {
|
|
|
52
54
|
} from "./plugins/security_plugin.js";
|
|
53
55
|
import { InMemoryRunner } from "./runner/in_memory_runner.js";
|
|
54
56
|
import { Runner } from "./runner/runner.js";
|
|
57
|
+
import { BaseSessionService } from "./sessions/base_session_service.js";
|
|
55
58
|
import { InMemorySessionService } from "./sessions/in_memory_session_service.js";
|
|
56
59
|
import { createSession } from "./sessions/session.js";
|
|
57
60
|
import { State } from "./sessions/state.js";
|
|
@@ -63,7 +66,7 @@ import { GOOGLE_SEARCH, GoogleSearchTool } from "./tools/google_search_tool.js";
|
|
|
63
66
|
import { LongRunningFunctionTool } from "./tools/long_running_tool.js";
|
|
64
67
|
import { ToolConfirmation } from "./tools/tool_confirmation.js";
|
|
65
68
|
import { ToolContext } from "./tools/tool_context.js";
|
|
66
|
-
import { LogLevel, setLogLevel } from "./utils/logger.js";
|
|
69
|
+
import { LogLevel, getLogger, setLogLevel, setLogger } from "./utils/logger.js";
|
|
67
70
|
import { isGemini2OrAbove } from "./utils/model_name.js";
|
|
68
71
|
import { zodObjectToSchema } from "./utils/simple_zod_to_json.js";
|
|
69
72
|
import { GoogleLLMVariant } from "./utils/variant_utils.js";
|
|
@@ -75,6 +78,7 @@ export * from "./tools/base_tool.js";
|
|
|
75
78
|
export {
|
|
76
79
|
ActiveStreamingTool,
|
|
77
80
|
AgentTool,
|
|
81
|
+
ApigeeLlm,
|
|
78
82
|
AuthCredentialTypes,
|
|
79
83
|
BaseAgent,
|
|
80
84
|
BaseCodeExecutor,
|
|
@@ -83,10 +87,12 @@ export {
|
|
|
83
87
|
BaseLlmRequestProcessor,
|
|
84
88
|
BaseLlmResponseProcessor,
|
|
85
89
|
BasePlugin,
|
|
90
|
+
BaseSessionService,
|
|
86
91
|
BaseTool,
|
|
87
92
|
BaseToolset,
|
|
88
93
|
BuiltInCodeExecutor,
|
|
89
94
|
CallbackContext,
|
|
95
|
+
EventType,
|
|
90
96
|
FunctionTool,
|
|
91
97
|
GOOGLE_SEARCH,
|
|
92
98
|
Gemini,
|
|
@@ -121,9 +127,11 @@ export {
|
|
|
121
127
|
createEventActions,
|
|
122
128
|
createSession,
|
|
123
129
|
functionsExportedForTestingOnly,
|
|
130
|
+
geminiInitParams,
|
|
124
131
|
getAskUserConfirmationFunctionCalls,
|
|
125
132
|
getFunctionCalls,
|
|
126
133
|
getFunctionResponses,
|
|
134
|
+
getLogger,
|
|
127
135
|
hasTrailingCodeExecutionResult,
|
|
128
136
|
isAgentTool,
|
|
129
137
|
isBaseAgent,
|
|
@@ -138,7 +146,9 @@ export {
|
|
|
138
146
|
isParallelAgent,
|
|
139
147
|
isSequentialAgent,
|
|
140
148
|
setLogLevel,
|
|
149
|
+
setLogger,
|
|
141
150
|
stringifyContent,
|
|
151
|
+
toStructuredEvents,
|
|
142
152
|
version,
|
|
143
153
|
zodObjectToSchema
|
|
144
154
|
};
|
package/dist/esm/events/event.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
import { toCamelCase, toSnakeCase } from "../utils/object_notation_utils.js";
|
|
6
7
|
import { createEventActions } from "./event_actions.js";
|
|
7
8
|
function createEvent(params = {}) {
|
|
8
9
|
return {
|
|
@@ -66,12 +67,34 @@ const ASCII_LETTERS_AND_NUMBERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS
|
|
|
66
67
|
function createNewEventId() {
|
|
67
68
|
let id = "";
|
|
68
69
|
for (let i = 0; i < 8; i++) {
|
|
69
|
-
id += ASCII_LETTERS_AND_NUMBERS[Math.floor(
|
|
70
|
-
Math.random() * ASCII_LETTERS_AND_NUMBERS.length
|
|
71
|
-
)];
|
|
70
|
+
id += ASCII_LETTERS_AND_NUMBERS[Math.floor(Math.random() * ASCII_LETTERS_AND_NUMBERS.length)];
|
|
72
71
|
}
|
|
73
72
|
return id;
|
|
74
73
|
}
|
|
74
|
+
const PRESERVE_KEYS_CAMEL_CASE = [
|
|
75
|
+
"actions.stateDelta",
|
|
76
|
+
"actions.artifactDelta",
|
|
77
|
+
"actions.requestedAuthConfigs",
|
|
78
|
+
"actions.requestedToolConfirmations",
|
|
79
|
+
"actions.customMetadata",
|
|
80
|
+
"content.parts.functionCall.args",
|
|
81
|
+
"content.parts.functionResponse.response"
|
|
82
|
+
];
|
|
83
|
+
const PRESERVE_KEYS_SNAKE_CASE = [
|
|
84
|
+
"actions.state_delta",
|
|
85
|
+
"actions.artifact_delta",
|
|
86
|
+
"actions.requested_auth_configs",
|
|
87
|
+
"actions.requested_tool_confirmations",
|
|
88
|
+
"actions.custom_metadata",
|
|
89
|
+
"content.parts.function_call.args",
|
|
90
|
+
"content.parts.function_response.response"
|
|
91
|
+
];
|
|
92
|
+
function transformToCamelCaseEvent(event) {
|
|
93
|
+
return toCamelCase(event, PRESERVE_KEYS_SNAKE_CASE);
|
|
94
|
+
}
|
|
95
|
+
function transformToSnakeCaseEvent(event) {
|
|
96
|
+
return toSnakeCase(event, PRESERVE_KEYS_CAMEL_CASE);
|
|
97
|
+
}
|
|
75
98
|
export {
|
|
76
99
|
createEvent,
|
|
77
100
|
createNewEventId,
|
|
@@ -79,5 +102,7 @@ export {
|
|
|
79
102
|
getFunctionResponses,
|
|
80
103
|
hasTrailingCodeExecutionResult,
|
|
81
104
|
isFinalResponse,
|
|
82
|
-
stringifyContent
|
|
105
|
+
stringifyContent,
|
|
106
|
+
transformToCamelCaseEvent,
|
|
107
|
+
transformToSnakeCaseEvent
|
|
83
108
|
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { isEmpty } from "lodash-es";
|
|
7
|
+
import { isFinalResponse } from "./event.js";
|
|
8
|
+
var EventType = /* @__PURE__ */ ((EventType2) => {
|
|
9
|
+
EventType2["THOUGHT"] = "thought";
|
|
10
|
+
EventType2["CONTENT"] = "content";
|
|
11
|
+
EventType2["TOOL_CALL"] = "tool_call";
|
|
12
|
+
EventType2["TOOL_RESULT"] = "tool_result";
|
|
13
|
+
EventType2["CALL_CODE"] = "call_code";
|
|
14
|
+
EventType2["CODE_RESULT"] = "code_result";
|
|
15
|
+
EventType2["ERROR"] = "error";
|
|
16
|
+
EventType2["ACTIVITY"] = "activity";
|
|
17
|
+
EventType2["TOOL_CONFIRMATION"] = "tool_confirmation";
|
|
18
|
+
EventType2["FINISHED"] = "finished";
|
|
19
|
+
return EventType2;
|
|
20
|
+
})(EventType || {});
|
|
21
|
+
function toStructuredEvents(event) {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
const structuredEvents = [];
|
|
24
|
+
if (event.errorCode) {
|
|
25
|
+
structuredEvents.push({
|
|
26
|
+
type: "error" /* ERROR */,
|
|
27
|
+
error: new Error(event.errorMessage || event.errorCode)
|
|
28
|
+
});
|
|
29
|
+
return structuredEvents;
|
|
30
|
+
}
|
|
31
|
+
for (const part of (_b = (_a = event.content) == null ? void 0 : _a.parts) != null ? _b : []) {
|
|
32
|
+
if (part.functionCall && !isEmpty(part.functionCall)) {
|
|
33
|
+
structuredEvents.push({
|
|
34
|
+
type: "tool_call" /* TOOL_CALL */,
|
|
35
|
+
call: part.functionCall
|
|
36
|
+
});
|
|
37
|
+
} else if (part.functionResponse && !isEmpty(part.functionResponse)) {
|
|
38
|
+
structuredEvents.push({
|
|
39
|
+
type: "tool_result" /* TOOL_RESULT */,
|
|
40
|
+
result: part.functionResponse
|
|
41
|
+
});
|
|
42
|
+
} else if (part.executableCode && !isEmpty(part.executableCode)) {
|
|
43
|
+
structuredEvents.push({
|
|
44
|
+
type: "call_code" /* CALL_CODE */,
|
|
45
|
+
code: part.executableCode
|
|
46
|
+
});
|
|
47
|
+
} else if (part.codeExecutionResult && !isEmpty(part.codeExecutionResult)) {
|
|
48
|
+
structuredEvents.push({
|
|
49
|
+
type: "code_result" /* CODE_RESULT */,
|
|
50
|
+
result: part.codeExecutionResult
|
|
51
|
+
});
|
|
52
|
+
} else if (part.text) {
|
|
53
|
+
if (part.thought) {
|
|
54
|
+
structuredEvents.push({ type: "thought" /* THOUGHT */, content: part.text });
|
|
55
|
+
} else {
|
|
56
|
+
structuredEvents.push({ type: "content" /* CONTENT */, content: part.text });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (event.actions.requestedToolConfirmations && !isEmpty(event.actions.requestedToolConfirmations)) {
|
|
61
|
+
structuredEvents.push({
|
|
62
|
+
type: "tool_confirmation" /* TOOL_CONFIRMATION */,
|
|
63
|
+
confirmations: event.actions.requestedToolConfirmations
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (isFinalResponse(event)) {
|
|
67
|
+
structuredEvents.push({ type: "finished" /* FINISHED */, output: void 0 });
|
|
68
|
+
}
|
|
69
|
+
return structuredEvents;
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
EventType,
|
|
73
|
+
toStructuredEvents
|
|
74
|
+
};
|