@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,111 @@
|
|
|
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 * as fs from "node:fs";
|
|
11
|
+
import * as os from "node:os";
|
|
12
|
+
import * as path from "node:path";
|
|
13
|
+
import * as util from "node:util";
|
|
14
|
+
import { LogLevel, setLogger, setLogLevel } from "../../utils/logger.js";
|
|
15
|
+
const LOGGING_FORMAT = "%(asctime)s - %(levelname)s - %(filename)s:%(lineno)d - %(message)s";
|
|
16
|
+
const LOG_LEVEL_NAMES = {
|
|
17
|
+
[LogLevel.DEBUG]: "DEBUG",
|
|
18
|
+
[LogLevel.INFO]: "INFO",
|
|
19
|
+
[LogLevel.WARN]: "WARNING",
|
|
20
|
+
[LogLevel.ERROR]: "ERROR"
|
|
21
|
+
};
|
|
22
|
+
function formatDateTimestamp(date) {
|
|
23
|
+
const pad = /* @__PURE__ */ __name((n) => String(n).padStart(2, "0"), "pad");
|
|
24
|
+
return `${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(date.getDate())}_${pad(date.getHours())}${pad(date.getMinutes())}${pad(date.getSeconds())}`;
|
|
25
|
+
}
|
|
26
|
+
__name(formatDateTimestamp, "formatDateTimestamp");
|
|
27
|
+
function formatLogLine(level, messages) {
|
|
28
|
+
var _a;
|
|
29
|
+
const iso = (/* @__PURE__ */ new Date()).toISOString();
|
|
30
|
+
const levelName = (_a = LOG_LEVEL_NAMES[level]) != null ? _a : "INFO";
|
|
31
|
+
const formattedMessage = messages.map((m) => typeof m === "string" ? m : util.inspect(m, { depth: null })).join(" ");
|
|
32
|
+
return `${iso} - ${levelName} - ${formattedMessage}`;
|
|
33
|
+
}
|
|
34
|
+
__name(formatLogLine, "formatLogLine");
|
|
35
|
+
function createWriterLogger(initialLevel, writeLine) {
|
|
36
|
+
let currentLevel = initialLevel;
|
|
37
|
+
const logAt = /* @__PURE__ */ __name((targetLevel, messages) => {
|
|
38
|
+
if (currentLevel <= targetLevel) {
|
|
39
|
+
writeLine(formatLogLine(targetLevel, messages));
|
|
40
|
+
}
|
|
41
|
+
}, "logAt");
|
|
42
|
+
return {
|
|
43
|
+
setLogLevel(level) {
|
|
44
|
+
currentLevel = level;
|
|
45
|
+
},
|
|
46
|
+
log(level, ...messages) {
|
|
47
|
+
logAt(level, messages);
|
|
48
|
+
},
|
|
49
|
+
debug(...messages) {
|
|
50
|
+
logAt(LogLevel.DEBUG, messages);
|
|
51
|
+
},
|
|
52
|
+
info(...messages) {
|
|
53
|
+
logAt(LogLevel.INFO, messages);
|
|
54
|
+
},
|
|
55
|
+
warn(...messages) {
|
|
56
|
+
logAt(LogLevel.WARN, messages);
|
|
57
|
+
},
|
|
58
|
+
error(...messages) {
|
|
59
|
+
logAt(LogLevel.ERROR, messages);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
__name(createWriterLogger, "createWriterLogger");
|
|
64
|
+
function logToStderr(level = LogLevel.INFO) {
|
|
65
|
+
setLogLevel(level);
|
|
66
|
+
setLogger(
|
|
67
|
+
createWriterLogger(level, (line) => {
|
|
68
|
+
process.stderr.write(`${line}
|
|
69
|
+
`);
|
|
70
|
+
})
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
__name(logToStderr, "logToStderr");
|
|
74
|
+
function logToTmpFolder(options = {}) {
|
|
75
|
+
const {
|
|
76
|
+
level = LogLevel.INFO,
|
|
77
|
+
subFolder = "agents_log",
|
|
78
|
+
logFilePrefix = "agent",
|
|
79
|
+
logFileTimestamp = formatDateTimestamp(/* @__PURE__ */ new Date())
|
|
80
|
+
} = options;
|
|
81
|
+
const logDir = path.join(os.tmpdir(), subFolder);
|
|
82
|
+
fs.mkdirSync(logDir, { recursive: true });
|
|
83
|
+
const logFilename = `${logFilePrefix}.${logFileTimestamp}.log`;
|
|
84
|
+
const logFilepath = path.join(logDir, logFilename);
|
|
85
|
+
fs.writeFileSync(logFilepath, "", "utf-8");
|
|
86
|
+
setLogLevel(level);
|
|
87
|
+
const fileLogger = createWriterLogger(level, (line) => {
|
|
88
|
+
fs.appendFileSync(logFilepath, `${line}
|
|
89
|
+
`, "utf-8");
|
|
90
|
+
});
|
|
91
|
+
setLogger(fileLogger);
|
|
92
|
+
const latestLogLink = path.join(logDir, `${logFilePrefix}.latest.log`);
|
|
93
|
+
try {
|
|
94
|
+
try {
|
|
95
|
+
fs.lstatSync(latestLogLink);
|
|
96
|
+
fs.unlinkSync(latestLogLink);
|
|
97
|
+
} catch {
|
|
98
|
+
}
|
|
99
|
+
fs.symlinkSync(logFilepath, latestLogLink);
|
|
100
|
+
} catch (e) {
|
|
101
|
+
fileLogger.warn(`Failed to create symlink to latest log: ${String(e)}`);
|
|
102
|
+
}
|
|
103
|
+
fileLogger.info(`Log setup complete: ${logFilepath}`);
|
|
104
|
+
return logFilepath;
|
|
105
|
+
}
|
|
106
|
+
__name(logToTmpFolder, "logToTmpFolder");
|
|
107
|
+
export {
|
|
108
|
+
LOGGING_FORMAT,
|
|
109
|
+
logToStderr,
|
|
110
|
+
logToTmpFolder
|
|
111
|
+
};
|
|
@@ -27,6 +27,7 @@ import { BaseCodeExecutor } from "./base_code_executor.js";
|
|
|
27
27
|
import {
|
|
28
28
|
CodeExecutionLanguage
|
|
29
29
|
} from "./code_execution_utils.js";
|
|
30
|
+
import { CONTEXT_KEY } from "./code_executor_context.js";
|
|
30
31
|
const DEFAULT_MAX_ATTEMPTS = 180;
|
|
31
32
|
const DEFAULT_SANDBOX_TTL = "31536000s";
|
|
32
33
|
const DEFAULT_SANDBOX_DISPLAY_NAME = "default_sandbox";
|
|
@@ -208,12 +209,14 @@ let AgentEngineSandboxCodeExecutor = class extends BaseCodeExecutor {
|
|
|
208
209
|
return this.agentEngineCreationPromise;
|
|
209
210
|
}
|
|
210
211
|
async getOrCreateSandbox(invocationContext, agentEngineName, language) {
|
|
211
|
-
var _a, _b;
|
|
212
|
+
var _a, _b, _c, _d, _e;
|
|
212
213
|
if (this.sandboxResourceName) {
|
|
213
214
|
return this.sandboxResourceName;
|
|
214
215
|
}
|
|
215
216
|
const stateKey = `sandbox_name_${language.toLowerCase()}`;
|
|
216
|
-
|
|
217
|
+
const state = (_a = invocationContext.session) == null ? void 0 : _a.state;
|
|
218
|
+
const codeExecutionContext = state == null ? void 0 : state[CONTEXT_KEY];
|
|
219
|
+
let sandboxName = (_b = state == null ? void 0 : state[stateKey]) != null ? _b : codeExecutionContext == null ? void 0 : codeExecutionContext[stateKey];
|
|
217
220
|
let createNewSandbox = false;
|
|
218
221
|
if (!sandboxName) {
|
|
219
222
|
createNewSandbox = true;
|
|
@@ -270,6 +273,8 @@ let AgentEngineSandboxCodeExecutor = class extends BaseCodeExecutor {
|
|
|
270
273
|
invocationContext.session.state = {};
|
|
271
274
|
}
|
|
272
275
|
invocationContext.session.state[stateKey] = sandboxName;
|
|
276
|
+
const context = (_e = (_c = invocationContext.session.state)[_d = CONTEXT_KEY]) != null ? _e : _c[_d] = {};
|
|
277
|
+
context[stateKey] = sandboxName;
|
|
273
278
|
}
|
|
274
279
|
}
|
|
275
280
|
return sandboxName;
|
|
@@ -29,33 +29,62 @@ function getEncodedFileContent(data) {
|
|
|
29
29
|
return isBase64Encoded(data) ? data : base64Encode(data);
|
|
30
30
|
}
|
|
31
31
|
__name(getEncodedFileContent, "getEncodedFileContent");
|
|
32
|
+
const FENCE_TAG_LANGUAGE_MAP = {
|
|
33
|
+
tool_code: "python" /* PYTHON */,
|
|
34
|
+
python: "python" /* PYTHON */,
|
|
35
|
+
py: "python" /* PYTHON */,
|
|
36
|
+
javascript: "javascript" /* JAVASCRIPT */,
|
|
37
|
+
js: "javascript" /* JAVASCRIPT */,
|
|
38
|
+
typescript: "typescript" /* TYPESCRIPT */,
|
|
39
|
+
ts: "typescript" /* TYPESCRIPT */,
|
|
40
|
+
bash: "shell" /* SHELL */,
|
|
41
|
+
sh: "shell" /* SHELL */,
|
|
42
|
+
shell: "shell" /* SHELL */
|
|
43
|
+
};
|
|
44
|
+
const NO_CODE_BLOCK = Object.freeze({
|
|
45
|
+
code: "",
|
|
46
|
+
language: "unspecified" /* UNSPECIFIED */
|
|
47
|
+
});
|
|
48
|
+
function getCodeBlockLanguage(leadingDelimiter) {
|
|
49
|
+
var _a;
|
|
50
|
+
const tag = leadingDelimiter.trim().replace(/^`+/, "").toLowerCase();
|
|
51
|
+
return (_a = FENCE_TAG_LANGUAGE_MAP[tag]) != null ? _a : "unspecified" /* UNSPECIFIED */;
|
|
52
|
+
}
|
|
53
|
+
__name(getCodeBlockLanguage, "getCodeBlockLanguage");
|
|
32
54
|
function extractCodeAndTruncateContent(content, codeBlockDelimiters) {
|
|
55
|
+
return extractCodeBlockAndTruncateContent(content, codeBlockDelimiters).code;
|
|
56
|
+
}
|
|
57
|
+
__name(extractCodeAndTruncateContent, "extractCodeAndTruncateContent");
|
|
58
|
+
function extractCodeBlockAndTruncateContent(content, codeBlockDelimiters) {
|
|
33
59
|
var _a;
|
|
34
60
|
if (!((_a = content.parts) == null ? void 0 : _a.length)) {
|
|
35
|
-
return
|
|
61
|
+
return { ...NO_CODE_BLOCK };
|
|
36
62
|
}
|
|
37
63
|
for (let i = 0; i < content.parts.length; i++) {
|
|
38
64
|
const part = content.parts[i];
|
|
39
65
|
if (part.executableCode && (i === content.parts.length - 1 || !content.parts[i + 1].codeExecutionResult)) {
|
|
40
66
|
content.parts = content.parts.slice(0, i + 1);
|
|
41
|
-
return
|
|
67
|
+
return {
|
|
68
|
+
code: part.executableCode.code || "",
|
|
69
|
+
language: "python" /* PYTHON */
|
|
70
|
+
};
|
|
42
71
|
}
|
|
43
72
|
}
|
|
44
73
|
const textParts = content.parts.filter((part) => part.text);
|
|
45
74
|
if (!textParts.length) {
|
|
46
|
-
return
|
|
75
|
+
return { ...NO_CODE_BLOCK };
|
|
47
76
|
}
|
|
48
77
|
const firstTextPart = cloneDeep(textParts[0]);
|
|
49
78
|
const responseText = textParts.map((part) => part.text).join("\n");
|
|
50
79
|
const leadingDelimiterPattern = codeBlockDelimiters.map((d) => d[0]).join("|");
|
|
51
80
|
const trailingDelimiterPattern = codeBlockDelimiters.map((d) => d[1]).join("|");
|
|
52
81
|
const match = new RegExp(
|
|
53
|
-
`(?<prefix>.*?)(
|
|
82
|
+
`(?<prefix>.*?)(?<leading>${leadingDelimiterPattern})(?<codeStr>.*?)(${trailingDelimiterPattern})(?<suffix>.*?)$`,
|
|
54
83
|
"s"
|
|
55
84
|
).exec(responseText);
|
|
56
|
-
const { prefix, codeStr } = (match == null ? void 0 : match.groups) || {};
|
|
85
|
+
const { prefix, leading, codeStr } = (match == null ? void 0 : match.groups) || {};
|
|
57
86
|
if (!codeStr) {
|
|
58
|
-
return
|
|
87
|
+
return { ...NO_CODE_BLOCK };
|
|
59
88
|
}
|
|
60
89
|
content.parts = [];
|
|
61
90
|
if (prefix) {
|
|
@@ -63,12 +92,11 @@ function extractCodeAndTruncateContent(content, codeBlockDelimiters) {
|
|
|
63
92
|
content.parts.push(firstTextPart);
|
|
64
93
|
}
|
|
65
94
|
content.parts.push(buildExecutableCodePart(codeStr));
|
|
66
|
-
return codeStr;
|
|
95
|
+
return { code: codeStr, language: getCodeBlockLanguage(leading != null ? leading : "") };
|
|
67
96
|
}
|
|
68
|
-
__name(
|
|
97
|
+
__name(extractCodeBlockAndTruncateContent, "extractCodeBlockAndTruncateContent");
|
|
69
98
|
function buildExecutableCodePart(code) {
|
|
70
99
|
return {
|
|
71
|
-
text: code,
|
|
72
100
|
executableCode: {
|
|
73
101
|
code,
|
|
74
102
|
language: Language.PYTHON
|
|
@@ -79,28 +107,28 @@ __name(buildExecutableCodePart, "buildExecutableCodePart");
|
|
|
79
107
|
function buildCodeExecutionResultPart(codeExecutionResult) {
|
|
80
108
|
if (codeExecutionResult.stderr) {
|
|
81
109
|
return {
|
|
82
|
-
text: codeExecutionResult.stderr,
|
|
83
110
|
codeExecutionResult: {
|
|
84
|
-
outcome: Outcome.OUTCOME_FAILED
|
|
111
|
+
outcome: Outcome.OUTCOME_FAILED,
|
|
112
|
+
output: codeExecutionResult.stderr
|
|
85
113
|
}
|
|
86
114
|
};
|
|
87
115
|
}
|
|
88
116
|
const finalResult = [];
|
|
89
|
-
if (codeExecutionResult.stdout || !codeExecutionResult.outputFiles) {
|
|
117
|
+
if (codeExecutionResult.stdout || !codeExecutionResult.outputFiles.length) {
|
|
90
118
|
finalResult.push(`Code execution result:
|
|
91
119
|
${codeExecutionResult.stdout}
|
|
92
120
|
`);
|
|
93
121
|
}
|
|
94
|
-
if (codeExecutionResult.outputFiles) {
|
|
122
|
+
if (codeExecutionResult.outputFiles.length) {
|
|
95
123
|
finalResult.push(
|
|
96
124
|
`Saved artifacts:
|
|
97
|
-
` + codeExecutionResult.outputFiles.map((f) => f.name).join(",
|
|
125
|
+
` + codeExecutionResult.outputFiles.map((f) => `\`${f.name}\``).join(",")
|
|
98
126
|
);
|
|
99
127
|
}
|
|
100
128
|
return {
|
|
101
|
-
text: finalResult.join("\n\n"),
|
|
102
129
|
codeExecutionResult: {
|
|
103
|
-
outcome: Outcome.OUTCOME_OK
|
|
130
|
+
outcome: Outcome.OUTCOME_OK,
|
|
131
|
+
output: finalResult.join("\n\n")
|
|
104
132
|
}
|
|
105
133
|
};
|
|
106
134
|
}
|
|
@@ -130,5 +158,7 @@ export {
|
|
|
130
158
|
buildExecutableCodePart,
|
|
131
159
|
convertCodeExecutionParts,
|
|
132
160
|
extractCodeAndTruncateContent,
|
|
161
|
+
extractCodeBlockAndTruncateContent,
|
|
162
|
+
getCodeBlockLanguage,
|
|
133
163
|
getEncodedFileContent
|
|
134
164
|
};
|
|
@@ -17,8 +17,10 @@ const CODE_EXECUTION_RESULTS_KEY = "_code_execution_results";
|
|
|
17
17
|
const _CodeExecutorContext = class _CodeExecutorContext {
|
|
18
18
|
constructor(sessionState) {
|
|
19
19
|
this.sessionState = sessionState;
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
if (!sessionState.has(CONTEXT_KEY)) {
|
|
21
|
+
sessionState.set(CONTEXT_KEY, {});
|
|
22
|
+
}
|
|
23
|
+
this.context = sessionState.get(CONTEXT_KEY);
|
|
22
24
|
this.sessionState = sessionState;
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
@@ -170,5 +172,6 @@ const _CodeExecutorContext = class _CodeExecutorContext {
|
|
|
170
172
|
__name(_CodeExecutorContext, "CodeExecutorContext");
|
|
171
173
|
let CodeExecutorContext = _CodeExecutorContext;
|
|
172
174
|
export {
|
|
175
|
+
CONTEXT_KEY,
|
|
173
176
|
CodeExecutorContext
|
|
174
177
|
};
|
package/dist/esm/common.js
CHANGED
|
@@ -15,9 +15,20 @@ import {
|
|
|
15
15
|
findEventByFunctionCallId,
|
|
16
16
|
findMatchingFunctionCall,
|
|
17
17
|
functionsExportedForTestingOnly,
|
|
18
|
+
handleFunctionCallsLive,
|
|
18
19
|
isToolNotFound
|
|
19
20
|
} from "./agents/functions.js";
|
|
20
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
InvocationContext,
|
|
23
|
+
LlmCallsLimitExceededError,
|
|
24
|
+
isLlmCallsLimitExceededError,
|
|
25
|
+
requireAgent
|
|
26
|
+
} from "./agents/invocation_context.js";
|
|
27
|
+
import {
|
|
28
|
+
LangGraphAgent,
|
|
29
|
+
getLastHumanMessages,
|
|
30
|
+
isLangGraphAgent
|
|
31
|
+
} from "./agents/langgraph_agent.js";
|
|
21
32
|
import { LiveRequestQueue } from "./agents/live_request_queue.js";
|
|
22
33
|
import { LlmAgent, LlmAgent as LlmAgent2, isLlmAgent } from "./agents/llm_agent.js";
|
|
23
34
|
import { LoopAgent, isLoopAgent } from "./agents/loop_agent.js";
|
|
@@ -27,6 +38,7 @@ import {
|
|
|
27
38
|
BaseLlmRequestProcessor,
|
|
28
39
|
BaseLlmResponseProcessor
|
|
29
40
|
} from "./agents/processors/base_llm_processor.js";
|
|
41
|
+
import { CodeExecutionResponseProcessor } from "./agents/processors/code_execution_request_processor.js";
|
|
30
42
|
import {
|
|
31
43
|
CONTENT_REQUEST_PROCESSOR,
|
|
32
44
|
ContentRequestProcessor
|
|
@@ -37,8 +49,9 @@ import {
|
|
|
37
49
|
InteractionsRequestProcessor
|
|
38
50
|
} from "./agents/processors/interactions_request_processor.js";
|
|
39
51
|
import { ReadonlyContext } from "./agents/readonly_context.js";
|
|
52
|
+
import { RemoteAgent, isRemoteAgent } from "./agents/remote_agent.js";
|
|
40
53
|
import { RoutedAgent, isRoutedAgent } from "./agents/routed_agent.js";
|
|
41
|
-
import { StreamingMode } from "./agents/run_config.js";
|
|
54
|
+
import { StreamingMode, createRunConfig } from "./agents/run_config.js";
|
|
42
55
|
import { SequentialAgent, isSequentialAgent } from "./agents/sequential_agent.js";
|
|
43
56
|
import {
|
|
44
57
|
getPendingUserInputRequests,
|
|
@@ -53,7 +66,11 @@ import { AuthCredentialTypes, isAuthCredential } from "./auth/auth_credential.js
|
|
|
53
66
|
import { AuthHandler } from "./auth/auth_handler.js";
|
|
54
67
|
import { AUTH_PREPROCESSOR, AuthPreprocessor } from "./auth/auth_preprocessor.js";
|
|
55
68
|
import { AuthProviderRegistry } from "./auth/auth_provider_registry.js";
|
|
56
|
-
import {
|
|
69
|
+
import {
|
|
70
|
+
AuthSchemeType,
|
|
71
|
+
OAuthGrantType,
|
|
72
|
+
getOAuthGrantTypeFromFlow
|
|
73
|
+
} from "./auth/auth_schemes.js";
|
|
57
74
|
import { InMemoryCredentialService } from "./auth/credential_service/in_memory_credential_service.js";
|
|
58
75
|
import { SessionStateCredentialService } from "./auth/credential_service/session_state_credential_service.js";
|
|
59
76
|
import { CredentialExchangeError } from "./auth/exchanger/base_credential_exchanger.js";
|
|
@@ -95,6 +112,14 @@ import {
|
|
|
95
112
|
stringifyContent
|
|
96
113
|
} from "./events/event.js";
|
|
97
114
|
import { createEventActions } from "./events/event_actions.js";
|
|
115
|
+
import {
|
|
116
|
+
INTERNAL_METADATA_PREFIX,
|
|
117
|
+
RESTORED_EVENT_KEY,
|
|
118
|
+
markRestored,
|
|
119
|
+
publicEvent,
|
|
120
|
+
publicMetadata,
|
|
121
|
+
publicSession
|
|
122
|
+
} from "./events/internal_metadata.js";
|
|
98
123
|
import { EventType, toStructuredEvents } from "./events/structured_events.js";
|
|
99
124
|
import {
|
|
100
125
|
BaseExampleProvider,
|
|
@@ -110,6 +135,8 @@ import {
|
|
|
110
135
|
stripAdkIdentityPreamble
|
|
111
136
|
} from "./models/chrome_prompt_llm.js";
|
|
112
137
|
import { Gemini, geminiInitParams } from "./models/google_llm.js";
|
|
138
|
+
import { appendInstructions } from "./models/llm_request.js";
|
|
139
|
+
import { createLlmResponse } from "./models/llm_response.js";
|
|
113
140
|
import { LLMRegistry } from "./models/registry.js";
|
|
114
141
|
import { RoutedLlm } from "./models/routed_llm.js";
|
|
115
142
|
import { BasePlanner, isBasePlanner } from "./planners/base_planner.js";
|
|
@@ -140,6 +167,10 @@ import {
|
|
|
140
167
|
SecurityPlugin,
|
|
141
168
|
getAskUserConfirmationFunctionCalls
|
|
142
169
|
} from "./plugins/security_plugin.js";
|
|
170
|
+
import {
|
|
171
|
+
ToolCallIntegrityError,
|
|
172
|
+
ToolCallIntegrityPlugin
|
|
173
|
+
} from "./plugins/tool_call_integrity_plugin.js";
|
|
143
174
|
import { InMemoryRunner } from "./runner/in_memory_runner.js";
|
|
144
175
|
import {
|
|
145
176
|
Runner,
|
|
@@ -207,6 +238,8 @@ import {
|
|
|
207
238
|
import { AsyncQueue } from "./utils/async_queue.js";
|
|
208
239
|
import { renameReservedKeywords, toSnakeCaseName } from "./utils/case_utils.js";
|
|
209
240
|
import { getClientLabels, runWithClientLabel } from "./utils/client_labels.js";
|
|
241
|
+
import { toGeminiSchema } from "./utils/gemini_schema_util.js";
|
|
242
|
+
import { genaiSchemaToJsonSchema } from "./utils/genai_schema_to_json.js";
|
|
210
243
|
import {
|
|
211
244
|
LogLevel,
|
|
212
245
|
getLogger,
|
|
@@ -221,6 +254,7 @@ import {
|
|
|
221
254
|
isGemini3xFlashLive,
|
|
222
255
|
isGemini3xLive
|
|
223
256
|
} from "./utils/model_name.js";
|
|
257
|
+
import { toJsonSchema } from "./utils/schema.js";
|
|
224
258
|
import { zodObjectToSchema } from "./utils/simple_zod_to_json.js";
|
|
225
259
|
import { Task } from "./utils/task.js";
|
|
226
260
|
import { GoogleLLMVariant } from "./utils/variant_utils.js";
|
|
@@ -276,6 +310,19 @@ export * from "./features/feature_registry.js";
|
|
|
276
310
|
export * from "./memory/base_memory_service.js";
|
|
277
311
|
export * from "./sessions/base_session_service.js";
|
|
278
312
|
export * from "./tools/base_tool.js";
|
|
313
|
+
import {
|
|
314
|
+
convertSessionToEvalFormat,
|
|
315
|
+
createEmptyState
|
|
316
|
+
} from "./cli/utils/evals.js";
|
|
317
|
+
import { CrewaiTool, isCrewaiTool } from "./tools/crewai_tool.js";
|
|
318
|
+
import {
|
|
319
|
+
buildFunctionDeclarationForLangchain,
|
|
320
|
+
buildFunctionDeclarationForParamsForCrewai,
|
|
321
|
+
buildFunctionDeclarationUtil
|
|
322
|
+
} from "./tools/function_tool.js";
|
|
323
|
+
import { LangchainTool, isLangchainTool } from "./tools/langchain_tool.js";
|
|
324
|
+
import { isBaseRetrievalTool } from "./tools/retrieval/base_retrieval_tool.js";
|
|
325
|
+
import { ToolboxTool, isToolboxTool } from "./tools/toolbox_tool.js";
|
|
279
326
|
export {
|
|
280
327
|
ADK_HANDLE_MODEL_ERROR_TOOL_NAME,
|
|
281
328
|
AUTH_PREPROCESSOR,
|
|
@@ -293,6 +340,7 @@ export {
|
|
|
293
340
|
AuthHandler,
|
|
294
341
|
AuthPreprocessor,
|
|
295
342
|
AuthProviderRegistry,
|
|
343
|
+
AuthSchemeType,
|
|
296
344
|
BaseAgent,
|
|
297
345
|
BaseCodeExecutor,
|
|
298
346
|
BaseEnvironment,
|
|
@@ -316,6 +364,7 @@ export {
|
|
|
316
364
|
ChromeBuiltInLlm,
|
|
317
365
|
ChromeModelUnavailableError,
|
|
318
366
|
CodeExecutionLanguage,
|
|
367
|
+
CodeExecutionResponseProcessor,
|
|
319
368
|
ConsolidateContextTool,
|
|
320
369
|
ContentRequestProcessor,
|
|
321
370
|
Context,
|
|
@@ -323,6 +372,7 @@ export {
|
|
|
323
372
|
ContextCompactorRequestProcessor,
|
|
324
373
|
CredentialExchangeError,
|
|
325
374
|
CredentialRefresherRegistry,
|
|
375
|
+
CrewaiTool,
|
|
326
376
|
DEFAULT_ROUTE,
|
|
327
377
|
ENTERPRISE_WEB_SEARCH,
|
|
328
378
|
EXIT_LOOP,
|
|
@@ -348,6 +398,7 @@ export {
|
|
|
348
398
|
GoogleSearchTool,
|
|
349
399
|
Graph,
|
|
350
400
|
INTERACTIONS_REQUEST_PROCESSOR,
|
|
401
|
+
INTERNAL_METADATA_PREFIX,
|
|
351
402
|
InMemoryArtifactService,
|
|
352
403
|
InMemoryCredentialService,
|
|
353
404
|
InMemoryMemoryService,
|
|
@@ -362,10 +413,13 @@ export {
|
|
|
362
413
|
LLMRegistry,
|
|
363
414
|
LOAD_ARTIFACTS,
|
|
364
415
|
LOAD_MEMORY,
|
|
416
|
+
LangGraphAgent,
|
|
417
|
+
LangchainTool,
|
|
365
418
|
ListSkillsTool,
|
|
366
419
|
LiveRequestQueue,
|
|
367
420
|
LlamaIndexRetrieval,
|
|
368
421
|
LlmAgent2 as LlmAgent,
|
|
422
|
+
LlmCallsLimitExceededError,
|
|
369
423
|
LlmSummarizer,
|
|
370
424
|
LoadArtifactsTool,
|
|
371
425
|
LoadMemoryTool,
|
|
@@ -396,9 +450,11 @@ export {
|
|
|
396
450
|
REQUEST_CREDENTIAL_FUNCTION_CALL_NAME,
|
|
397
451
|
REQUEST_INPUT_FUNCTION_CALL_NAME,
|
|
398
452
|
RESERVED_TOOL_CALL_ERROR_TYPE,
|
|
453
|
+
RESTORED_EVENT_KEY,
|
|
399
454
|
ReadonlyContext,
|
|
400
455
|
ReflectAndRetryModelPlugin,
|
|
401
456
|
ReflectAndRetryToolPlugin,
|
|
457
|
+
RemoteAgent,
|
|
402
458
|
RequestInput,
|
|
403
459
|
RoutedAgent,
|
|
404
460
|
RoutedLlm,
|
|
@@ -416,11 +472,14 @@ export {
|
|
|
416
472
|
StreamingMode,
|
|
417
473
|
Task,
|
|
418
474
|
TokenBasedContextCompactor,
|
|
475
|
+
ToolCallIntegrityError,
|
|
476
|
+
ToolCallIntegrityPlugin,
|
|
419
477
|
ToolConfirmation,
|
|
420
478
|
ToolContext,
|
|
421
479
|
ToolErrorType,
|
|
422
480
|
ToolExecutionError,
|
|
423
481
|
ToolNode,
|
|
482
|
+
ToolboxTool,
|
|
424
483
|
TrackingScope,
|
|
425
484
|
TrajectoryThoughtPruningCompactor,
|
|
426
485
|
TruncatingContextCompactor,
|
|
@@ -433,13 +492,21 @@ export {
|
|
|
433
492
|
WebMCPToolset,
|
|
434
493
|
Workflow,
|
|
435
494
|
WorkflowNode,
|
|
495
|
+
appendInstructions,
|
|
436
496
|
asRunnableRoot,
|
|
497
|
+
buildFunctionDeclarationForLangchain,
|
|
498
|
+
buildFunctionDeclarationForParamsForCrewai,
|
|
499
|
+
buildFunctionDeclarationUtil,
|
|
437
500
|
commonPrefixOf,
|
|
501
|
+
convertSessionToEvalFormat,
|
|
502
|
+
createEmptyState,
|
|
438
503
|
createEvent,
|
|
439
504
|
createEventActions,
|
|
505
|
+
createLlmResponse,
|
|
440
506
|
createNodeErrorEvent,
|
|
441
507
|
createNodeState,
|
|
442
508
|
createResumabilityConfig,
|
|
509
|
+
createRunConfig,
|
|
443
510
|
createSession,
|
|
444
511
|
createSubBranch,
|
|
445
512
|
determineAgentForResumption,
|
|
@@ -448,16 +515,20 @@ export {
|
|
|
448
515
|
findMatchingFunctionCall,
|
|
449
516
|
functionsExportedForTestingOnly,
|
|
450
517
|
geminiInitParams,
|
|
518
|
+
genaiSchemaToJsonSchema,
|
|
451
519
|
generateClientFunctionCallId,
|
|
452
520
|
getAskUserConfirmationFunctionCalls,
|
|
453
521
|
getClientLabels,
|
|
454
522
|
getFunctionCalls,
|
|
455
523
|
getFunctionResponses,
|
|
524
|
+
getLastHumanMessages,
|
|
456
525
|
getLogger,
|
|
457
526
|
getModelContext,
|
|
527
|
+
getOAuthGrantTypeFromFlow,
|
|
458
528
|
getPendingUserInputRequests,
|
|
459
529
|
getUserChoiceTool,
|
|
460
530
|
getUserInputRequests,
|
|
531
|
+
handleFunctionCallsLive,
|
|
461
532
|
hasThoughts,
|
|
462
533
|
hasTrailingCodeExecutionResult,
|
|
463
534
|
isAgentTool,
|
|
@@ -467,10 +538,12 @@ export {
|
|
|
467
538
|
isBaseExampleProvider,
|
|
468
539
|
isBaseLlm,
|
|
469
540
|
isBasePlanner,
|
|
541
|
+
isBaseRetrievalTool,
|
|
470
542
|
isBaseTool,
|
|
471
543
|
isBaseToolset,
|
|
472
544
|
isBuiltInPlanner,
|
|
473
545
|
isCompactedEvent,
|
|
546
|
+
isCrewaiTool,
|
|
474
547
|
isFinalResponse,
|
|
475
548
|
isFunctionTool,
|
|
476
549
|
isGemini2OrAbove,
|
|
@@ -478,7 +551,10 @@ export {
|
|
|
478
551
|
isGemini3xFlashLive,
|
|
479
552
|
isGemini3xLive,
|
|
480
553
|
isIntentMismatchError,
|
|
554
|
+
isLangGraphAgent,
|
|
555
|
+
isLangchainTool,
|
|
481
556
|
isLlmAgent,
|
|
557
|
+
isLlmCallsLimitExceededError,
|
|
482
558
|
isLoopAgent,
|
|
483
559
|
isNodeErrorEvent,
|
|
484
560
|
isNodeReportedError,
|
|
@@ -486,6 +562,7 @@ export {
|
|
|
486
562
|
isNodeState,
|
|
487
563
|
isNodeTimeoutError,
|
|
488
564
|
isParallelAgent,
|
|
565
|
+
isRemoteAgent,
|
|
489
566
|
isRequestInput,
|
|
490
567
|
isRoutableLlmAgent,
|
|
491
568
|
isRoutedAgent,
|
|
@@ -496,14 +573,19 @@ export {
|
|
|
496
573
|
isSessionArtifactService,
|
|
497
574
|
isStateSchemaError,
|
|
498
575
|
isToolNotFound,
|
|
576
|
+
isToolboxTool,
|
|
499
577
|
isWebMCPSupported,
|
|
500
578
|
isWorkflow,
|
|
501
579
|
logger,
|
|
580
|
+
markRestored,
|
|
502
581
|
node,
|
|
503
582
|
normalizeRetryExceptions,
|
|
504
583
|
populateClientFunctionCallId,
|
|
505
584
|
prepareRetryConfig,
|
|
506
585
|
pruneThoughts,
|
|
586
|
+
publicEvent,
|
|
587
|
+
publicMetadata,
|
|
588
|
+
publicSession,
|
|
507
589
|
renameReservedKeywords,
|
|
508
590
|
requestInputTool,
|
|
509
591
|
requireAgent,
|
|
@@ -515,6 +597,8 @@ export {
|
|
|
515
597
|
setLogger,
|
|
516
598
|
stringifyContent,
|
|
517
599
|
stripAdkIdentityPreamble,
|
|
600
|
+
toGeminiSchema,
|
|
601
|
+
toJsonSchema,
|
|
518
602
|
toSnakeCaseName,
|
|
519
603
|
toStructuredEvents,
|
|
520
604
|
validateAppName,
|
|
@@ -29,7 +29,7 @@ const _LlmSummarizer = class _LlmSummarizer {
|
|
|
29
29
|
* @throws {Error} If `events` is empty or the LLM returns no content.
|
|
30
30
|
*/
|
|
31
31
|
async summarize(events) {
|
|
32
|
-
var _a, _b
|
|
32
|
+
var _a, _b;
|
|
33
33
|
if (events.length === 0) {
|
|
34
34
|
throw new Error("Cannot summarize an empty list of events.");
|
|
35
35
|
}
|
|
@@ -51,18 +51,20 @@ ${formattedEvents}`;
|
|
|
51
51
|
toolsDict: {},
|
|
52
52
|
liveConnectConfig: {}
|
|
53
53
|
};
|
|
54
|
-
const responseGen = this.llm.generateContentAsync(request, false);
|
|
55
54
|
let compactedContent = "";
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
for await (const response of this.llm.generateContentAsync(
|
|
56
|
+
request,
|
|
57
|
+
false
|
|
58
|
+
)) {
|
|
59
|
+
for (const part of (_b = (_a = response.content) == null ? void 0 : _a.parts) != null ? _b : []) {
|
|
60
|
+
if (part.text && !part.thought) {
|
|
61
|
+
compactedContent += part.text;
|
|
62
|
+
}
|
|
64
63
|
}
|
|
65
64
|
}
|
|
65
|
+
if (!compactedContent) {
|
|
66
|
+
throw new Error("LLM failed to return a valid summary.");
|
|
67
|
+
}
|
|
66
68
|
return createCompactedEvent({
|
|
67
69
|
author: "system",
|
|
68
70
|
content: {
|
|
@@ -86,7 +86,8 @@ let TokenBasedContextCompactor = _TokenBasedContextCompactor;
|
|
|
86
86
|
function latestPromptTokenCount(activeEvents, invocationContext) {
|
|
87
87
|
var _a;
|
|
88
88
|
for (let i = activeEvents.length - 1; i >= 0; i--) {
|
|
89
|
-
const
|
|
89
|
+
const usage = activeEvents[i].usageMetadata;
|
|
90
|
+
const count = (_a = usage == null ? void 0 : usage.initialPromptTokenCount) != null ? _a : usage == null ? void 0 : usage.promptTokenCount;
|
|
90
91
|
if (count !== void 0) {
|
|
91
92
|
return count;
|
|
92
93
|
}
|