@google/adk 0.2.2 → 0.2.3
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 +12 -2
- package/dist/cjs/agents/functions.js +13 -3
- package/dist/cjs/agents/llm_agent.js +13 -3
- package/dist/cjs/code_executors/built_in_code_executor.js +1 -1
- package/dist/cjs/code_executors/code_execution_utils.js +12 -2
- package/dist/cjs/code_executors/code_executor_context.js +12 -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/sessions/in_memory_session_service.js +13 -3
- package/dist/cjs/utils/model_name.js +24 -4
- package/dist/cjs/version.js +1 -1
- 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/sessions/in_memory_session_service.js +1 -1
- package/dist/esm/utils/model_name.js +23 -3
- package/dist/esm/version.js +1 -1
- 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/sessions/in_memory_session_service.js +1 -1
- package/dist/web/utils/model_name.js +23 -3
- package/dist/web/version.js +1 -1
- package/package.json +3 -3
- 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
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
"use strict";
|
|
8
|
+
var __create = Object.create;
|
|
8
9
|
var __defProp = Object.defineProperty;
|
|
9
10
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
11
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
11
13
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
14
|
var __export = (target, all) => {
|
|
13
15
|
for (var name in all)
|
|
@@ -21,13 +23,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
21
23
|
}
|
|
22
24
|
return to;
|
|
23
25
|
};
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
+
mod
|
|
33
|
+
));
|
|
24
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
35
|
var in_memory_session_service_exports = {};
|
|
26
36
|
__export(in_memory_session_service_exports, {
|
|
27
37
|
InMemorySessionService: () => InMemorySessionService
|
|
28
38
|
});
|
|
29
39
|
module.exports = __toCommonJS(in_memory_session_service_exports);
|
|
30
|
-
var
|
|
40
|
+
var import_cloneDeep = __toESM(require("lodash-es/cloneDeep.js"), 1);
|
|
31
41
|
var import_env_aware_utils = require("../utils/env_aware_utils.js");
|
|
32
42
|
var import_logger = require("../utils/logger.js");
|
|
33
43
|
var import_base_session_service = require("./base_session_service.js");
|
|
@@ -72,7 +82,7 @@ class InMemorySessionService extends import_base_session_service.BaseSessionServ
|
|
|
72
82
|
}
|
|
73
83
|
this.sessions[appName][userId][session.id] = session;
|
|
74
84
|
return Promise.resolve(
|
|
75
|
-
this.mergeState(appName, userId, (0,
|
|
85
|
+
this.mergeState(appName, userId, (0, import_cloneDeep.default)(session))
|
|
76
86
|
);
|
|
77
87
|
}
|
|
78
88
|
getSession({ appName, userId, sessionId, config }) {
|
|
@@ -80,7 +90,7 @@ class InMemorySessionService extends import_base_session_service.BaseSessionServ
|
|
|
80
90
|
return Promise.resolve(void 0);
|
|
81
91
|
}
|
|
82
92
|
const session = this.sessions[appName][userId][sessionId];
|
|
83
|
-
const copiedSession = (0,
|
|
93
|
+
const copiedSession = (0, import_cloneDeep.default)(session);
|
|
84
94
|
if (config) {
|
|
85
95
|
if (config.numRecentEvents) {
|
|
86
96
|
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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import
|
|
6
|
+
import cloneDeep from "lodash-es/cloneDeep.js";
|
|
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
|
|
7
|
+
import isEmpty from "lodash-es/isEmpty.js";
|
|
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
|
|
6
|
+
import cloneDeep from "lodash-es/cloneDeep.js";
|
|
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
|
|
7
|
+
import cloneDeep from "lodash-es/cloneDeep.js";
|
|
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
|
|
6
|
+
import cloneDeep from "lodash-es/cloneDeep.js";
|
|
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,
|