@google/adk 0.2.2 → 0.2.4
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/agents/content_processor_utils.js +2 -2
- package/dist/cjs/agents/functions.js +3 -3
- package/dist/cjs/agents/llm_agent.js +3 -3
- package/dist/cjs/code_executors/built_in_code_executor.js +1 -1
- package/dist/cjs/code_executors/code_execution_utils.js +2 -2
- package/dist/cjs/code_executors/code_executor_context.js +2 -2
- package/dist/cjs/common.js +3 -0
- package/dist/cjs/index.js +11 -16
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/runner/runner.js +5 -4
- package/dist/cjs/sessions/in_memory_session_service.js +3 -3
- package/dist/cjs/utils/model_name.js +24 -4
- package/dist/cjs/version.js +2 -2
- package/dist/esm/agents/content_processor_utils.js +1 -1
- package/dist/esm/agents/functions.js +1 -1
- package/dist/esm/agents/llm_agent.js +1 -1
- package/dist/esm/code_executors/built_in_code_executor.js +2 -2
- package/dist/esm/code_executors/code_execution_utils.js +1 -1
- package/dist/esm/code_executors/code_executor_context.js +1 -1
- package/dist/esm/common.js +2 -0
- package/dist/esm/index.js +11 -16
- package/dist/esm/index.js.map +3 -3
- package/dist/esm/runner/runner.js +5 -4
- package/dist/esm/sessions/in_memory_session_service.js +1 -1
- package/dist/esm/utils/model_name.js +23 -3
- package/dist/esm/version.js +2 -2
- package/dist/types/common.d.ts +1 -0
- package/dist/types/utils/model_name.d.ts +1 -1
- package/dist/types/version.d.ts +2 -2
- package/dist/web/agents/content_processor_utils.js +1 -1
- package/dist/web/agents/functions.js +1 -1
- package/dist/web/agents/llm_agent.js +1 -1
- package/dist/web/code_executors/built_in_code_executor.js +2 -2
- package/dist/web/code_executors/code_execution_utils.js +1 -1
- package/dist/web/code_executors/code_executor_context.js +1 -1
- package/dist/web/common.js +2 -0
- package/dist/web/index.js +1 -6
- package/dist/web/index.js.map +3 -3
- package/dist/web/runner/runner.js +5 -4
- package/dist/web/sessions/in_memory_session_service.js +1 -1
- package/dist/web/utils/model_name.js +23 -3
- package/dist/web/version.js +2 -2
- package/package.json +4 -4
- package/dist/cjs/utils/deep_clone.js +0 -44
- package/dist/esm/utils/deep_clone.js +0 -14
- package/dist/types/utils/deep_clone.d.ts +0 -1
- package/dist/web/utils/deep_clone.js +0 -14
|
@@ -37,6 +37,7 @@ var import_event = require("../events/event.js");
|
|
|
37
37
|
var import_event_actions = require("../events/event_actions.js");
|
|
38
38
|
var import_plugin_manager = require("../plugins/plugin_manager.js");
|
|
39
39
|
var import_logger = require("../utils/logger.js");
|
|
40
|
+
var import_model_name = require("../utils/model_name.js");
|
|
40
41
|
/**
|
|
41
42
|
* @license
|
|
42
43
|
* Copyright 2025 Google LLC
|
|
@@ -87,12 +88,12 @@ class Runner {
|
|
|
87
88
|
}
|
|
88
89
|
if (runConfig.supportCfc && this.agent instanceof import_llm_agent.LlmAgent) {
|
|
89
90
|
const modelName = this.agent.canonicalModel.model;
|
|
90
|
-
if (!
|
|
91
|
+
if (!(0, import_model_name.isGemini2OrAbove)(modelName)) {
|
|
91
92
|
throw new Error(`CFC is not supported for model: ${modelName} in agent: ${this.agent.name}`);
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
if (!(this.agent.codeExecutor instanceof import_built_in_code_executor.BuiltInCodeExecutor)) {
|
|
95
|
+
this.agent.codeExecutor = new import_built_in_code_executor.BuiltInCodeExecutor();
|
|
96
|
+
}
|
|
96
97
|
}
|
|
97
98
|
const invocationContext = new import_invocation_context.InvocationContext({
|
|
98
99
|
artifactService: this.artifactService,
|
|
@@ -27,7 +27,7 @@ __export(in_memory_session_service_exports, {
|
|
|
27
27
|
InMemorySessionService: () => InMemorySessionService
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(in_memory_session_service_exports);
|
|
30
|
-
var
|
|
30
|
+
var import_lodash_es = require("lodash-es");
|
|
31
31
|
var import_env_aware_utils = require("../utils/env_aware_utils.js");
|
|
32
32
|
var import_logger = require("../utils/logger.js");
|
|
33
33
|
var import_base_session_service = require("./base_session_service.js");
|
|
@@ -72,7 +72,7 @@ class InMemorySessionService extends import_base_session_service.BaseSessionServ
|
|
|
72
72
|
}
|
|
73
73
|
this.sessions[appName][userId][session.id] = session;
|
|
74
74
|
return Promise.resolve(
|
|
75
|
-
this.mergeState(appName, userId, (0,
|
|
75
|
+
this.mergeState(appName, userId, (0, import_lodash_es.cloneDeep)(session))
|
|
76
76
|
);
|
|
77
77
|
}
|
|
78
78
|
getSession({ appName, userId, sessionId, config }) {
|
|
@@ -80,7 +80,7 @@ class InMemorySessionService extends import_base_session_service.BaseSessionServ
|
|
|
80
80
|
return Promise.resolve(void 0);
|
|
81
81
|
}
|
|
82
82
|
const session = this.sessions[appName][userId][sessionId];
|
|
83
|
-
const copiedSession = (0,
|
|
83
|
+
const copiedSession = (0, import_lodash_es.cloneDeep)(session);
|
|
84
84
|
if (config) {
|
|
85
85
|
if (config.numRecentEvents) {
|
|
86
86
|
copiedSession.events = copiedSession.events.slice(-config.numRecentEvents);
|
|
@@ -26,7 +26,7 @@ var model_name_exports = {};
|
|
|
26
26
|
__export(model_name_exports, {
|
|
27
27
|
extractModelName: () => extractModelName,
|
|
28
28
|
isGemini1Model: () => isGemini1Model,
|
|
29
|
-
|
|
29
|
+
isGemini2OrAbove: () => isGemini2OrAbove,
|
|
30
30
|
isGeminiModel: () => isGeminiModel
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(model_name_exports);
|
|
@@ -47,18 +47,38 @@ function isGeminiModel(modelString) {
|
|
|
47
47
|
const modelName = extractModelName(modelString);
|
|
48
48
|
return modelName.startsWith("gemini-");
|
|
49
49
|
}
|
|
50
|
+
function parseVersion(versionString) {
|
|
51
|
+
if (!/^\d+(\.\d+)*$/.test(versionString)) {
|
|
52
|
+
return { valid: false, major: 0, minor: 0, patch: 0 };
|
|
53
|
+
}
|
|
54
|
+
const parts = versionString.split(".").map((part) => parseInt(part, 10));
|
|
55
|
+
return {
|
|
56
|
+
valid: true,
|
|
57
|
+
major: parts[0],
|
|
58
|
+
minor: parts.length > 1 ? parts[1] : 0,
|
|
59
|
+
patch: parts.length > 2 ? parts[2] : 0
|
|
60
|
+
};
|
|
61
|
+
}
|
|
50
62
|
function isGemini1Model(modelString) {
|
|
51
63
|
const modelName = extractModelName(modelString);
|
|
52
64
|
return modelName.startsWith("gemini-1");
|
|
53
65
|
}
|
|
54
|
-
function
|
|
66
|
+
function isGemini2OrAbove(modelString) {
|
|
67
|
+
if (!modelString) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
55
70
|
const modelName = extractModelName(modelString);
|
|
56
|
-
|
|
71
|
+
if (!modelName.startsWith("gemini-")) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
const versionString = modelName.slice("gemini-".length).split("-", 1)[0];
|
|
75
|
+
const parsedVersion = parseVersion(versionString);
|
|
76
|
+
return parsedVersion.valid && parsedVersion.major >= 2;
|
|
57
77
|
}
|
|
58
78
|
// Annotate the CommonJS export names for ESM import in node:
|
|
59
79
|
0 && (module.exports = {
|
|
60
80
|
extractModelName,
|
|
61
81
|
isGemini1Model,
|
|
62
|
-
|
|
82
|
+
isGemini2OrAbove,
|
|
63
83
|
isGeminiModel
|
|
64
84
|
});
|
package/dist/cjs/version.js
CHANGED
|
@@ -29,10 +29,10 @@ __export(version_exports, {
|
|
|
29
29
|
module.exports = __toCommonJS(version_exports);
|
|
30
30
|
/**
|
|
31
31
|
* @license
|
|
32
|
-
* Copyright
|
|
32
|
+
* Copyright 2025 Google LLC
|
|
33
33
|
* SPDX-License-Identifier: Apache-2.0
|
|
34
34
|
*/
|
|
35
|
-
const version = "0.2.
|
|
35
|
+
const version = "0.2.4";
|
|
36
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
37
|
0 && (module.exports = {
|
|
38
38
|
version
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { cloneDeep } from "lodash";
|
|
6
|
+
import { cloneDeep } from "lodash-es";
|
|
7
7
|
import { createEvent, getFunctionCalls, getFunctionResponses } from "../events/event.js";
|
|
8
8
|
import { removeClientFunctionCallId, REQUEST_CONFIRMATION_FUNCTION_CALL_NAME, REQUEST_EUC_FUNCTION_CALL_NAME } from "./functions.js";
|
|
9
9
|
function getContents(events, agentName, currentBranch) {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { createUserContent } from "@google/genai";
|
|
7
|
-
import { isEmpty } from "lodash";
|
|
7
|
+
import { isEmpty } from "lodash-es";
|
|
8
8
|
import { createEvent, getFunctionCalls } from "../events/event.js";
|
|
9
9
|
import { mergeEventActions } from "../events/event_actions.js";
|
|
10
10
|
import { ToolContext } from "../tools/tool_context.js";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { cloneDeep } from "lodash";
|
|
6
|
+
import { cloneDeep } from "lodash-es";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import { BaseCodeExecutor } from "../code_executors/base_code_executor.js";
|
|
9
9
|
import { BuiltInCodeExecutor } from "../code_executors/built_in_code_executor.js";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { isGemini2OrAbove } from "../utils/model_name.js";
|
|
7
7
|
import { BaseCodeExecutor } from "./base_code_executor.js";
|
|
8
8
|
class BuiltInCodeExecutor extends BaseCodeExecutor {
|
|
9
9
|
executeCode(params) {
|
|
@@ -14,7 +14,7 @@ class BuiltInCodeExecutor extends BaseCodeExecutor {
|
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
processLlmRequest(llmRequest) {
|
|
17
|
-
if (llmRequest.model &&
|
|
17
|
+
if (llmRequest.model && isGemini2OrAbove(llmRequest.model)) {
|
|
18
18
|
llmRequest.config = llmRequest.config || {};
|
|
19
19
|
llmRequest.config.tools = llmRequest.config.tools || [];
|
|
20
20
|
llmRequest.config.tools.push({ codeExecution: {} });
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { Language, Outcome } from "@google/genai";
|
|
7
|
-
import { cloneDeep } from "lodash";
|
|
7
|
+
import { cloneDeep } from "lodash-es";
|
|
8
8
|
import { base64Encode, isBase64Encoded } from "../utils/env_aware_utils.js";
|
|
9
9
|
function getEncodedFileContent(data) {
|
|
10
10
|
return isBase64Encoded(data) ? data : base64Encode(data);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { cloneDeep } from "lodash";
|
|
6
|
+
import { cloneDeep } from "lodash-es";
|
|
7
7
|
const CONTEXT_KEY = "_code_execution_context";
|
|
8
8
|
const SESSION_ID_KEY = "execution_session_id";
|
|
9
9
|
const PROCESSED_FILE_NAMES_KEY = "processed_input_files";
|
package/dist/esm/common.js
CHANGED
|
@@ -39,6 +39,7 @@ import { LongRunningFunctionTool } from "./tools/long_running_tool.js";
|
|
|
39
39
|
import { ToolConfirmation } from "./tools/tool_confirmation.js";
|
|
40
40
|
import { ToolContext } from "./tools/tool_context.js";
|
|
41
41
|
import { LogLevel, setLogLevel } from "./utils/logger.js";
|
|
42
|
+
import { isGemini2OrAbove } from "./utils/model_name.js";
|
|
42
43
|
import { zodObjectToSchema } from "./utils/simple_zod_to_json.js";
|
|
43
44
|
import { version } from "./version.js";
|
|
44
45
|
export * from "./artifacts/base_artifact_service.js";
|
|
@@ -92,6 +93,7 @@ export {
|
|
|
92
93
|
isBaseAgent,
|
|
93
94
|
isBaseLlm,
|
|
94
95
|
isFinalResponse,
|
|
96
|
+
isGemini2OrAbove,
|
|
95
97
|
setLogLevel,
|
|
96
98
|
stringifyContent,
|
|
97
99
|
version,
|