@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
|
@@ -13,6 +13,7 @@ import { createEvent, getFunctionCalls } from "../events/event.js";
|
|
|
13
13
|
import { createEventActions } from "../events/event_actions.js";
|
|
14
14
|
import { PluginManager } from "../plugins/plugin_manager.js";
|
|
15
15
|
import { logger } from "../utils/logger.js";
|
|
16
|
+
import { isGemini2OrAbove } from "../utils/model_name.js";
|
|
16
17
|
class Runner {
|
|
17
18
|
constructor(input) {
|
|
18
19
|
var _a;
|
|
@@ -58,12 +59,12 @@ class Runner {
|
|
|
58
59
|
}
|
|
59
60
|
if (runConfig.supportCfc && this.agent instanceof LlmAgent) {
|
|
60
61
|
const modelName = this.agent.canonicalModel.model;
|
|
61
|
-
if (!modelName
|
|
62
|
+
if (!isGemini2OrAbove(modelName)) {
|
|
62
63
|
throw new Error(`CFC is not supported for model: ${modelName} in agent: ${this.agent.name}`);
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
if (!(this.agent.codeExecutor instanceof BuiltInCodeExecutor)) {
|
|
66
|
+
this.agent.codeExecutor = new BuiltInCodeExecutor();
|
|
67
|
+
}
|
|
67
68
|
}
|
|
68
69
|
const invocationContext = new InvocationContext({
|
|
69
70
|
artifactService: this.artifactService,
|
|
@@ -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 { randomUUID } from "../utils/env_aware_utils.js";
|
|
8
8
|
import { logger } from "../utils/logger.js";
|
|
9
9
|
import { BaseSessionService } from "./base_session_service.js";
|
|
@@ -15,17 +15,37 @@ function isGeminiModel(modelString) {
|
|
|
15
15
|
const modelName = extractModelName(modelString);
|
|
16
16
|
return modelName.startsWith("gemini-");
|
|
17
17
|
}
|
|
18
|
+
function parseVersion(versionString) {
|
|
19
|
+
if (!/^\d+(\.\d+)*$/.test(versionString)) {
|
|
20
|
+
return { valid: false, major: 0, minor: 0, patch: 0 };
|
|
21
|
+
}
|
|
22
|
+
const parts = versionString.split(".").map((part) => parseInt(part, 10));
|
|
23
|
+
return {
|
|
24
|
+
valid: true,
|
|
25
|
+
major: parts[0],
|
|
26
|
+
minor: parts.length > 1 ? parts[1] : 0,
|
|
27
|
+
patch: parts.length > 2 ? parts[2] : 0
|
|
28
|
+
};
|
|
29
|
+
}
|
|
18
30
|
function isGemini1Model(modelString) {
|
|
19
31
|
const modelName = extractModelName(modelString);
|
|
20
32
|
return modelName.startsWith("gemini-1");
|
|
21
33
|
}
|
|
22
|
-
function
|
|
34
|
+
function isGemini2OrAbove(modelString) {
|
|
35
|
+
if (!modelString) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
23
38
|
const modelName = extractModelName(modelString);
|
|
24
|
-
|
|
39
|
+
if (!modelName.startsWith("gemini-")) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
const versionString = modelName.slice("gemini-".length).split("-", 1)[0];
|
|
43
|
+
const parsedVersion = parseVersion(versionString);
|
|
44
|
+
return parsedVersion.valid && parsedVersion.major >= 2;
|
|
25
45
|
}
|
|
26
46
|
export {
|
|
27
47
|
extractModelName,
|
|
28
48
|
isGemini1Model,
|
|
29
|
-
|
|
49
|
+
isGemini2OrAbove,
|
|
30
50
|
isGeminiModel
|
|
31
51
|
};
|
package/dist/esm/version.js
CHANGED
package/dist/types/common.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export { LongRunningFunctionTool } from './tools/long_running_tool.js';
|
|
|
51
51
|
export { ToolConfirmation } from './tools/tool_confirmation.js';
|
|
52
52
|
export { ToolContext } from './tools/tool_context.js';
|
|
53
53
|
export { LogLevel, setLogLevel } from './utils/logger.js';
|
|
54
|
+
export { isGemini2OrAbove } from './utils/model_name.js';
|
|
54
55
|
export { zodObjectToSchema } from './utils/simple_zod_to_json.js';
|
|
55
56
|
export { version } from './version.js';
|
|
56
57
|
export * from './artifacts/base_artifact_service.js';
|
|
@@ -31,4 +31,4 @@ export declare function isGemini1Model(modelString: string): boolean;
|
|
|
31
31
|
* @param modelString Either a simple model name or path - based model name
|
|
32
32
|
* @return true if it's a Gemini 2.x model, false otherwise.
|
|
33
33
|
*/
|
|
34
|
-
export declare function
|
|
34
|
+
export declare function isGemini2OrAbove(modelString: string): boolean;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -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";
|
|
@@ -36,7 +36,7 @@ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")])
|
|
|
36
36
|
* Copyright 2025 Google LLC
|
|
37
37
|
* SPDX-License-Identifier: Apache-2.0
|
|
38
38
|
*/
|
|
39
|
-
import { cloneDeep } from "lodash";
|
|
39
|
+
import { cloneDeep } from "lodash-es";
|
|
40
40
|
import { z } from "zod";
|
|
41
41
|
import { BaseCodeExecutor } from "../code_executors/base_code_executor.js";
|
|
42
42
|
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/web/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,
|