@google/adk 0.3.0 → 0.5.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/a2a_event.js +290 -0
- package/dist/cjs/a2a/event_converter_utils.js +201 -0
- package/dist/cjs/a2a/executor_context.js +53 -0
- package/dist/cjs/a2a/metadata_converter_utils.js +125 -0
- package/dist/cjs/a2a/part_converter_utils.js +212 -0
- package/dist/cjs/agents/active_streaming_tool.js +1 -1
- package/dist/cjs/agents/base_agent.js +6 -6
- package/dist/cjs/agents/content_processor_utils.js +1 -1
- package/dist/cjs/{tools/tool_context.js → agents/context.js} +71 -16
- package/dist/cjs/agents/functions.js +4 -3
- 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 +76 -711
- package/dist/cjs/agents/loop_agent.js +1 -1
- package/dist/cjs/agents/parallel_agent.js +1 -1
- package/dist/cjs/agents/processors/agent_transfer_llm_request_processor.js +132 -0
- package/dist/cjs/agents/{base_llm_processor.js → processors/base_llm_processor.js} +1 -1
- package/dist/cjs/agents/processors/basic_llm_request_processor.js +68 -0
- package/dist/cjs/agents/processors/code_execution_request_processor.js +389 -0
- package/dist/cjs/agents/processors/content_request_processor.js +66 -0
- package/dist/cjs/agents/processors/identity_llm_request_processor.js +54 -0
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +85 -0
- package/dist/cjs/agents/processors/request_confirmation_llm_request_processor.js +165 -0
- 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 +127 -48
- package/dist/cjs/artifacts/in_memory_artifact_service.js +54 -6
- package/dist/cjs/artifacts/registry.js +55 -0
- package/dist/cjs/auth/auth_credential.js +1 -1
- package/dist/cjs/auth/auth_handler.js +1 -1
- 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 +1 -1
- package/dist/cjs/code_executors/built_in_code_executor.js +1 -1
- package/dist/cjs/code_executors/code_execution_utils.js +1 -1
- package/dist/cjs/code_executors/code_executor_context.js +1 -1
- package/dist/cjs/common.js +25 -8
- package/dist/cjs/events/event.js +33 -4
- 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 +24 -17
- package/dist/cjs/index.js.map +4 -4
- 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 +1 -1
- 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 +1 -1
- package/dist/cjs/models/base_llm_connection.js +1 -1
- package/dist/cjs/models/gemini_llm_connection.js +1 -1
- package/dist/cjs/models/google_llm.js +70 -51
- package/dist/cjs/models/llm_request.js +1 -1
- package/dist/cjs/models/llm_response.js +3 -1
- package/dist/cjs/models/registry.js +3 -1
- package/dist/cjs/plugins/base_plugin.js +2 -2
- package/dist/cjs/plugins/logging_plugin.js +1 -1
- package/dist/cjs/plugins/plugin_manager.js +1 -1
- package/dist/cjs/plugins/security_plugin.js +1 -1
- package/dist/cjs/runner/in_memory_runner.js +1 -1
- package/dist/cjs/runner/runner.js +33 -2
- package/dist/cjs/sessions/base_session_service.js +53 -3
- package/dist/cjs/sessions/database_session_service.js +367 -0
- package/dist/cjs/sessions/db/operations.js +126 -0
- package/dist/cjs/sessions/db/schema.js +204 -0
- package/dist/cjs/sessions/in_memory_session_service.js +24 -22
- 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 +1 -1
- package/dist/cjs/telemetry/setup.js +1 -1
- package/dist/cjs/telemetry/tracing.js +1 -1
- package/dist/cjs/tools/agent_tool.js +1 -1
- package/dist/cjs/tools/base_tool.js +4 -1
- package/dist/cjs/tools/base_toolset.js +14 -4
- package/dist/cjs/tools/exit_loop_tool.js +63 -0
- package/dist/cjs/tools/forwarding_artifact_service.js +17 -1
- package/dist/cjs/tools/function_tool.js +1 -1
- package/dist/cjs/tools/google_search_tool.js +1 -1
- package/dist/cjs/tools/long_running_tool.js +1 -1
- package/dist/cjs/tools/mcp/mcp_session_manager.js +1 -1
- package/dist/cjs/tools/mcp/mcp_tool.js +1 -1
- package/dist/cjs/tools/mcp/mcp_toolset.js +10 -6
- package/dist/cjs/tools/tool_confirmation.js +1 -1
- package/dist/cjs/utils/client_labels.js +1 -1
- package/dist/cjs/utils/env_aware_utils.js +10 -1
- package/dist/cjs/utils/gemini_schema_util.js +1 -1
- package/dist/cjs/utils/logger.js +62 -55
- 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 +1 -1
- package/dist/cjs/utils/variant_utils.js +3 -9
- package/dist/cjs/version.js +2 -2
- package/dist/esm/a2a/a2a_event.js +243 -0
- package/dist/esm/a2a/event_converter_utils.js +187 -0
- package/dist/esm/a2a/executor_context.js +23 -0
- package/dist/esm/a2a/metadata_converter_utils.js +90 -0
- package/dist/esm/a2a/part_converter_utils.js +175 -0
- package/dist/esm/agents/base_agent.js +5 -5
- package/dist/esm/{tools/tool_context.js → agents/context.js} +66 -11
- package/dist/esm/agents/functions.js +3 -2
- package/dist/esm/agents/llm_agent.js +69 -720
- package/dist/esm/agents/processors/agent_transfer_llm_request_processor.js +101 -0
- package/dist/esm/agents/processors/basic_llm_request_processor.js +37 -0
- package/dist/esm/agents/processors/code_execution_request_processor.js +363 -0
- package/dist/esm/agents/processors/content_request_processor.js +38 -0
- package/dist/esm/agents/processors/identity_llm_request_processor.js +23 -0
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +54 -0
- package/dist/esm/agents/processors/request_confirmation_llm_request_processor.js +140 -0
- 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 +126 -47
- package/dist/esm/artifacts/in_memory_artifact_service.js +51 -4
- package/dist/esm/artifacts/registry.js +28 -0
- package/dist/esm/common.js +20 -10
- package/dist/esm/events/event.js +29 -2
- package/dist/esm/events/event_actions.js +1 -1
- package/dist/esm/events/structured_events.js +74 -0
- package/dist/esm/index.js +24 -17
- package/dist/esm/index.js.map +4 -4
- package/dist/esm/models/apigee_llm.js +152 -0
- package/dist/esm/models/google_llm.js +67 -49
- package/dist/esm/models/llm_response.js +2 -0
- package/dist/esm/models/registry.js +2 -0
- package/dist/esm/plugins/base_plugin.js +1 -1
- package/dist/esm/runner/runner.js +32 -1
- package/dist/esm/sessions/base_session_service.js +49 -1
- package/dist/esm/sessions/database_session_service.js +353 -0
- package/dist/esm/sessions/db/operations.js +111 -0
- package/dist/esm/sessions/db/schema.js +172 -0
- package/dist/esm/sessions/in_memory_session_service.js +23 -21
- package/dist/esm/sessions/registry.js +25 -0
- package/dist/esm/tools/base_tool.js +3 -0
- package/dist/esm/tools/base_toolset.js +11 -2
- package/dist/esm/tools/exit_loop_tool.js +32 -0
- package/dist/esm/tools/forwarding_artifact_service.js +16 -0
- package/dist/esm/tools/mcp/mcp_toolset.js +9 -5
- package/dist/esm/utils/env_aware_utils.js +8 -0
- package/dist/esm/utils/logger.js +51 -54
- package/dist/esm/utils/object_notation_utils.js +47 -0
- package/dist/esm/utils/variant_utils.js +1 -7
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/a2a_event.d.ts +122 -0
- package/dist/types/a2a/event_converter_utils.d.ts +20 -0
- package/dist/types/a2a/executor_context.d.ts +33 -0
- package/dist/types/a2a/metadata_converter_utils.d.ts +62 -0
- package/dist/types/a2a/part_converter_utils.d.ts +48 -0
- package/dist/types/agents/base_agent.d.ts +2 -2
- package/dist/types/{tools/tool_context.d.ts → agents/context.d.ts} +43 -8
- package/dist/types/agents/llm_agent.d.ts +19 -42
- package/dist/types/agents/processors/agent_transfer_llm_request_processor.d.ts +18 -0
- package/dist/types/agents/{base_llm_processor.d.ts → processors/base_llm_processor.d.ts} +4 -4
- package/dist/types/agents/processors/basic_llm_request_processor.d.ts +13 -0
- package/dist/types/agents/processors/code_execution_request_processor.d.ts +34 -0
- package/dist/types/agents/processors/content_request_processor.d.ts +13 -0
- package/dist/types/agents/processors/identity_llm_request_processor.d.ts +13 -0
- package/dist/types/agents/processors/instructions_llm_request_processor.d.ts +16 -0
- package/dist/types/agents/processors/request_confirmation_llm_request_processor.d.ts +13 -0
- 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 +5 -2
- package/dist/types/artifacts/registry.d.ts +7 -0
- package/dist/types/auth/credential_service/base_credential_service.d.ts +3 -3
- package/dist/types/auth/credential_service/in_memory_credential_service.d.ts +3 -3
- package/dist/types/common.d.ts +15 -6
- 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 +5 -1
- package/dist/types/models/apigee_llm.d.ts +59 -0
- package/dist/types/models/google_llm.d.ts +5 -2
- package/dist/types/models/llm_response.d.ts +5 -1
- package/dist/types/plugins/base_plugin.d.ts +12 -13
- package/dist/types/plugins/logging_plugin.d.ts +9 -10
- package/dist/types/plugins/plugin_manager.d.ts +9 -10
- package/dist/types/plugins/security_plugin.d.ts +2 -2
- package/dist/types/runner/runner.d.ts +15 -0
- package/dist/types/sessions/base_session_service.d.ts +20 -0
- package/dist/types/sessions/database_session_service.d.ts +32 -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 +4 -1
- package/dist/types/sessions/registry.d.ts +7 -0
- package/dist/types/tools/base_tool.d.ts +3 -3
- package/dist/types/tools/base_toolset.d.ts +12 -3
- package/dist/types/tools/exit_loop_tool.d.ts +24 -0
- package/dist/types/tools/forwarding_artifact_service.d.ts +5 -3
- package/dist/types/tools/function_tool.d.ts +2 -2
- package/dist/types/tools/mcp/mcp_toolset.d.ts +1 -1
- package/dist/types/utils/env_aware_utils.d.ts +7 -0
- package/dist/types/utils/logger.d.ts +5 -9
- package/dist/types/utils/object_notation_utils.d.ts +21 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/web/a2a/a2a_event.js +243 -0
- package/dist/web/a2a/event_converter_utils.js +201 -0
- package/dist/web/a2a/executor_context.js +23 -0
- package/dist/web/a2a/metadata_converter_utils.js +107 -0
- package/dist/web/a2a/part_converter_utils.js +175 -0
- package/dist/web/agents/base_agent.js +5 -5
- package/dist/web/{tools/tool_context.js → agents/context.js} +66 -11
- package/dist/web/agents/functions.js +3 -2
- package/dist/web/agents/llm_agent.js +90 -717
- package/dist/web/agents/processors/agent_transfer_llm_request_processor.js +100 -0
- package/dist/web/agents/processors/basic_llm_request_processor.js +71 -0
- package/dist/web/agents/processors/code_execution_request_processor.js +365 -0
- package/dist/web/agents/processors/content_request_processor.js +56 -0
- package/dist/web/agents/processors/identity_llm_request_processor.js +41 -0
- package/dist/web/agents/processors/instructions_llm_request_processor.js +72 -0
- package/dist/web/agents/processors/request_confirmation_llm_request_processor.js +158 -0
- 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 +123 -46
- package/dist/web/artifacts/in_memory_artifact_service.js +51 -4
- package/dist/web/artifacts/registry.js +28 -0
- package/dist/web/common.js +20 -10
- package/dist/web/events/event.js +29 -2
- package/dist/web/events/event_actions.js +1 -1
- package/dist/web/events/structured_events.js +74 -0
- package/dist/web/index.js +7 -2
- package/dist/web/index.js.map +4 -4
- package/dist/web/models/apigee_llm.js +219 -0
- package/dist/web/models/google_llm.js +67 -46
- package/dist/web/models/llm_response.js +2 -0
- package/dist/web/models/registry.js +2 -0
- package/dist/web/plugins/base_plugin.js +1 -1
- package/dist/web/runner/runner.js +34 -1
- package/dist/web/sessions/base_session_service.js +49 -1
- package/dist/web/sessions/database_session_service.js +371 -0
- package/dist/web/sessions/db/operations.js +111 -0
- package/dist/web/sessions/db/schema.js +172 -0
- package/dist/web/sessions/in_memory_session_service.js +23 -21
- package/dist/web/sessions/registry.js +25 -0
- package/dist/web/tools/base_tool.js +3 -0
- package/dist/web/tools/base_toolset.js +11 -2
- package/dist/web/tools/exit_loop_tool.js +32 -0
- package/dist/web/tools/forwarding_artifact_service.js +16 -0
- package/dist/web/tools/mcp/mcp_toolset.js +27 -5
- package/dist/web/utils/env_aware_utils.js +8 -0
- package/dist/web/utils/logger.js +51 -54
- package/dist/web/utils/object_notation_utils.js +47 -0
- package/dist/web/utils/variant_utils.js +1 -7
- package/dist/web/version.js +1 -1
- package/package.json +13 -3
- package/dist/cjs/agents/callback_context.js +0 -101
- package/dist/esm/agents/callback_context.js +0 -71
- package/dist/types/agents/callback_context.d.ts +0 -42
- package/dist/web/agents/callback_context.js +0 -71
- /package/dist/esm/agents/{base_llm_processor.js → processors/base_llm_processor.js} +0 -0
- /package/dist/web/agents/{base_llm_processor.js → processors/base_llm_processor.js} +0 -0
|
@@ -7,10 +7,14 @@ import { cloneDeep } from "lodash-es";
|
|
|
7
7
|
import { randomUUID } from "../utils/env_aware_utils.js";
|
|
8
8
|
import { logger } from "../utils/logger.js";
|
|
9
9
|
import {
|
|
10
|
-
BaseSessionService
|
|
10
|
+
BaseSessionService,
|
|
11
|
+
mergeStates
|
|
11
12
|
} from "./base_session_service.js";
|
|
12
13
|
import { createSession } from "./session.js";
|
|
13
14
|
import { State } from "./state.js";
|
|
15
|
+
function isInMemoryConnectionString(uri) {
|
|
16
|
+
return uri === "memory://";
|
|
17
|
+
}
|
|
14
18
|
class InMemorySessionService extends BaseSessionService {
|
|
15
19
|
constructor() {
|
|
16
20
|
super(...arguments);
|
|
@@ -28,12 +32,13 @@ class InMemorySessionService extends BaseSessionService {
|
|
|
28
32
|
*/
|
|
29
33
|
this.appState = {};
|
|
30
34
|
}
|
|
31
|
-
createSession({
|
|
35
|
+
async createSession({
|
|
32
36
|
appName,
|
|
33
37
|
userId,
|
|
34
38
|
state,
|
|
35
39
|
sessionId
|
|
36
40
|
}) {
|
|
41
|
+
var _a;
|
|
37
42
|
const session = createSession({
|
|
38
43
|
id: sessionId || randomUUID(),
|
|
39
44
|
appName,
|
|
@@ -49,16 +54,21 @@ class InMemorySessionService extends BaseSessionService {
|
|
|
49
54
|
this.sessions[appName][userId] = {};
|
|
50
55
|
}
|
|
51
56
|
this.sessions[appName][userId][session.id] = session;
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
const copiedSession = cloneDeep(session);
|
|
58
|
+
copiedSession.state = mergeStates(
|
|
59
|
+
this.appState[appName],
|
|
60
|
+
(_a = this.userState[appName]) == null ? void 0 : _a[userId],
|
|
61
|
+
copiedSession.state
|
|
54
62
|
);
|
|
63
|
+
return copiedSession;
|
|
55
64
|
}
|
|
56
|
-
getSession({
|
|
65
|
+
async getSession({
|
|
57
66
|
appName,
|
|
58
67
|
userId,
|
|
59
68
|
sessionId,
|
|
60
69
|
config
|
|
61
70
|
}) {
|
|
71
|
+
var _a;
|
|
62
72
|
if (!this.sessions[appName] || !this.sessions[appName][userId] || !this.sessions[appName][userId][sessionId]) {
|
|
63
73
|
return Promise.resolve(void 0);
|
|
64
74
|
}
|
|
@@ -83,7 +93,12 @@ class InMemorySessionService extends BaseSessionService {
|
|
|
83
93
|
}
|
|
84
94
|
}
|
|
85
95
|
}
|
|
86
|
-
|
|
96
|
+
copiedSession.state = mergeStates(
|
|
97
|
+
this.appState[appName],
|
|
98
|
+
(_a = this.userState[appName]) == null ? void 0 : _a[userId],
|
|
99
|
+
copiedSession.state
|
|
100
|
+
);
|
|
101
|
+
return copiedSession;
|
|
87
102
|
}
|
|
88
103
|
listSessions({
|
|
89
104
|
appName,
|
|
@@ -160,21 +175,8 @@ class InMemorySessionService extends BaseSessionService {
|
|
|
160
175
|
storageSession.lastUpdateTime = event.timestamp;
|
|
161
176
|
return event;
|
|
162
177
|
}
|
|
163
|
-
mergeState(appName, userId, copiedSession) {
|
|
164
|
-
if (this.appState[appName]) {
|
|
165
|
-
for (const key of Object.keys(this.appState[appName])) {
|
|
166
|
-
copiedSession.state[State.APP_PREFIX + key] = this.appState[appName][key];
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
if (!this.userState[appName] || !this.userState[appName][userId]) {
|
|
170
|
-
return copiedSession;
|
|
171
|
-
}
|
|
172
|
-
for (const key of Object.keys(this.userState[appName][userId])) {
|
|
173
|
-
copiedSession.state[State.USER_PREFIX + key] = this.userState[appName][userId][key];
|
|
174
|
-
}
|
|
175
|
-
return copiedSession;
|
|
176
|
-
}
|
|
177
178
|
}
|
|
178
179
|
export {
|
|
179
|
-
InMemorySessionService
|
|
180
|
+
InMemorySessionService,
|
|
181
|
+
isInMemoryConnectionString
|
|
180
182
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import {
|
|
7
|
+
DatabaseSessionService,
|
|
8
|
+
isDatabaseConnectionString
|
|
9
|
+
} from "./database_session_service.js";
|
|
10
|
+
import {
|
|
11
|
+
InMemorySessionService,
|
|
12
|
+
isInMemoryConnectionString
|
|
13
|
+
} from "./in_memory_session_service.js";
|
|
14
|
+
function getSessionServiceFromUri(uri) {
|
|
15
|
+
if (isInMemoryConnectionString(uri)) {
|
|
16
|
+
return new InMemorySessionService();
|
|
17
|
+
}
|
|
18
|
+
if (isDatabaseConnectionString(uri)) {
|
|
19
|
+
return new DatabaseSessionService(uri);
|
|
20
|
+
}
|
|
21
|
+
throw new Error(`Unsupported session service URI: ${uri}`);
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
getSessionServiceFromUri
|
|
25
|
+
};
|
|
@@ -54,6 +54,9 @@ class BaseTool {
|
|
|
54
54
|
if (!functionDeclaration) {
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
|
+
if (this.name in llmRequest.toolsDict) {
|
|
58
|
+
throw new Error(`Duplicate tool name: ${this.name}`);
|
|
59
|
+
}
|
|
57
60
|
llmRequest.toolsDict[this.name] = this;
|
|
58
61
|
const tool = findToolWithFunctionDeclarations(llmRequest);
|
|
59
62
|
if (tool) {
|
|
@@ -3,9 +3,17 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
var _a;
|
|
7
|
+
const BASE_TOOLSET_SIGNATURE_SYMBOL = Symbol.for("google.adk.baseToolset");
|
|
8
|
+
function isBaseToolset(obj) {
|
|
9
|
+
return typeof obj === "object" && obj !== null && BASE_TOOLSET_SIGNATURE_SYMBOL in obj && obj[BASE_TOOLSET_SIGNATURE_SYMBOL] === true;
|
|
10
|
+
}
|
|
11
|
+
_a = BASE_TOOLSET_SIGNATURE_SYMBOL;
|
|
6
12
|
class BaseToolset {
|
|
7
|
-
constructor(toolFilter) {
|
|
13
|
+
constructor(toolFilter, prefix) {
|
|
8
14
|
this.toolFilter = toolFilter;
|
|
15
|
+
this.prefix = prefix;
|
|
16
|
+
this[_a] = true;
|
|
9
17
|
}
|
|
10
18
|
/**
|
|
11
19
|
* Returns whether the tool should be exposed to LLM.
|
|
@@ -42,5 +50,6 @@ class BaseToolset {
|
|
|
42
50
|
}
|
|
43
51
|
}
|
|
44
52
|
export {
|
|
45
|
-
BaseToolset
|
|
53
|
+
BaseToolset,
|
|
54
|
+
isBaseToolset
|
|
46
55
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { BaseTool } from "./base_tool.js";
|
|
7
|
+
class ExitLoopTool extends BaseTool {
|
|
8
|
+
constructor() {
|
|
9
|
+
super({
|
|
10
|
+
name: "exit_loop",
|
|
11
|
+
description: "Exits the loop.\n\nCall this function only when you are instructed to do so."
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
_getDeclaration() {
|
|
15
|
+
return {
|
|
16
|
+
name: this.name,
|
|
17
|
+
description: this.description
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
async runAsync({
|
|
21
|
+
toolContext
|
|
22
|
+
}) {
|
|
23
|
+
toolContext.actions.escalate = true;
|
|
24
|
+
toolContext.actions.skipSummarization = true;
|
|
25
|
+
return "";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const EXIT_LOOP = new ExitLoopTool();
|
|
29
|
+
export {
|
|
30
|
+
EXIT_LOOP,
|
|
31
|
+
ExitLoopTool
|
|
32
|
+
};
|
|
@@ -35,6 +35,22 @@ class ForwardingArtifactService {
|
|
|
35
35
|
request
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
|
+
listArtifactVersions(request) {
|
|
39
|
+
if (!this.toolContext.invocationContext.artifactService) {
|
|
40
|
+
throw new Error("Artifact service is not initialized.");
|
|
41
|
+
}
|
|
42
|
+
return this.toolContext.invocationContext.artifactService.listArtifactVersions(
|
|
43
|
+
request
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
getArtifactVersion(request) {
|
|
47
|
+
if (!this.toolContext.invocationContext.artifactService) {
|
|
48
|
+
throw new Error("Artifact service is not initialized.");
|
|
49
|
+
}
|
|
50
|
+
return this.toolContext.invocationContext.artifactService.getArtifactVersion(
|
|
51
|
+
request
|
|
52
|
+
);
|
|
53
|
+
}
|
|
38
54
|
}
|
|
39
55
|
export {
|
|
40
56
|
ForwardingArtifactService
|
|
@@ -8,8 +8,8 @@ import { BaseToolset } from "../base_toolset.js";
|
|
|
8
8
|
import { MCPSessionManager } from "./mcp_session_manager.js";
|
|
9
9
|
import { MCPTool } from "./mcp_tool.js";
|
|
10
10
|
class MCPToolset extends BaseToolset {
|
|
11
|
-
constructor(connectionParams, toolFilter = []) {
|
|
12
|
-
super(toolFilter);
|
|
11
|
+
constructor(connectionParams, toolFilter = [], prefix) {
|
|
12
|
+
super(toolFilter, prefix);
|
|
13
13
|
this.mcpSessionManager = new MCPSessionManager(connectionParams);
|
|
14
14
|
}
|
|
15
15
|
async getTools() {
|
|
@@ -19,9 +19,13 @@ class MCPToolset extends BaseToolset {
|
|
|
19
19
|
for (const tool of listResult.tools) {
|
|
20
20
|
logger.debug(`tool: ${tool.name}`);
|
|
21
21
|
}
|
|
22
|
-
return listResult.tools.map(
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
return listResult.tools.map((tool) => {
|
|
23
|
+
const toolWithPrefix = {
|
|
24
|
+
...tool,
|
|
25
|
+
name: this.prefix ? `${this.prefix}_${tool.name}` : tool.name
|
|
26
|
+
};
|
|
27
|
+
return new MCPTool(toolWithPrefix, this.mcpSessionManager);
|
|
28
|
+
});
|
|
25
29
|
}
|
|
26
30
|
async close() {
|
|
27
31
|
}
|
|
@@ -40,9 +40,17 @@ function isBase64Encoded(data) {
|
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
function getBooleanEnvVar(envVar) {
|
|
44
|
+
if (!process.env) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
const envVarValue = (process.env[envVar] || "").toLowerCase();
|
|
48
|
+
return ["true", "1"].includes(envVarValue);
|
|
49
|
+
}
|
|
43
50
|
export {
|
|
44
51
|
base64Decode,
|
|
45
52
|
base64Encode,
|
|
53
|
+
getBooleanEnvVar,
|
|
46
54
|
isBase64Encoded,
|
|
47
55
|
isBrowser,
|
|
48
56
|
randomUUID
|
package/dist/esm/utils/logger.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
import * as winston from "winston";
|
|
6
7
|
var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
7
8
|
LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
|
|
8
9
|
LogLevel2[LogLevel2["INFO"] = 1] = "INFO";
|
|
@@ -10,58 +11,68 @@ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
|
10
11
|
LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";
|
|
11
12
|
return LogLevel2;
|
|
12
13
|
})(LogLevel || {});
|
|
13
|
-
let logLevel = 1 /* INFO */;
|
|
14
|
-
function setLogLevel(level) {
|
|
15
|
-
logLevel = level;
|
|
16
|
-
}
|
|
17
14
|
class SimpleLogger {
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
constructor() {
|
|
16
|
+
this.logLevel = 1 /* INFO */;
|
|
17
|
+
this.logger = winston.createLogger({
|
|
18
|
+
levels: {
|
|
19
|
+
"debug": 0 /* DEBUG */,
|
|
20
|
+
"info": 1 /* INFO */,
|
|
21
|
+
"warn": 2 /* WARN */,
|
|
22
|
+
"error": 3 /* ERROR */
|
|
23
|
+
},
|
|
24
|
+
format: winston.format.combine(
|
|
25
|
+
winston.format.label({ label: "ADK" }),
|
|
26
|
+
winston.format((info) => {
|
|
27
|
+
info.level = info.level.toUpperCase();
|
|
28
|
+
return info;
|
|
29
|
+
})(),
|
|
30
|
+
winston.format.colorize(),
|
|
31
|
+
winston.format.timestamp(),
|
|
32
|
+
winston.format.printf((info) => {
|
|
33
|
+
return `${info.level}: [${info.label}] ${info.timestamp} ${info.message}`;
|
|
34
|
+
})
|
|
35
|
+
),
|
|
36
|
+
transports: [new winston.transports.Console()]
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
setLogLevel(level) {
|
|
40
|
+
this.logLevel = level;
|
|
41
|
+
}
|
|
42
|
+
log(level, ...messages) {
|
|
43
|
+
if (this.logLevel > level) {
|
|
20
44
|
return;
|
|
21
45
|
}
|
|
22
|
-
|
|
23
|
-
case 0 /* DEBUG */:
|
|
24
|
-
this.debug(...args);
|
|
25
|
-
break;
|
|
26
|
-
case 1 /* INFO */:
|
|
27
|
-
this.info(...args);
|
|
28
|
-
break;
|
|
29
|
-
case 2 /* WARN */:
|
|
30
|
-
this.warn(...args);
|
|
31
|
-
break;
|
|
32
|
-
case 3 /* ERROR */:
|
|
33
|
-
this.error(...args);
|
|
34
|
-
break;
|
|
35
|
-
default:
|
|
36
|
-
throw new Error(`Unsupported log level: ${level}`);
|
|
37
|
-
}
|
|
46
|
+
this.logger.log(level.toString(), messages.join(" "));
|
|
38
47
|
}
|
|
39
|
-
debug(...
|
|
40
|
-
if (logLevel > 0 /* DEBUG */) {
|
|
48
|
+
debug(...messages) {
|
|
49
|
+
if (this.logLevel > 0 /* DEBUG */) {
|
|
41
50
|
return;
|
|
42
51
|
}
|
|
43
|
-
|
|
52
|
+
this.logger.debug(messages.join(" "));
|
|
44
53
|
}
|
|
45
|
-
info(...
|
|
46
|
-
if (logLevel > 1 /* INFO */) {
|
|
54
|
+
info(...messages) {
|
|
55
|
+
if (this.logLevel > 1 /* INFO */) {
|
|
47
56
|
return;
|
|
48
57
|
}
|
|
49
|
-
|
|
58
|
+
this.logger.info(messages.join(" "));
|
|
50
59
|
}
|
|
51
|
-
warn(...
|
|
52
|
-
if (logLevel > 2 /* WARN */) {
|
|
60
|
+
warn(...messages) {
|
|
61
|
+
if (this.logLevel > 2 /* WARN */) {
|
|
53
62
|
return;
|
|
54
63
|
}
|
|
55
|
-
|
|
64
|
+
this.logger.warn(messages.join(" "));
|
|
56
65
|
}
|
|
57
|
-
error(...
|
|
58
|
-
if (logLevel > 3 /* ERROR */) {
|
|
66
|
+
error(...messages) {
|
|
67
|
+
if (this.logLevel > 3 /* ERROR */) {
|
|
59
68
|
return;
|
|
60
69
|
}
|
|
61
|
-
|
|
70
|
+
this.logger.error(messages.join(" "));
|
|
62
71
|
}
|
|
63
72
|
}
|
|
64
73
|
class NoOpLogger {
|
|
74
|
+
setLogLevel(_level) {
|
|
75
|
+
}
|
|
65
76
|
log(_level, ..._args) {
|
|
66
77
|
}
|
|
67
78
|
debug(..._args) {
|
|
@@ -73,26 +84,6 @@ class NoOpLogger {
|
|
|
73
84
|
error(..._args) {
|
|
74
85
|
}
|
|
75
86
|
}
|
|
76
|
-
const LOG_LEVEL_STR = {
|
|
77
|
-
[0 /* DEBUG */]: "DEBUG",
|
|
78
|
-
[1 /* INFO */]: "INFO",
|
|
79
|
-
[2 /* WARN */]: "WARN",
|
|
80
|
-
[3 /* ERROR */]: "ERROR"
|
|
81
|
-
};
|
|
82
|
-
const CONSOLE_COLOR_MAP = {
|
|
83
|
-
[0 /* DEBUG */]: "\x1B[34m",
|
|
84
|
-
// Blue
|
|
85
|
-
[1 /* INFO */]: "\x1B[32m",
|
|
86
|
-
// Green
|
|
87
|
-
[2 /* WARN */]: "\x1B[33m",
|
|
88
|
-
// Yellow
|
|
89
|
-
[3 /* ERROR */]: "\x1B[31m"
|
|
90
|
-
// Red
|
|
91
|
-
};
|
|
92
|
-
const RESET_COLOR = "\x1B[0m";
|
|
93
|
-
function getColoredPrefix(level) {
|
|
94
|
-
return `${CONSOLE_COLOR_MAP[level]}[ADK ${LOG_LEVEL_STR[level]}]:${RESET_COLOR}`;
|
|
95
|
-
}
|
|
96
87
|
let currentLogger = new SimpleLogger();
|
|
97
88
|
function setLogger(customLogger) {
|
|
98
89
|
currentLogger = customLogger != null ? customLogger : new NoOpLogger();
|
|
@@ -103,7 +94,13 @@ function getLogger() {
|
|
|
103
94
|
function resetLogger() {
|
|
104
95
|
currentLogger = new SimpleLogger();
|
|
105
96
|
}
|
|
97
|
+
function setLogLevel(level) {
|
|
98
|
+
logger.setLogLevel(level);
|
|
99
|
+
}
|
|
106
100
|
const logger = {
|
|
101
|
+
setLogLevel(level) {
|
|
102
|
+
currentLogger.setLogLevel(level);
|
|
103
|
+
},
|
|
107
104
|
log(level, ...args) {
|
|
108
105
|
currentLogger.log(level, ...args);
|
|
109
106
|
},
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
function toCamelCase(obj, preserveKeys = []) {
|
|
7
|
+
return toNotation(obj, toCamelCaseKey, "", preserveKeys);
|
|
8
|
+
}
|
|
9
|
+
function toSnakeCase(obj, preserveKeys = []) {
|
|
10
|
+
return toNotation(obj, toSnakeCaseKey, "", preserveKeys);
|
|
11
|
+
}
|
|
12
|
+
const toCamelCaseKey = (key) => key.replace(
|
|
13
|
+
/_([a-z])/g,
|
|
14
|
+
(_match, letter) => letter.toUpperCase()
|
|
15
|
+
);
|
|
16
|
+
const toSnakeCaseKey = (key) => key.replace(/[A-Z]/g, (g) => "_" + g.toLowerCase());
|
|
17
|
+
function toNotation(obj, converter, parentKey = "", preserveKeys = []) {
|
|
18
|
+
if (Array.isArray(obj)) {
|
|
19
|
+
return obj.map(
|
|
20
|
+
(item) => toNotation(item, converter, parentKey, preserveKeys)
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
if (typeof obj === "object" && obj !== null) {
|
|
24
|
+
const source = obj;
|
|
25
|
+
const result = {};
|
|
26
|
+
for (const key of Object.keys(source)) {
|
|
27
|
+
const convertedKey = converter(key);
|
|
28
|
+
const fullPath = parentKey !== "" ? parentKey + "." + key : key;
|
|
29
|
+
if (preserveKeys.includes(fullPath)) {
|
|
30
|
+
result[convertedKey] = source[key];
|
|
31
|
+
} else {
|
|
32
|
+
result[convertedKey] = toNotation(
|
|
33
|
+
source[key],
|
|
34
|
+
converter,
|
|
35
|
+
fullPath,
|
|
36
|
+
preserveKeys
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
return obj;
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
toCamelCase,
|
|
46
|
+
toSnakeCase
|
|
47
|
+
};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
import { getBooleanEnvVar } from "./env_aware_utils.js";
|
|
6
7
|
var GoogleLLMVariant = /* @__PURE__ */ ((GoogleLLMVariant2) => {
|
|
7
8
|
GoogleLLMVariant2["VERTEX_AI"] = "VERTEX_AI";
|
|
8
9
|
GoogleLLMVariant2["GEMINI_API"] = "GEMINI_API";
|
|
@@ -11,13 +12,6 @@ var GoogleLLMVariant = /* @__PURE__ */ ((GoogleLLMVariant2) => {
|
|
|
11
12
|
function getGoogleLlmVariant() {
|
|
12
13
|
return getBooleanEnvVar("GOOGLE_GENAI_USE_VERTEXAI") ? "VERTEX_AI" /* VERTEX_AI */ : "GEMINI_API" /* GEMINI_API */;
|
|
13
14
|
}
|
|
14
|
-
function getBooleanEnvVar(envVar) {
|
|
15
|
-
if (!process.env) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
const envVarValue = (process.env[envVar] || "").toLowerCase();
|
|
19
|
-
return ["true", "1"].includes(envVarValue);
|
|
20
|
-
}
|
|
21
15
|
export {
|
|
22
16
|
GoogleLLMVariant,
|
|
23
17
|
getGoogleLlmVariant
|
package/dist/esm/version.js
CHANGED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Part as A2APart, Message, Task, TaskArtifactUpdateEvent, TaskStatusUpdateEvent } from '@a2a-js/sdk';
|
|
7
|
+
/**
|
|
8
|
+
* Message roles.
|
|
9
|
+
*/
|
|
10
|
+
export declare enum MessageRole {
|
|
11
|
+
USER = "user",
|
|
12
|
+
AGENT = "agent"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A2A event.
|
|
16
|
+
*/
|
|
17
|
+
export type A2AEvent = Task | Message | TaskStatusUpdateEvent | TaskArtifactUpdateEvent;
|
|
18
|
+
/**
|
|
19
|
+
* Checks if the event is an A2A TaskStatusUpdateEvent.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isTaskStatusUpdateEvent(event: unknown): event is TaskStatusUpdateEvent;
|
|
22
|
+
/**
|
|
23
|
+
* Checks if the event is an A2A TaskArtifactUpdateEvent.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isTaskArtifactUpdateEvent(event: unknown): event is TaskArtifactUpdateEvent;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if the event is an A2A Message.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isMessage(event: unknown): event is Message;
|
|
30
|
+
/**
|
|
31
|
+
* Checks if the event is an A2A Task.
|
|
32
|
+
*/
|
|
33
|
+
export declare function isTask(event: unknown): event is Task;
|
|
34
|
+
/**
|
|
35
|
+
* Gets the metadata from an A2A event.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getEventMetadata(event: A2AEvent): Record<string, unknown>;
|
|
38
|
+
/**
|
|
39
|
+
* Checks if the event is a failed task status update event.
|
|
40
|
+
*/
|
|
41
|
+
export declare function isFailedTaskStatusUpdateEvent(event: unknown): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Checks if the event is a terminal task status update event.
|
|
44
|
+
*/
|
|
45
|
+
export declare function isTerminalTaskStatusUpdateEvent(event: unknown): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Checks if the event is an input required task status update event.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isInputRequiredTaskStatusUpdateEvent(event: unknown): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Gets the error message from a failed task status update event.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getFailedTaskStatusUpdateEventError(event: TaskStatusUpdateEvent | Task): string | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a task submitted event.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createTaskSubmittedEvent({ taskId, contextId, message, }: {
|
|
58
|
+
taskId: string;
|
|
59
|
+
contextId: string;
|
|
60
|
+
message: Message;
|
|
61
|
+
}): TaskStatusUpdateEvent;
|
|
62
|
+
/**
|
|
63
|
+
* Creates a task with submitted status.
|
|
64
|
+
*/
|
|
65
|
+
export declare function createTask({ contextId, message, taskId, }: {
|
|
66
|
+
taskId: string;
|
|
67
|
+
contextId: string;
|
|
68
|
+
message: Message;
|
|
69
|
+
}): Task;
|
|
70
|
+
/**
|
|
71
|
+
* Creates a task working event.
|
|
72
|
+
*/
|
|
73
|
+
export declare function createTaskWorkingEvent({ taskId, contextId, message, }: {
|
|
74
|
+
taskId: string;
|
|
75
|
+
contextId: string;
|
|
76
|
+
message: Message;
|
|
77
|
+
}): TaskStatusUpdateEvent;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a task completed event.
|
|
80
|
+
*/
|
|
81
|
+
export declare function createTaskCompletedEvent({ taskId, contextId, metadata, }: {
|
|
82
|
+
taskId: string;
|
|
83
|
+
contextId: string;
|
|
84
|
+
metadata?: Record<string, unknown>;
|
|
85
|
+
}): TaskStatusUpdateEvent;
|
|
86
|
+
/**
|
|
87
|
+
* Creates an artifact update event.
|
|
88
|
+
*/
|
|
89
|
+
export declare function createTaskArtifactUpdateEvent({ taskId, contextId, artifactId, parts, metadata, append, lastChunk, }: {
|
|
90
|
+
taskId: string;
|
|
91
|
+
contextId: string;
|
|
92
|
+
artifactId?: string;
|
|
93
|
+
parts?: A2APart[];
|
|
94
|
+
metadata?: Record<string, unknown>;
|
|
95
|
+
append?: boolean;
|
|
96
|
+
lastChunk?: boolean;
|
|
97
|
+
}): TaskArtifactUpdateEvent;
|
|
98
|
+
/**
|
|
99
|
+
* Creates an error message for task execution failure.
|
|
100
|
+
*/
|
|
101
|
+
export declare function createTaskFailedEvent({ taskId, contextId, error, metadata, }: {
|
|
102
|
+
taskId: string;
|
|
103
|
+
contextId: string;
|
|
104
|
+
error: Error;
|
|
105
|
+
metadata?: Record<string, unknown>;
|
|
106
|
+
}): TaskStatusUpdateEvent;
|
|
107
|
+
/**
|
|
108
|
+
* Creates an input required event.
|
|
109
|
+
*/
|
|
110
|
+
export declare function createTaskInputRequiredEvent({ taskId, contextId, parts, }: {
|
|
111
|
+
taskId: string;
|
|
112
|
+
contextId: string;
|
|
113
|
+
parts: A2APart[];
|
|
114
|
+
}): TaskStatusUpdateEvent;
|
|
115
|
+
/**
|
|
116
|
+
* Creates an error message for missing input for a function call.
|
|
117
|
+
*/
|
|
118
|
+
export declare function createInputMissingErrorEvent({ taskId, contextId, parts, }: {
|
|
119
|
+
parts: A2APart[];
|
|
120
|
+
taskId: string;
|
|
121
|
+
contextId: string;
|
|
122
|
+
}): TaskStatusUpdateEvent;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Message } from '@a2a-js/sdk';
|
|
7
|
+
import { Event as AdkEvent } from '../events/event.js';
|
|
8
|
+
import { A2AEvent } from './a2a_event.js';
|
|
9
|
+
/**
|
|
10
|
+
* Converts a session Event to an A2A Message.
|
|
11
|
+
*/
|
|
12
|
+
export declare function toA2AMessage(event: AdkEvent, { appName, userId, sessionId, }: {
|
|
13
|
+
appName: string;
|
|
14
|
+
userId: string;
|
|
15
|
+
sessionId: string;
|
|
16
|
+
}): Message;
|
|
17
|
+
/**
|
|
18
|
+
* Converts an A2A Event to a Session Event.
|
|
19
|
+
*/
|
|
20
|
+
export declare function toAdkEvent(event: A2AEvent, invocationId: string, agentName: string): AdkEvent | undefined;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { RequestContext } from '@a2a-js/sdk/server';
|
|
7
|
+
import { Content } from '@google/genai';
|
|
8
|
+
import { Event } from '../events/event.js';
|
|
9
|
+
import { Session } from '../sessions/session.js';
|
|
10
|
+
/**
|
|
11
|
+
* The A2A Agent Executor context.
|
|
12
|
+
*/
|
|
13
|
+
export interface ExecutorContext {
|
|
14
|
+
userId: string;
|
|
15
|
+
sessionId: string;
|
|
16
|
+
agentName: string;
|
|
17
|
+
readonlyState: Record<string, unknown>;
|
|
18
|
+
events: Event[];
|
|
19
|
+
userContent: Content;
|
|
20
|
+
requestContext: RequestContext;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates an A2A Agent Executor context from the given parameters.
|
|
24
|
+
* @param session The session.
|
|
25
|
+
* @param userContent The content of the user.
|
|
26
|
+
* @param requestContext The request context.
|
|
27
|
+
* @returns The A2A Agent Executor context.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createExecutorContext({ session, userContent, requestContext, }: {
|
|
30
|
+
session: Session;
|
|
31
|
+
userContent: Content;
|
|
32
|
+
requestContext: RequestContext;
|
|
33
|
+
}): ExecutorContext;
|