@google/adk 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/a2a/event_converter_utils.js +5 -1
- package/dist/cjs/a2a/metadata_converter_utils.js +2 -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 +90 -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/abort_events.js +135 -0
- package/dist/cjs/events/event.js +4 -2
- package/dist/cjs/events/internal_metadata.js +131 -0
- 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/plugins/debug_logging_plugin.js +653 -0
- package/dist/cjs/plugins/plugin_manager.js +1 -1
- package/dist/cjs/plugins/tool_call_integrity_plugin.js +364 -0
- package/dist/cjs/runner/in_memory_runner.js +6 -11
- package/dist/cjs/runner/runner.js +121 -35
- 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/a2a/event_converter_utils.js +5 -1
- package/dist/esm/a2a/metadata_converter_utils.js +2 -1
- 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 +87 -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/abort_events.js +110 -0
- package/dist/esm/events/event.js +4 -2
- package/dist/esm/events/internal_metadata.js +97 -0
- 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/plugins/debug_logging_plugin.js +615 -0
- package/dist/esm/plugins/plugin_manager.js +1 -1
- package/dist/esm/plugins/tool_call_integrity_plugin.js +339 -0
- package/dist/esm/runner/in_memory_runner.js +6 -11
- package/dist/esm/runner/runner.js +124 -35
- 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 +30 -4
- package/dist/types/events/abort_events.d.ts +43 -0
- package/dist/types/events/event.d.ts +4 -0
- package/dist/types/events/internal_metadata.d.ts +78 -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/plugins/debug_logging_plugin.d.ts +157 -0
- package/dist/types/plugins/tool_call_integrity_plugin.d.ts +116 -0
- 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 +105 -106
- package/dist/web/index_web.js.map +4 -4
- package/package.json +8 -3
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
import {
|
|
11
|
+
createEvent,
|
|
12
|
+
getFunctionCalls,
|
|
13
|
+
getFunctionResponses,
|
|
14
|
+
isFinalResponse
|
|
15
|
+
} from "./event.js";
|
|
16
|
+
const INVOCATION_ABORTED = "INVOCATION_ABORTED";
|
|
17
|
+
const ABORT_MESSAGE = "Invocation was aborted by client.";
|
|
18
|
+
function isAbortEvent(event) {
|
|
19
|
+
return event.errorCode === INVOCATION_ABORTED;
|
|
20
|
+
}
|
|
21
|
+
__name(isAbortEvent, "isAbortEvent");
|
|
22
|
+
function isPausedTaskReply(event) {
|
|
23
|
+
return Boolean(event.isolationScope) && event.author !== "user" && isFinalResponse(event);
|
|
24
|
+
}
|
|
25
|
+
__name(isPausedTaskReply, "isPausedTaskReply");
|
|
26
|
+
function buildAbortEvents({
|
|
27
|
+
events,
|
|
28
|
+
invocationId,
|
|
29
|
+
rootAgentName,
|
|
30
|
+
branch
|
|
31
|
+
}) {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
const invocationEvents = events.filter(
|
|
34
|
+
(e) => e.invocationId === invocationId
|
|
35
|
+
);
|
|
36
|
+
if (invocationEvents.length > 0 && isPausedTaskReply(invocationEvents[invocationEvents.length - 1])) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
const answeredCallIds = /* @__PURE__ */ new Set();
|
|
40
|
+
for (const event of invocationEvents) {
|
|
41
|
+
for (const fr of getFunctionResponses(event)) {
|
|
42
|
+
if (fr.id) {
|
|
43
|
+
answeredCallIds.add(fr.id);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const groupedCalls = /* @__PURE__ */ new Map();
|
|
48
|
+
for (const event of invocationEvents) {
|
|
49
|
+
for (const fc of getFunctionCalls(event)) {
|
|
50
|
+
if (!fc.id || answeredCallIds.has(fc.id)) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const callBranch = event.branch || branch;
|
|
54
|
+
const key = JSON.stringify([
|
|
55
|
+
(_a = event.author) != null ? _a : null,
|
|
56
|
+
callBranch != null ? callBranch : null,
|
|
57
|
+
(_b = event.isolationScope) != null ? _b : null
|
|
58
|
+
]);
|
|
59
|
+
let group = groupedCalls.get(key);
|
|
60
|
+
if (!group) {
|
|
61
|
+
group = {
|
|
62
|
+
author: event.author,
|
|
63
|
+
branch: callBranch,
|
|
64
|
+
isolationScope: event.isolationScope,
|
|
65
|
+
calls: []
|
|
66
|
+
};
|
|
67
|
+
groupedCalls.set(key, group);
|
|
68
|
+
}
|
|
69
|
+
group.calls.push(fc);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (groupedCalls.size === 0) {
|
|
73
|
+
return [
|
|
74
|
+
createEvent({
|
|
75
|
+
invocationId,
|
|
76
|
+
author: rootAgentName,
|
|
77
|
+
branch,
|
|
78
|
+
errorCode: INVOCATION_ABORTED,
|
|
79
|
+
errorMessage: ABORT_MESSAGE
|
|
80
|
+
})
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
return [...groupedCalls.values()].map(
|
|
84
|
+
(group) => createEvent({
|
|
85
|
+
invocationId,
|
|
86
|
+
author: group.author,
|
|
87
|
+
branch: group.branch,
|
|
88
|
+
isolationScope: group.isolationScope,
|
|
89
|
+
content: {
|
|
90
|
+
role: "user",
|
|
91
|
+
parts: group.calls.map((fc) => ({
|
|
92
|
+
functionResponse: {
|
|
93
|
+
id: fc.id,
|
|
94
|
+
name: fc.name,
|
|
95
|
+
response: { error: ABORT_MESSAGE }
|
|
96
|
+
}
|
|
97
|
+
}))
|
|
98
|
+
},
|
|
99
|
+
errorCode: INVOCATION_ABORTED,
|
|
100
|
+
errorMessage: ABORT_MESSAGE
|
|
101
|
+
})
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
__name(buildAbortEvents, "buildAbortEvents");
|
|
105
|
+
export {
|
|
106
|
+
ABORT_MESSAGE,
|
|
107
|
+
INVOCATION_ABORTED,
|
|
108
|
+
buildAbortEvents,
|
|
109
|
+
isAbortEvent
|
|
110
|
+
};
|
package/dist/esm/events/event.js
CHANGED
|
@@ -91,8 +91,10 @@ function stringifyContent(event) {
|
|
|
91
91
|
__name(stringifyContent, "stringifyContent");
|
|
92
92
|
function getEventTokens(event) {
|
|
93
93
|
var _a;
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
const usage = event.usageMetadata;
|
|
95
|
+
const promptTokenCount = (_a = usage == null ? void 0 : usage.initialPromptTokenCount) != null ? _a : usage == null ? void 0 : usage.promptTokenCount;
|
|
96
|
+
if (promptTokenCount !== void 0) {
|
|
97
|
+
return promptTokenCount;
|
|
96
98
|
}
|
|
97
99
|
const contentStr = stringifyContent(event);
|
|
98
100
|
return Math.ceil(contentStr.length / 4);
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
import { logger } from "../utils/logger.js";
|
|
11
|
+
const INTERNAL_METADATA_PREFIX = "__adk_internal_";
|
|
12
|
+
const RESTORED_EVENT_KEY = `${INTERNAL_METADATA_PREFIX}restored_event`;
|
|
13
|
+
function isMetadataObject(value) {
|
|
14
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15
|
+
}
|
|
16
|
+
__name(isMetadataObject, "isMetadataObject");
|
|
17
|
+
function isInternalKey(key) {
|
|
18
|
+
return key.startsWith(INTERNAL_METADATA_PREFIX);
|
|
19
|
+
}
|
|
20
|
+
__name(isInternalKey, "isInternalKey");
|
|
21
|
+
function dropInternalKeys(metadata) {
|
|
22
|
+
return Object.fromEntries(
|
|
23
|
+
Object.entries(metadata).filter(([key]) => !isInternalKey(key))
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
__name(dropInternalKeys, "dropInternalKeys");
|
|
27
|
+
function hasInternalKeys(metadata) {
|
|
28
|
+
return isMetadataObject(metadata) && Object.keys(metadata).some(isInternalKey);
|
|
29
|
+
}
|
|
30
|
+
__name(hasInternalKeys, "hasInternalKeys");
|
|
31
|
+
function withoutInternalMetadata(metadata) {
|
|
32
|
+
if (!isMetadataObject(metadata)) {
|
|
33
|
+
return metadata;
|
|
34
|
+
}
|
|
35
|
+
const kept = dropInternalKeys(metadata);
|
|
36
|
+
const dropped = Object.keys(metadata).filter(isInternalKey);
|
|
37
|
+
if (dropped.length > 0) {
|
|
38
|
+
logger.debug(
|
|
39
|
+
`Dropping ADK-internal customMetadata keys: ${JSON.stringify(dropped.sort())}`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
return kept;
|
|
43
|
+
}
|
|
44
|
+
__name(withoutInternalMetadata, "withoutInternalMetadata");
|
|
45
|
+
function publicMetadata(metadata) {
|
|
46
|
+
if (!isMetadataObject(metadata)) {
|
|
47
|
+
return metadata;
|
|
48
|
+
}
|
|
49
|
+
const kept = dropInternalKeys(metadata);
|
|
50
|
+
return Object.keys(kept).length > 0 ? kept : void 0;
|
|
51
|
+
}
|
|
52
|
+
__name(publicMetadata, "publicMetadata");
|
|
53
|
+
function internalMetadata(metadata) {
|
|
54
|
+
if (!isMetadataObject(metadata)) {
|
|
55
|
+
return {};
|
|
56
|
+
}
|
|
57
|
+
return Object.fromEntries(
|
|
58
|
+
Object.entries(metadata).filter(([key]) => isInternalKey(key))
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
__name(internalMetadata, "internalMetadata");
|
|
62
|
+
function markRestored(event) {
|
|
63
|
+
var _a;
|
|
64
|
+
event.customMetadata = {
|
|
65
|
+
...(_a = withoutInternalMetadata(event.customMetadata)) != null ? _a : {},
|
|
66
|
+
[RESTORED_EVENT_KEY]: true
|
|
67
|
+
};
|
|
68
|
+
return event;
|
|
69
|
+
}
|
|
70
|
+
__name(markRestored, "markRestored");
|
|
71
|
+
function publicEvent(event) {
|
|
72
|
+
if (!hasInternalKeys(event.customMetadata)) {
|
|
73
|
+
return event;
|
|
74
|
+
}
|
|
75
|
+
return { ...event, customMetadata: publicMetadata(event.customMetadata) };
|
|
76
|
+
}
|
|
77
|
+
__name(publicEvent, "publicEvent");
|
|
78
|
+
function publicSession(session) {
|
|
79
|
+
var _a;
|
|
80
|
+
const events = (_a = session.events) != null ? _a : [];
|
|
81
|
+
const publicEvents = events.map((event) => publicEvent(event));
|
|
82
|
+
if (publicEvents.every((event, i) => event === events[i])) {
|
|
83
|
+
return session;
|
|
84
|
+
}
|
|
85
|
+
return { ...session, events: publicEvents };
|
|
86
|
+
}
|
|
87
|
+
__name(publicSession, "publicSession");
|
|
88
|
+
export {
|
|
89
|
+
INTERNAL_METADATA_PREFIX,
|
|
90
|
+
RESTORED_EVENT_KEY,
|
|
91
|
+
internalMetadata,
|
|
92
|
+
markRestored,
|
|
93
|
+
publicEvent,
|
|
94
|
+
publicMetadata,
|
|
95
|
+
publicSession,
|
|
96
|
+
withoutInternalMetadata
|
|
97
|
+
};
|
|
@@ -7,11 +7,30 @@ 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
|
+
import { z } from "zod";
|
|
11
|
+
import { InputValidationError } from "../errors/input_validation_error.js";
|
|
10
12
|
import { getFunctionResponses } from "../events/event.js";
|
|
11
13
|
import { logger } from "../utils/logger.js";
|
|
12
14
|
import {
|
|
13
15
|
isBaseExampleProvider
|
|
14
16
|
} from "./base_example_provider.js";
|
|
17
|
+
const contentSchema = z.object({
|
|
18
|
+
role: z.string().optional(),
|
|
19
|
+
parts: z.array(z.object({}).loose()).optional()
|
|
20
|
+
}).loose();
|
|
21
|
+
const examplesSchema = z.array(
|
|
22
|
+
z.object({ input: contentSchema, output: z.array(contentSchema) })
|
|
23
|
+
);
|
|
24
|
+
function validateExamples(examples) {
|
|
25
|
+
const result = examplesSchema.safeParse(examples);
|
|
26
|
+
if (!result.success) {
|
|
27
|
+
throw new InputValidationError(
|
|
28
|
+
`Invalid few-shot examples:
|
|
29
|
+
${z.prettifyError(result.error)}`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
__name(validateExamples, "validateExamples");
|
|
15
34
|
const EXAMPLES_INTRO = "<EXAMPLES>\nBegin few-shot\nThe following are examples of user queries and model responses using the available tools.\n\n";
|
|
16
35
|
const EXAMPLES_END = "End few-shot\n<EXAMPLES>";
|
|
17
36
|
const EXAMPLE_START = "EXAMPLE {}:\nBegin example\n";
|
|
@@ -102,5 +121,6 @@ export {
|
|
|
102
121
|
_getLatestMessageFromUser,
|
|
103
122
|
buildExampleSi,
|
|
104
123
|
convertExamplesToText,
|
|
105
|
-
getLatestMessageFromUser
|
|
124
|
+
getLatestMessageFromUser,
|
|
125
|
+
validateExamples
|
|
106
126
|
};
|
|
@@ -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;
|