@google/adk 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/a2a/a2a_remote_agent.js +4 -1
- package/dist/cjs/a2a/agent_card.js +102 -26
- package/dist/cjs/a2a/agent_to_a2a.js +1 -1
- package/dist/cjs/agents/functions.js +199 -25
- package/dist/cjs/agents/instructions.js +4 -1
- package/dist/cjs/agents/invocation_context.js +26 -4
- package/dist/cjs/agents/langgraph_agent.js +152 -0
- package/dist/cjs/agents/llm_agent.js +175 -101
- package/dist/cjs/agents/processors/code_execution_request_processor.js +10 -6
- package/dist/cjs/agents/remote_agent.js +187 -0
- package/dist/cjs/artifacts/in_memory_artifact_service.js +14 -0
- package/dist/cjs/auth/auth_handler.js +37 -5
- package/dist/cjs/auth/auth_schemes.js +9 -0
- package/dist/cjs/cli/cli_eval.js +532 -0
- package/dist/cjs/cli/utils/envs.js +116 -0
- package/dist/cjs/cli/utils/evals.js +137 -0
- package/dist/cjs/cli/utils/logs.js +150 -0
- package/dist/cjs/code_executors/agent_engine_sandbox_code_executor.js +7 -2
- package/dist/cjs/code_executors/code_execution_utils.js +48 -16
- package/dist/cjs/code_executors/code_executor_context.js +6 -2
- package/dist/cjs/common.js +72 -0
- package/dist/cjs/context/summarizers/llm_summarizer.js +12 -10
- package/dist/cjs/context/token_based_context_compactor.js +2 -1
- package/dist/cjs/events/event.js +4 -2
- package/dist/cjs/examples/example_util.js +23 -2
- package/dist/cjs/flows/llm_flows/audio_transcriber.js +170 -0
- package/dist/cjs/index.js +97 -1
- package/dist/cjs/integrations/agent_registry/helpers.js +1 -1
- package/dist/cjs/models/gemini_llm_connection.js +16 -8
- package/dist/cjs/models/google_llm.js +13 -16
- package/dist/cjs/models/llm_response.js +9 -1
- package/dist/cjs/models/registry.js +1 -1
- package/dist/cjs/models/routed_llm.js +9 -8
- package/dist/cjs/planners/plan_re_act_planner.js +1 -1
- package/dist/cjs/runner/in_memory_runner.js +6 -11
- package/dist/cjs/runner/runner.js +105 -33
- package/dist/cjs/sessions/db/operations.js +1 -1
- package/dist/cjs/sessions/in_memory_session_service.js +3 -1
- package/dist/cjs/sessions/state.js +8 -4
- package/dist/cjs/sessions/vertex_ai_session_service.js +34 -15
- package/dist/cjs/telemetry/tracing.js +97 -66
- package/dist/cjs/tools/agent_tool.js +44 -0
- package/dist/cjs/tools/apihub_tool/apihub_toolset.js +142 -0
- package/dist/cjs/tools/apihub_tool/clients/apihub_client.js +272 -0
- package/dist/cjs/tools/apihub_tool/clients/secret_client.js +148 -0
- package/dist/cjs/tools/apihub_tool/clients/service_account.js +48 -0
- package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +185 -0
- package/dist/cjs/tools/application_integration_tool/clients/cloud_request.js +133 -0
- package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +603 -0
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +219 -0
- package/dist/cjs/tools/crewai_tool.js +132 -0
- package/dist/cjs/tools/example_tool.js +10 -0
- package/dist/cjs/tools/function_tool.js +319 -0
- package/dist/cjs/tools/google_api_tool/google_api_tool.js +97 -0
- package/dist/cjs/tools/google_api_tool/google_api_tool_set.js +226 -0
- package/dist/cjs/tools/google_api_tool/google_api_tool_sets.js +58 -0
- package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +440 -0
- package/dist/cjs/tools/google_api_tool/index.js +64 -0
- package/dist/cjs/tools/langchain_tool.js +172 -0
- package/dist/cjs/tools/mcp/index.js +12 -0
- package/dist/cjs/tools/mcp/mcp_session_manager.js +25 -0
- package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +1 -2
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +46 -2
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -1
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +14 -2
- package/dist/cjs/tools/retrieval/base_retrieval_tool.js +18 -3
- package/dist/cjs/tools/toolbox_tool.js +108 -0
- package/dist/cjs/utils/env_aware_utils.js +6 -8
- package/dist/cjs/utils/error_utils.js +11 -11
- package/dist/cjs/utils/file_extension_utils.js +11 -0
- package/dist/cjs/utils/file_utils.js +2 -24
- package/dist/cjs/utils/gemini_schema_util.js +4 -1
- package/dist/cjs/utils/json_utils.js +49 -0
- package/dist/cjs/utils/live_connection_utils.js +4 -5
- package/dist/cjs/utils/logger_node.js +7 -1
- package/dist/cjs/utils/object_notation_utils.js +6 -3
- package/dist/cjs/utils/streaming_utils.js +12 -12
- package/dist/cjs/version.js +1 -1
- package/dist/esm/a2a/a2a_remote_agent.js +4 -1
- package/dist/esm/a2a/agent_card.js +103 -27
- package/dist/esm/a2a/agent_to_a2a.js +5 -2
- package/dist/esm/agents/functions.js +198 -25
- package/dist/esm/agents/instructions.js +4 -1
- package/dist/esm/agents/invocation_context.js +24 -4
- package/dist/esm/agents/langgraph_agent.js +123 -0
- package/dist/esm/agents/llm_agent.js +185 -104
- package/dist/esm/agents/processors/code_execution_request_processor.js +13 -8
- package/dist/esm/agents/remote_agent.js +164 -0
- package/dist/esm/artifacts/in_memory_artifact_service.js +14 -0
- package/dist/esm/auth/auth_handler.js +37 -5
- package/dist/esm/auth/auth_schemes.js +8 -0
- package/dist/esm/cli/cli_eval.js +510 -0
- package/dist/esm/cli/utils/envs.js +78 -0
- package/dist/esm/cli/utils/evals.js +109 -0
- package/dist/esm/cli/utils/logs.js +111 -0
- package/dist/esm/code_executors/agent_engine_sandbox_code_executor.js +7 -2
- package/dist/esm/code_executors/code_execution_utils.js +46 -16
- package/dist/esm/code_executors/code_executor_context.js +5 -2
- package/dist/esm/common.js +67 -3
- package/dist/esm/context/summarizers/llm_summarizer.js +12 -10
- package/dist/esm/context/token_based_context_compactor.js +2 -1
- package/dist/esm/events/event.js +4 -2
- package/dist/esm/examples/example_util.js +21 -1
- package/dist/esm/flows/llm_flows/audio_transcriber.js +142 -0
- package/dist/esm/index.js +99 -1
- package/dist/esm/integrations/agent_registry/helpers.js +1 -1
- package/dist/esm/models/gemini_llm_connection.js +16 -8
- package/dist/esm/models/google_llm.js +14 -17
- package/dist/esm/models/llm_response.js +9 -1
- package/dist/esm/models/registry.js +1 -1
- package/dist/esm/models/routed_llm.js +9 -8
- package/dist/esm/planners/plan_re_act_planner.js +1 -1
- package/dist/esm/runner/in_memory_runner.js +6 -11
- package/dist/esm/runner/runner.js +105 -33
- package/dist/esm/sessions/db/operations.js +1 -1
- package/dist/esm/sessions/in_memory_session_service.js +3 -1
- package/dist/esm/sessions/state.js +8 -4
- package/dist/esm/sessions/vertex_ai_session_service.js +34 -15
- package/dist/esm/telemetry/tracing.js +97 -66
- package/dist/esm/tools/agent_tool.js +44 -0
- package/dist/esm/tools/apihub_tool/apihub_toolset.js +106 -0
- package/dist/esm/tools/apihub_tool/clients/apihub_client.js +244 -0
- package/dist/esm/tools/apihub_tool/clients/secret_client.js +132 -0
- package/dist/esm/tools/apihub_tool/clients/service_account.js +21 -0
- package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +163 -0
- package/dist/esm/tools/application_integration_tool/clients/cloud_request.js +103 -0
- package/dist/esm/tools/application_integration_tool/clients/connections_client.js +561 -0
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +215 -0
- package/dist/esm/tools/crewai_tool.js +107 -0
- package/dist/esm/tools/example_tool.js +13 -1
- package/dist/esm/tools/function_tool.js +316 -0
- package/dist/esm/tools/google_api_tool/google_api_tool.js +70 -0
- package/dist/esm/tools/google_api_tool/google_api_tool_set.js +188 -0
- package/dist/esm/tools/google_api_tool/google_api_tool_sets.js +24 -0
- package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +393 -0
- package/dist/esm/tools/google_api_tool/index.js +33 -0
- package/dist/esm/tools/langchain_tool.js +148 -0
- package/dist/esm/tools/mcp/index.js +6 -0
- package/dist/esm/tools/mcp/mcp_session_manager.js +25 -0
- package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +1 -2
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +50 -3
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -1
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +15 -2
- package/dist/esm/tools/retrieval/base_retrieval_tool.js +16 -2
- package/dist/esm/tools/toolbox_tool.js +80 -0
- package/dist/esm/utils/env_aware_utils.js +6 -8
- package/dist/esm/utils/error_utils.js +9 -10
- package/dist/esm/utils/file_extension_utils.js +11 -0
- package/dist/esm/utils/file_utils.js +2 -23
- package/dist/esm/utils/gemini_schema_util.js +4 -1
- package/dist/esm/utils/json_utils.js +21 -0
- package/dist/esm/utils/live_connection_utils.js +4 -5
- package/dist/esm/utils/logger_node.js +7 -1
- package/dist/esm/utils/object_notation_utils.js +4 -2
- package/dist/esm/utils/streaming_utils.js +11 -11
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/a2a_remote_agent.d.ts +9 -0
- package/dist/types/a2a/agent_card.d.ts +44 -1
- package/dist/types/a2a/agent_to_a2a.d.ts +9 -0
- package/dist/types/a2a/index.d.ts +1 -0
- package/dist/types/agents/functions.d.ts +33 -1
- package/dist/types/agents/invocation_context.d.ts +20 -1
- package/dist/types/agents/langgraph_agent.d.ts +153 -0
- package/dist/types/agents/remote_agent.d.ts +68 -0
- package/dist/types/auth/auth_handler.d.ts +28 -1
- package/dist/types/auth/auth_schemes.d.ts +13 -0
- package/dist/types/cli/cli_eval.d.ts +173 -0
- package/dist/types/cli/utils/envs.d.ts +23 -0
- package/dist/types/cli/utils/evals.d.ts +47 -0
- package/dist/types/cli/utils/logs.d.ts +38 -0
- package/dist/types/code_executors/code_execution_utils.d.ts +39 -0
- package/dist/types/code_executors/code_executor_context.d.ts +1 -0
- package/dist/types/common.d.ts +27 -4
- package/dist/types/events/event.d.ts +4 -0
- package/dist/types/examples/example_util.d.ts +17 -0
- package/dist/types/flows/llm_flows/audio_transcriber.d.ts +85 -0
- package/dist/types/index.d.ts +16 -1
- package/dist/types/models/gemini_llm_connection.d.ts +6 -7
- package/dist/types/models/routed_llm.d.ts +1 -1
- package/dist/types/runner/in_memory_runner.d.ts +2 -1
- package/dist/types/runner/runner.d.ts +34 -0
- package/dist/types/sessions/state.d.ts +5 -1
- package/dist/types/sessions/vertex_ai_session_service.d.ts +8 -0
- package/dist/types/skills/skill.d.ts +1 -1
- package/dist/types/telemetry/tracing.d.ts +4 -2
- package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +122 -0
- package/dist/types/tools/apihub_tool/clients/apihub_client.d.ts +142 -0
- package/dist/types/tools/apihub_tool/clients/secret_client.d.ts +55 -0
- package/dist/types/tools/apihub_tool/clients/service_account.d.ts +11 -0
- package/dist/types/tools/application_integration_tool/application_integration_toolset.d.ts +86 -0
- package/dist/types/tools/application_integration_tool/clients/cloud_request.d.ts +53 -0
- package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +215 -0
- package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +72 -0
- package/dist/types/tools/crewai_tool.d.ts +85 -0
- package/dist/types/tools/example_tool.d.ts +10 -0
- package/dist/types/tools/function_tool.d.ts +32 -0
- package/dist/types/tools/google_api_tool/google_api_tool.d.ts +30 -0
- package/dist/types/tools/google_api_tool/google_api_tool_set.d.ts +78 -0
- package/dist/types/tools/google_api_tool/google_api_tool_sets.d.ts +33 -0
- package/dist/types/tools/google_api_tool/googleapi_to_openapi_converter.d.ts +164 -0
- package/dist/types/tools/google_api_tool/index.d.ts +11 -0
- package/dist/types/tools/langchain_tool.d.ts +103 -0
- package/dist/types/tools/mcp/index.d.ts +3 -0
- package/dist/types/tools/mcp/mcp_session_manager.d.ts +34 -1
- package/dist/types/tools/mcp/mcp_toolset.d.ts +15 -0
- package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +19 -0
- package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +18 -1
- package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +2 -1
- package/dist/types/tools/retrieval/base_retrieval_tool.d.ts +15 -0
- package/dist/types/tools/toolbox_tool.d.ts +73 -0
- package/dist/types/utils/env_aware_utils.d.ts +18 -2
- package/dist/types/utils/error_utils.d.ts +7 -0
- package/dist/types/utils/file_utils.d.ts +6 -1
- package/dist/types/utils/gemini_schema_util.d.ts +1 -2
- package/dist/types/utils/json_utils.d.ts +11 -0
- package/dist/types/utils/object_notation_utils.d.ts +7 -0
- package/dist/types/utils/streaming_utils.d.ts +11 -4
- package/dist/types/version.d.ts +1 -1
- package/dist/web/index_web.js +102 -103
- package/dist/web/index_web.js.map +4 -4
- package/package.json +8 -3
- package/dist/cjs/models/gemini_continuation.js +0 -232
- package/dist/esm/models/gemini_continuation.js +0 -205
- package/dist/types/models/gemini_continuation.d.ts +0 -59
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2026 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
*/
|
|
10
|
+
var AudioEncoding = /* @__PURE__ */ ((AudioEncoding2) => {
|
|
11
|
+
AudioEncoding2[AudioEncoding2["ENCODING_UNSPECIFIED"] = 0] = "ENCODING_UNSPECIFIED";
|
|
12
|
+
AudioEncoding2[AudioEncoding2["LINEAR16"] = 1] = "LINEAR16";
|
|
13
|
+
return AudioEncoding2;
|
|
14
|
+
})(AudioEncoding || {});
|
|
15
|
+
function isSpeechClientLike(value) {
|
|
16
|
+
return typeof value === "object" && value !== null && typeof value.recognize === "function";
|
|
17
|
+
}
|
|
18
|
+
__name(isSpeechClientLike, "isSpeechClientLike");
|
|
19
|
+
function isContentEntry(data) {
|
|
20
|
+
return "parts" in data || !("data" in data) && !("mimeType" in data);
|
|
21
|
+
}
|
|
22
|
+
__name(isContentEntry, "isContentEntry");
|
|
23
|
+
function blobDataToBytes(data) {
|
|
24
|
+
if (typeof data !== "string") {
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
if (data.length > 0 && data.length % 4 === 0 && /^[A-Za-z0-9+/]+={0,2}$/.test(data)) {
|
|
28
|
+
const atobFn = globalThis.atob;
|
|
29
|
+
if (typeof Buffer === "undefined" && typeof atobFn === "function") {
|
|
30
|
+
const binary = atobFn(data);
|
|
31
|
+
return Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
32
|
+
}
|
|
33
|
+
return new Uint8Array(Buffer.from(data, "base64"));
|
|
34
|
+
}
|
|
35
|
+
return new TextEncoder().encode(data);
|
|
36
|
+
}
|
|
37
|
+
__name(blobDataToBytes, "blobDataToBytes");
|
|
38
|
+
function concatBytes(first, second) {
|
|
39
|
+
const merged = new Uint8Array(first.length + second.length);
|
|
40
|
+
merged.set(first, 0);
|
|
41
|
+
merged.set(second, first.length);
|
|
42
|
+
return merged;
|
|
43
|
+
}
|
|
44
|
+
__name(concatBytes, "concatBytes");
|
|
45
|
+
const _AudioTranscriber = class _AudioTranscriber {
|
|
46
|
+
constructor(optionsOrClient) {
|
|
47
|
+
if (isSpeechClientLike(optionsOrClient)) {
|
|
48
|
+
this.client = optionsOrClient;
|
|
49
|
+
} else if (optionsOrClient == null ? void 0 : optionsOrClient.client) {
|
|
50
|
+
this.client = optionsOrClient.client;
|
|
51
|
+
} else {
|
|
52
|
+
this.client = {
|
|
53
|
+
recognize() {
|
|
54
|
+
throw new Error(
|
|
55
|
+
"SpeechClient is not configured on AudioTranscriber. Pass a SpeechClientLike implementation to new AudioTranscriber({client})."
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Bundles consecutive audio blobs from the same speaker in
|
|
63
|
+
* `invocationContext.transcriptionCache`, transcribes user audio bundles into
|
|
64
|
+
* text `Content` entries, preserves already-transcribed `Content`
|
|
65
|
+
* entries in order, clears `invocationContext.transcriptionCache`, and
|
|
66
|
+
* returns the resulting content list.
|
|
67
|
+
*
|
|
68
|
+
* @param invocationContext The invocation context holding `transcriptionCache`.
|
|
69
|
+
* @returns Ordered list of transcribed `Content` objects.
|
|
70
|
+
*/
|
|
71
|
+
async transcribeFile(invocationContext) {
|
|
72
|
+
var _a, _b, _c, _d;
|
|
73
|
+
const bundledAudio = [];
|
|
74
|
+
const transcriptionHistory = [];
|
|
75
|
+
let currentSpeaker = void 0;
|
|
76
|
+
let currentAudioData = new Uint8Array(0);
|
|
77
|
+
for (const transcriptionEntry of (_a = invocationContext.transcriptionCache) != null ? _a : []) {
|
|
78
|
+
const speaker = transcriptionEntry.role;
|
|
79
|
+
const audioData = transcriptionEntry.data;
|
|
80
|
+
if (isContentEntry(audioData)) {
|
|
81
|
+
if (currentSpeaker !== void 0) {
|
|
82
|
+
bundledAudio.push([currentSpeaker, currentAudioData]);
|
|
83
|
+
currentSpeaker = void 0;
|
|
84
|
+
currentAudioData = new Uint8Array(0);
|
|
85
|
+
}
|
|
86
|
+
bundledAudio.push([speaker, audioData]);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const rawData = audioData.data;
|
|
90
|
+
if (!rawData) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const chunkBytes = blobDataToBytes(rawData);
|
|
94
|
+
if (chunkBytes.length === 0) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (speaker === currentSpeaker) {
|
|
98
|
+
currentAudioData = concatBytes(currentAudioData, chunkBytes);
|
|
99
|
+
} else {
|
|
100
|
+
if (currentSpeaker !== void 0) {
|
|
101
|
+
bundledAudio.push([currentSpeaker, currentAudioData]);
|
|
102
|
+
}
|
|
103
|
+
currentSpeaker = speaker;
|
|
104
|
+
currentAudioData = chunkBytes;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (currentSpeaker !== void 0) {
|
|
108
|
+
bundledAudio.push([currentSpeaker, currentAudioData]);
|
|
109
|
+
}
|
|
110
|
+
invocationContext.transcriptionCache = [];
|
|
111
|
+
for (const [speaker, data] of bundledAudio) {
|
|
112
|
+
if (ArrayBuffer.isView(data)) {
|
|
113
|
+
const audio = { content: data };
|
|
114
|
+
const config = {
|
|
115
|
+
encoding: 1 /* LINEAR16 */,
|
|
116
|
+
sampleRateHertz: 16e3,
|
|
117
|
+
languageCode: "en-US"
|
|
118
|
+
};
|
|
119
|
+
const rawResponse = await this.client.recognize({ config, audio });
|
|
120
|
+
const response = Array.isArray(rawResponse) ? rawResponse[0] : rawResponse;
|
|
121
|
+
for (const result of (_b = response.results) != null ? _b : []) {
|
|
122
|
+
const transcript = (_d = (_c = result.alternatives) == null ? void 0 : _c[0]) == null ? void 0 : _d.transcript;
|
|
123
|
+
if (transcript !== void 0 && transcript !== null) {
|
|
124
|
+
transcriptionHistory.push({
|
|
125
|
+
role: speaker ? speaker.toLowerCase() : "user",
|
|
126
|
+
parts: [{ text: transcript }]
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
transcriptionHistory.push(data);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return transcriptionHistory;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
__name(_AudioTranscriber, "AudioTranscriber");
|
|
138
|
+
let AudioTranscriber = _AudioTranscriber;
|
|
139
|
+
export {
|
|
140
|
+
AudioEncoding,
|
|
141
|
+
AudioTranscriber
|
|
142
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -26,6 +26,10 @@ export * from "./common.js";
|
|
|
26
26
|
import { LocalEnvironment } from "./environment/local_environment.js";
|
|
27
27
|
import { VertexAiMemoryBankService } from "./memory/vertex_ai_memory_bank_service.js";
|
|
28
28
|
import { VertexAiRagMemoryService } from "./memory/vertex_ai_rag_memory_service.js";
|
|
29
|
+
import {
|
|
30
|
+
DebugLoggingPlugin,
|
|
31
|
+
isDebugLoggingPlugin
|
|
32
|
+
} from "./plugins/debug_logging_plugin.js";
|
|
29
33
|
import { DatabaseSessionService } from "./sessions/database_session_service.js";
|
|
30
34
|
import { getSessionServiceFromUri } from "./sessions/registry.js";
|
|
31
35
|
import { VertexAiSessionService } from "./sessions/vertex_ai_session_service.js";
|
|
@@ -36,6 +40,40 @@ import {
|
|
|
36
40
|
loadSkillFromZipBuffer,
|
|
37
41
|
validateSkillDir
|
|
38
42
|
} from "./skills/loader.js";
|
|
43
|
+
import {
|
|
44
|
+
APIHubToolset
|
|
45
|
+
} from "./tools/apihub_tool/apihub_toolset.js";
|
|
46
|
+
import {
|
|
47
|
+
APIHubClient
|
|
48
|
+
} from "./tools/apihub_tool/clients/apihub_client.js";
|
|
49
|
+
import {
|
|
50
|
+
SecretManagerClient
|
|
51
|
+
} from "./tools/apihub_tool/clients/secret_client.js";
|
|
52
|
+
import {
|
|
53
|
+
ApplicationIntegrationToolset
|
|
54
|
+
} from "./tools/application_integration_tool/application_integration_toolset.js";
|
|
55
|
+
import {
|
|
56
|
+
actionRequest,
|
|
57
|
+
actionResponse,
|
|
58
|
+
ConnectionsClient,
|
|
59
|
+
CONNECTOR_BASE_SPEC,
|
|
60
|
+
connectorPayload,
|
|
61
|
+
createOperation,
|
|
62
|
+
createOperationRequest,
|
|
63
|
+
deleteOperation,
|
|
64
|
+
deleteOperationRequest,
|
|
65
|
+
executeCustomQueryRequest,
|
|
66
|
+
getActionOperation,
|
|
67
|
+
getOperation,
|
|
68
|
+
getOperationRequest,
|
|
69
|
+
listOperation,
|
|
70
|
+
listOperationRequest,
|
|
71
|
+
updateOperation,
|
|
72
|
+
updateOperationRequest
|
|
73
|
+
} from "./tools/application_integration_tool/clients/connections_client.js";
|
|
74
|
+
import {
|
|
75
|
+
IntegrationClient
|
|
76
|
+
} from "./tools/application_integration_tool/clients/integration_client.js";
|
|
39
77
|
import { LOAD_WEB_PAGE, loadWebPage } from "./tools/load_web_page.js";
|
|
40
78
|
import {
|
|
41
79
|
credentialToParam,
|
|
@@ -54,6 +92,7 @@ import {
|
|
|
54
92
|
} from "./tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.js";
|
|
55
93
|
import {
|
|
56
94
|
exchangeCredential,
|
|
95
|
+
generateAuthToken,
|
|
57
96
|
OAuth2BearerExchanger
|
|
58
97
|
} from "./tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js";
|
|
59
98
|
import { ServiceAccountCredentialExchanger } from "./tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js";
|
|
@@ -86,59 +125,118 @@ import { SkillToolset } from "./tools/skill/skill_toolset.js";
|
|
|
86
125
|
export * from "./integrations/agent_registry/agent_registry.js";
|
|
87
126
|
export * from "./telemetry/google_cloud.js";
|
|
88
127
|
export * from "./telemetry/setup.js";
|
|
128
|
+
export * from "./tools/google_api_tool/index.js";
|
|
129
|
+
import {
|
|
130
|
+
DEFAULT_CRITERIA,
|
|
131
|
+
EVAL_SESSION_ID_PREFIX,
|
|
132
|
+
EvalStatus,
|
|
133
|
+
getEvaluationCriteriaOrDefault,
|
|
134
|
+
getRootAgent,
|
|
135
|
+
MISSING_EVAL_DEPENDENCIES_MESSAGE,
|
|
136
|
+
parseAndGetEvalsToRun,
|
|
137
|
+
RESPONSE_EVALUATION_SCORE_KEY,
|
|
138
|
+
RESPONSE_MATCH_SCORE_KEY,
|
|
139
|
+
runEvals,
|
|
140
|
+
TOOL_TRAJECTORY_SCORE_KEY,
|
|
141
|
+
tryGetResetFunc
|
|
142
|
+
} from "./cli/cli_eval.js";
|
|
143
|
+
import { loadDotenvForAgent, walkToRootUntilFound } from "./cli/utils/envs.js";
|
|
144
|
+
import { LOGGING_FORMAT, logToStderr, logToTmpFolder } from "./cli/utils/logs.js";
|
|
89
145
|
export * from "./tools/mcp/index.js";
|
|
90
146
|
export {
|
|
147
|
+
APIHubClient,
|
|
148
|
+
APIHubToolset,
|
|
91
149
|
AgentEngineSandboxCodeExecutor,
|
|
150
|
+
ApplicationIntegrationToolset,
|
|
92
151
|
AuthCredentialMissingError,
|
|
93
152
|
AutoAuthCredentialExchanger,
|
|
94
153
|
BaseAuthCredentialExchanger,
|
|
154
|
+
CONNECTOR_BASE_SPEC,
|
|
95
155
|
CodeExecutionLanguage,
|
|
156
|
+
ConnectionsClient,
|
|
96
157
|
ContainerCodeExecutor,
|
|
158
|
+
DEFAULT_CRITERIA,
|
|
97
159
|
DatabaseSessionService,
|
|
160
|
+
DebugLoggingPlugin,
|
|
161
|
+
EVAL_SESSION_ID_PREFIX,
|
|
162
|
+
EvalStatus,
|
|
98
163
|
FileArtifactService,
|
|
99
164
|
FilesRetrieval,
|
|
100
165
|
GCPSkillRegistry,
|
|
101
166
|
GcsArtifactService,
|
|
102
167
|
INTERNAL_AUTH_PREFIX,
|
|
168
|
+
IntegrationClient,
|
|
103
169
|
InvocationContext,
|
|
104
170
|
LOAD_WEB_PAGE,
|
|
171
|
+
LOGGING_FORMAT,
|
|
105
172
|
LoadSkillResourceTool,
|
|
106
173
|
LocalEnvironment,
|
|
174
|
+
MISSING_EVAL_DEPENDENCIES_MESSAGE,
|
|
107
175
|
OAuth2BearerExchanger,
|
|
108
176
|
OpenAPIToolset,
|
|
109
177
|
OpenApiSpecParser,
|
|
110
178
|
OperationParser,
|
|
179
|
+
RESPONSE_EVALUATION_SCORE_KEY,
|
|
180
|
+
RESPONSE_MATCH_SCORE_KEY,
|
|
111
181
|
RestApiTool,
|
|
112
182
|
RunSkillInlineScriptErrorCode,
|
|
113
183
|
RunSkillInlineScriptTool,
|
|
114
184
|
RunSkillScriptTool,
|
|
185
|
+
SecretManagerClient,
|
|
115
186
|
ServiceAccountCredentialExchanger,
|
|
116
187
|
SkillToolset,
|
|
188
|
+
TOOL_TRAJECTORY_SCORE_KEY,
|
|
117
189
|
ToolAuthHandler,
|
|
118
190
|
ToolContextCredentialStore,
|
|
119
191
|
UnsafeLocalCodeExecutor,
|
|
120
192
|
VertexAiMemoryBankService,
|
|
121
193
|
VertexAiRagMemoryService,
|
|
122
194
|
VertexAiSessionService,
|
|
195
|
+
actionRequest,
|
|
196
|
+
actionResponse,
|
|
197
|
+
connectorPayload,
|
|
123
198
|
createApiParameter,
|
|
199
|
+
createOperation,
|
|
200
|
+
createOperationRequest,
|
|
124
201
|
createRestApiTool,
|
|
125
202
|
createRestApiToolFromJson,
|
|
126
203
|
credentialToParam,
|
|
204
|
+
deleteOperation,
|
|
205
|
+
deleteOperationRequest,
|
|
127
206
|
dictToAuthScheme,
|
|
128
207
|
exchangeCredential,
|
|
208
|
+
executeCustomQueryRequest,
|
|
209
|
+
generateAuthToken,
|
|
129
210
|
generateParamDoc,
|
|
130
211
|
generateReturnDoc,
|
|
212
|
+
getActionOperation,
|
|
131
213
|
getArtifactServiceFromUri,
|
|
214
|
+
getEvaluationCriteriaOrDefault,
|
|
215
|
+
getOperation,
|
|
216
|
+
getOperationRequest,
|
|
217
|
+
getRootAgent,
|
|
132
218
|
getSessionServiceFromUri,
|
|
133
219
|
getTypeHint,
|
|
220
|
+
isDebugLoggingPlugin,
|
|
221
|
+
listOperation,
|
|
222
|
+
listOperationRequest,
|
|
134
223
|
loadAllSkillsInDir,
|
|
224
|
+
loadDotenvForAgent,
|
|
135
225
|
loadSkillFromDir,
|
|
136
226
|
loadSkillFromZipBuffer,
|
|
137
227
|
loadWebPage,
|
|
228
|
+
logToStderr,
|
|
229
|
+
logToTmpFolder,
|
|
138
230
|
openidDictToSchemeCredential,
|
|
139
231
|
openidUrlToSchemeCredential,
|
|
232
|
+
parseAndGetEvalsToRun,
|
|
233
|
+
runEvals,
|
|
140
234
|
serviceAccountDictToSchemeCredential,
|
|
141
235
|
serviceAccountSchemeCredential,
|
|
142
236
|
tokenToSchemeCredential,
|
|
143
|
-
|
|
237
|
+
tryGetResetFunc,
|
|
238
|
+
updateOperation,
|
|
239
|
+
updateOperationRequest,
|
|
240
|
+
validateSkillDir,
|
|
241
|
+
walkToRootUntilFound
|
|
144
242
|
};
|
|
@@ -10,7 +10,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
10
10
|
function isGoogleApi(url) {
|
|
11
11
|
try {
|
|
12
12
|
const parsed = new URL(url);
|
|
13
|
-
return parsed.hostname === "googleapis.com" || parsed.hostname.endsWith(".googleapis.com");
|
|
13
|
+
return parsed.protocol === "https:" && (parsed.hostname === "googleapis.com" || parsed.hostname.endsWith(".googleapis.com"));
|
|
14
14
|
} catch {
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
@@ -114,26 +114,34 @@ const _GeminiLlmConnection = class _GeminiLlmConnection {
|
|
|
114
114
|
this.geminiSession.sendRealtimeInput({ activityEnd: {} });
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
|
-
*
|
|
117
|
+
* Receives the model responses for one model turn.
|
|
118
118
|
*
|
|
119
|
-
* The
|
|
120
|
-
*
|
|
119
|
+
* The generator ends after the message that completes the turn has been
|
|
120
|
+
* processed, or when the server closes the connection. Call `receive()`
|
|
121
|
+
* again to read the next turn; it continues from the next server message.
|
|
121
122
|
*
|
|
122
|
-
* @
|
|
123
|
-
* @param isThought Whether the text is a thought.
|
|
124
|
-
* @param groundingMetadata The grounding metadata to include.
|
|
125
|
-
* @returns An LlmResponse containing the full text.
|
|
123
|
+
* @returns A generator of the LlmResponses of one model turn.
|
|
126
124
|
*/
|
|
127
125
|
async *receive() {
|
|
126
|
+
var _a, _b;
|
|
128
127
|
if (!this.messageQueue) {
|
|
129
128
|
throw new Error("Message queue is not initialized.");
|
|
130
129
|
}
|
|
130
|
+
(_a = this.messageIterator) != null ? _a : this.messageIterator = this.messageQueue[Symbol.asyncIterator]();
|
|
131
131
|
const aggregator = new LiveResponseAggregator(this.modelVersion);
|
|
132
|
-
|
|
132
|
+
while (true) {
|
|
133
|
+
const next = await this.messageIterator.next();
|
|
134
|
+
if (next.done) {
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
const message = next.value;
|
|
133
138
|
logger.debug("Got LLM Live message:", message);
|
|
134
139
|
for (const response of aggregator.processMessage(message)) {
|
|
135
140
|
yield response;
|
|
136
141
|
}
|
|
142
|
+
if ((_b = message.serverContent) == null ? void 0 : _b.turnComplete) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
137
145
|
}
|
|
138
146
|
for (const response of aggregator.close()) {
|
|
139
147
|
yield response;
|
|
@@ -16,7 +16,7 @@ import { isBrowser, isEnterpriseModeEnabled } from "../utils/env_aware_utils.js"
|
|
|
16
16
|
import { logger } from "../utils/logger.js";
|
|
17
17
|
import { GoogleLLMVariant } from "../utils/variant_utils.js";
|
|
18
18
|
import { AsyncQueue } from "../utils/async_queue.js";
|
|
19
|
-
import {
|
|
19
|
+
import { GeminiStreamingResponseAggregator } from "../utils/streaming_utils.js";
|
|
20
20
|
import { BaseLlm } from "./base_llm.js";
|
|
21
21
|
import { GeminiLlmConnection } from "./gemini_llm_connection.js";
|
|
22
22
|
import { generateContentViaInteractions } from "./interactions_utils.js";
|
|
@@ -76,7 +76,7 @@ const _Gemini = class _Gemini extends (_b = BaseLlm, _a = GEMINI_MODEL_SYMBOL, _
|
|
|
76
76
|
* metadata and no `content`; only a stream with neither ends silently.
|
|
77
77
|
*/
|
|
78
78
|
async *generateContentAsync(llmRequest, stream = false, abortSignal) {
|
|
79
|
-
var _a2, _b2
|
|
79
|
+
var _a2, _b2;
|
|
80
80
|
if (this.useInteractionsApi) {
|
|
81
81
|
yield* generateContentViaInteractions(this.apiClient, llmRequest, stream);
|
|
82
82
|
return;
|
|
@@ -98,28 +98,23 @@ const _Gemini = class _Gemini extends (_b = BaseLlm, _a = GEMINI_MODEL_SYMBOL, _
|
|
|
98
98
|
if (abortSignal) {
|
|
99
99
|
llmRequest.config.abortSignal = abortSignal;
|
|
100
100
|
}
|
|
101
|
+
const params = {
|
|
102
|
+
model: (_b2 = llmRequest.model) != null ? _b2 : this.model,
|
|
103
|
+
contents: llmRequest.contents,
|
|
104
|
+
config: llmRequest.config
|
|
105
|
+
};
|
|
101
106
|
if (stream) {
|
|
102
|
-
const streamResult = await this.apiClient.models.generateContentStream(
|
|
103
|
-
|
|
104
|
-
contents: llmRequest.contents,
|
|
105
|
-
config: llmRequest.config
|
|
106
|
-
});
|
|
107
|
-
const aggregator = new StreamingResponseAggregator();
|
|
107
|
+
const streamResult = await this.apiClient.models.generateContentStream(params);
|
|
108
|
+
const aggregator = new GeminiStreamingResponseAggregator();
|
|
108
109
|
for await (const response of streamResult) {
|
|
109
|
-
|
|
110
|
-
yield llmResponse;
|
|
111
|
-
}
|
|
110
|
+
yield* aggregator.processResponse(response);
|
|
112
111
|
}
|
|
113
112
|
const finalResponse = aggregator.close();
|
|
114
113
|
if (finalResponse) {
|
|
115
114
|
yield finalResponse;
|
|
116
115
|
}
|
|
117
116
|
} else {
|
|
118
|
-
const response = await this.apiClient.models.generateContent(
|
|
119
|
-
model: (_c = llmRequest.model) != null ? _c : this.model,
|
|
120
|
-
contents: llmRequest.contents,
|
|
121
|
-
config: llmRequest.config
|
|
122
|
-
});
|
|
117
|
+
const response = await this.apiClient.models.generateContent(params);
|
|
123
118
|
yield createLlmResponse(response);
|
|
124
119
|
}
|
|
125
120
|
}
|
|
@@ -139,6 +134,7 @@ const _Gemini = class _Gemini extends (_b = BaseLlm, _a = GEMINI_MODEL_SYMBOL, _
|
|
|
139
134
|
});
|
|
140
135
|
} else {
|
|
141
136
|
this._apiClient = new GoogleGenAI({
|
|
137
|
+
vertexai: false,
|
|
142
138
|
apiKey: this.apiKey,
|
|
143
139
|
httpOptions: this.getHttpOptions()
|
|
144
140
|
});
|
|
@@ -174,6 +170,7 @@ const _Gemini = class _Gemini extends (_b = BaseLlm, _a = GEMINI_MODEL_SYMBOL, _
|
|
|
174
170
|
});
|
|
175
171
|
} else {
|
|
176
172
|
this._liveApiClient = new GoogleGenAI({
|
|
173
|
+
vertexai: false,
|
|
177
174
|
apiKey: this.apiKey,
|
|
178
175
|
httpOptions: this.getLiveHttpOptions()
|
|
179
176
|
});
|
|
@@ -280,7 +277,7 @@ function geminiInitParams({
|
|
|
280
277
|
}) {
|
|
281
278
|
const params = { model, vertexai, project, location, apiKey };
|
|
282
279
|
params.vertexai = !!vertexai;
|
|
283
|
-
if (
|
|
280
|
+
if (vertexai === void 0 && !isBrowser()) {
|
|
284
281
|
params.vertexai = isEnterpriseModeEnabled();
|
|
285
282
|
}
|
|
286
283
|
if (params.vertexai) {
|
|
@@ -7,9 +7,17 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
7
7
|
* Copyright 2025 Google LLC
|
|
8
8
|
* SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
*/
|
|
10
|
+
function withOwnInitialPromptTokenCount(usage) {
|
|
11
|
+
const initialPromptTokenCount = usage == null ? void 0 : usage.initialPromptTokenCount;
|
|
12
|
+
if (!usage || initialPromptTokenCount === void 0 || initialPromptTokenCount === usage.promptTokenCount || Object.prototype.propertyIsEnumerable.call(usage, "initialPromptTokenCount")) {
|
|
13
|
+
return usage;
|
|
14
|
+
}
|
|
15
|
+
return { ...usage, initialPromptTokenCount };
|
|
16
|
+
}
|
|
17
|
+
__name(withOwnInitialPromptTokenCount, "withOwnInitialPromptTokenCount");
|
|
10
18
|
function createLlmResponse(response) {
|
|
11
19
|
var _a;
|
|
12
|
-
const usageMetadata = response.usageMetadata;
|
|
20
|
+
const usageMetadata = withOwnInitialPromptTokenCount(response.usageMetadata);
|
|
13
21
|
if (response.candidates && response.candidates.length > 0) {
|
|
14
22
|
const candidate = response.candidates[0];
|
|
15
23
|
if (((_a = candidate.content) == null ? void 0 : _a.parts) && candidate.content.parts.length > 0) {
|
|
@@ -75,7 +75,7 @@ const _LLMRegistry = class _LLMRegistry {
|
|
|
75
75
|
}
|
|
76
76
|
for (const [regex, llmClass] of _LLMRegistry.llmRegistryDict.entries()) {
|
|
77
77
|
const pattern = new RegExp(
|
|
78
|
-
|
|
78
|
+
`^(?:${regex instanceof RegExp ? regex.source : regex})$`,
|
|
79
79
|
regex instanceof RegExp ? regex.flags : void 0
|
|
80
80
|
);
|
|
81
81
|
if (pattern.test(model)) {
|
|
@@ -28,14 +28,12 @@ const _RoutedLlm = class _RoutedLlm extends BaseLlm {
|
|
|
28
28
|
/**
|
|
29
29
|
* Generates content by delegating to the selected model.
|
|
30
30
|
*/
|
|
31
|
-
async *generateContentAsync(llmRequest, stream) {
|
|
31
|
+
async *generateContentAsync(llmRequest, stream, abortSignal) {
|
|
32
32
|
logger.info(`Routing request via ${this.model}`);
|
|
33
|
-
yield* runWithRouting(
|
|
34
|
-
|
|
35
|
-
llmRequest,
|
|
36
|
-
|
|
37
|
-
(model) => model.generateContentAsync(llmRequest, stream)
|
|
38
|
-
);
|
|
33
|
+
yield* runWithRouting(this.models, llmRequest, this.router, (model) => {
|
|
34
|
+
llmRequest.model = model.model;
|
|
35
|
+
return model.generateContentAsync(llmRequest, stream, abortSignal);
|
|
36
|
+
});
|
|
39
37
|
}
|
|
40
38
|
/**
|
|
41
39
|
* Creates a live connection to the LLM by delegating to the selected model.
|
|
@@ -47,7 +45,10 @@ const _RoutedLlm = class _RoutedLlm extends BaseLlm {
|
|
|
47
45
|
this.models,
|
|
48
46
|
llmRequest,
|
|
49
47
|
this.router,
|
|
50
|
-
(model) =>
|
|
48
|
+
(model) => {
|
|
49
|
+
llmRequest.model = model.model;
|
|
50
|
+
return model.connect(llmRequest);
|
|
51
|
+
}
|
|
51
52
|
);
|
|
52
53
|
const result = await generator.next();
|
|
53
54
|
if (result.done || result.value === void 0) {
|
|
@@ -41,7 +41,7 @@ const _PlanReActPlanner = class _PlanReActPlanner extends BasePlanner {
|
|
|
41
41
|
}
|
|
42
42
|
handleNonFunctionCallPart(part, preservedParts);
|
|
43
43
|
}
|
|
44
|
-
if (firstFcPartIndex
|
|
44
|
+
if (firstFcPartIndex >= 0) {
|
|
45
45
|
for (let j = firstFcPartIndex + 1; j < responseParts.length; j++) {
|
|
46
46
|
if (!responseParts[j].functionCall) {
|
|
47
47
|
break;
|
|
@@ -18,28 +18,23 @@ const _InMemoryRunner = class _InMemoryRunner extends Runner {
|
|
|
18
18
|
* @param params The configuration for the runner.
|
|
19
19
|
* @param params.app An optional application instance to run.
|
|
20
20
|
* @param params.agent The root agent to run.
|
|
21
|
-
* @param params.appName The application name. Defaults to `
|
|
21
|
+
* @param params.appName The application name. Defaults to `app.name` when
|
|
22
|
+
* `app` is provided, or `'InMemoryRunner'` otherwise.
|
|
22
23
|
* @param params.plugins An optional list of plugins.
|
|
23
24
|
* @param params.resumabilityConfig An optional resumability configuration.
|
|
24
25
|
*/
|
|
25
26
|
constructor(params) {
|
|
26
|
-
var _a;
|
|
27
|
-
const {
|
|
28
|
-
agent,
|
|
29
|
-
appName = "InMemoryRunner",
|
|
30
|
-
plugins = [],
|
|
31
|
-
app,
|
|
32
|
-
resumabilityConfig
|
|
33
|
-
} = params;
|
|
27
|
+
var _a, _b;
|
|
28
|
+
const { agent, appName, plugins = [], app, resumabilityConfig } = params;
|
|
34
29
|
super({
|
|
35
30
|
app,
|
|
36
|
-
appName,
|
|
31
|
+
appName: (_a = appName != null ? appName : app == null ? void 0 : app.name) != null ? _a : "InMemoryRunner",
|
|
37
32
|
agent,
|
|
38
33
|
plugins,
|
|
39
34
|
artifactService: new InMemoryArtifactService(),
|
|
40
35
|
sessionService: new InMemorySessionService(),
|
|
41
36
|
memoryService: new InMemoryMemoryService(),
|
|
42
|
-
resumabilityConfig: (
|
|
37
|
+
resumabilityConfig: (_b = app == null ? void 0 : app.resumabilityConfig) != null ? _b : resumabilityConfig
|
|
43
38
|
});
|
|
44
39
|
}
|
|
45
40
|
};
|