@google/adk 0.2.3 → 0.2.5
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/base_agent.js +9 -3
- package/dist/cjs/agents/content_processor_utils.js +2 -12
- package/dist/cjs/agents/functions.js +3 -13
- package/dist/cjs/agents/invocation_context.js +3 -1
- package/dist/cjs/agents/llm_agent.js +132 -88
- package/dist/cjs/agents/loop_agent.js +16 -5
- package/dist/cjs/agents/parallel_agent.js +17 -3
- package/dist/cjs/agents/readonly_context.js +4 -1
- package/dist/cjs/agents/sequential_agent.js +34 -12
- package/dist/cjs/code_executors/base_code_executor.js +12 -2
- package/dist/cjs/code_executors/built_in_code_executor.js +15 -3
- package/dist/cjs/code_executors/code_execution_utils.js +2 -12
- package/dist/cjs/code_executors/code_executor_context.js +2 -12
- package/dist/cjs/common.js +41 -0
- package/dist/cjs/examples/base_example_provider.js +18 -2
- package/dist/cjs/examples/example_util.js +1 -1
- package/dist/cjs/index.js +11 -11
- package/dist/cjs/index.js.map +4 -4
- package/dist/cjs/plugins/base_plugin.js +59 -49
- package/dist/cjs/plugins/security_plugin.js +4 -1
- package/dist/cjs/runner/runner.js +38 -27
- package/dist/cjs/sessions/in_memory_session_service.js +3 -13
- package/dist/cjs/tools/agent_tool.js +18 -9
- package/dist/cjs/tools/base_tool.js +16 -6
- package/dist/cjs/tools/function_tool.js +14 -5
- package/dist/cjs/tools/google_search_tool.js +8 -3
- package/dist/cjs/tools/tool_context.js +4 -9
- package/dist/cjs/utils/gemini_schema_util.js +1 -0
- package/dist/cjs/version.js +1 -1
- package/dist/esm/agents/base_agent.js +9 -3
- package/dist/esm/agents/content_processor_utils.js +1 -1
- package/dist/esm/agents/functions.js +1 -1
- package/dist/esm/agents/invocation_context.js +3 -1
- package/dist/esm/agents/llm_agent.js +166 -84
- package/dist/esm/agents/loop_agent.js +14 -4
- package/dist/esm/agents/parallel_agent.js +15 -2
- package/dist/esm/agents/readonly_context.js +4 -1
- package/dist/esm/agents/sequential_agent.js +33 -12
- package/dist/esm/code_executors/base_code_executor.js +10 -1
- package/dist/esm/code_executors/built_in_code_executor.js +13 -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 +53 -10
- package/dist/esm/examples/base_example_provider.js +16 -1
- package/dist/esm/examples/example_util.js +4 -2
- package/dist/esm/index.js +11 -11
- package/dist/esm/index.js.map +4 -4
- package/dist/esm/plugins/base_plugin.js +59 -49
- package/dist/esm/plugins/security_plugin.js +4 -1
- package/dist/esm/runner/runner.js +47 -30
- package/dist/esm/sessions/in_memory_session_service.js +1 -1
- package/dist/esm/tools/agent_tool.js +17 -9
- package/dist/esm/tools/base_tool.js +14 -5
- package/dist/esm/tools/function_tool.js +13 -7
- package/dist/esm/tools/google_search_tool.js +9 -3
- package/dist/esm/tools/tool_context.js +4 -9
- package/dist/esm/utils/gemini_schema_util.js +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/types/agents/base_agent.d.ts +14 -3
- package/dist/types/agents/invocation_context.d.ts +4 -2
- package/dist/types/agents/llm_agent.d.ts +42 -30
- package/dist/types/agents/loop_agent.d.ts +16 -0
- package/dist/types/agents/parallel_agent.d.ts +16 -0
- package/dist/types/agents/sequential_agent.d.ts +17 -1
- package/dist/types/auth/auth_schemes.d.ts +5 -2
- package/dist/types/code_executors/base_code_executor.d.ts +14 -0
- package/dist/types/code_executors/built_in_code_executor.d.ts +19 -0
- package/dist/types/common.d.ts +38 -14
- package/dist/types/examples/base_example_provider.d.ts +16 -0
- package/dist/types/plugins/base_plugin.d.ts +50 -40
- package/dist/types/runner/runner.d.ts +17 -9
- package/dist/types/tools/agent_tool.d.ts +14 -0
- package/dist/types/tools/base_tool.d.ts +14 -0
- package/dist/types/tools/function_tool.d.ts +14 -1
- package/dist/types/tools/google_search_tool.d.ts +3 -4
- package/dist/types/tools/tool_context.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/web/agents/base_agent.js +9 -3
- package/dist/web/agents/content_processor_utils.js +1 -1
- package/dist/web/agents/functions.js +1 -1
- package/dist/web/agents/invocation_context.js +3 -1
- package/dist/web/agents/llm_agent.js +166 -84
- package/dist/web/agents/loop_agent.js +14 -4
- package/dist/web/agents/parallel_agent.js +15 -2
- package/dist/web/agents/readonly_context.js +4 -1
- package/dist/web/agents/sequential_agent.js +33 -12
- package/dist/web/code_executors/base_code_executor.js +10 -1
- package/dist/web/code_executors/built_in_code_executor.js +13 -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 +53 -10
- package/dist/web/examples/base_example_provider.js +16 -1
- package/dist/web/examples/example_util.js +4 -2
- package/dist/web/index.js +1 -1
- package/dist/web/index.js.map +4 -4
- package/dist/web/plugins/base_plugin.js +59 -49
- package/dist/web/plugins/security_plugin.js +4 -1
- package/dist/web/runner/runner.js +48 -31
- package/dist/web/sessions/in_memory_session_service.js +1 -1
- package/dist/web/tools/agent_tool.js +17 -9
- package/dist/web/tools/base_tool.js +14 -5
- package/dist/web/tools/function_tool.js +13 -7
- package/dist/web/tools/google_search_tool.js +9 -3
- package/dist/web/tools/tool_context.js +4 -9
- package/dist/web/utils/gemini_schema_util.js +1 -0
- package/dist/web/version.js +1 -1
- package/package.json +3 -3
|
@@ -55,7 +55,9 @@ class BaseAgent {
|
|
|
55
55
|
this.parentAgent = config.parentAgent;
|
|
56
56
|
this.subAgents = config.subAgents || [];
|
|
57
57
|
this.rootAgent = getRootAgent(this);
|
|
58
|
-
this.beforeAgentCallback = getCannonicalCallback(
|
|
58
|
+
this.beforeAgentCallback = getCannonicalCallback(
|
|
59
|
+
config.beforeAgentCallback
|
|
60
|
+
);
|
|
59
61
|
this.afterAgentCallback = getCannonicalCallback(config.afterAgentCallback);
|
|
60
62
|
this.setParentAgentForSubAgents();
|
|
61
63
|
}
|
|
@@ -217,7 +219,9 @@ class BaseAgent {
|
|
|
217
219
|
setParentAgentForSubAgents() {
|
|
218
220
|
for (const subAgent of this.subAgents) {
|
|
219
221
|
if (subAgent.parentAgent) {
|
|
220
|
-
throw new Error(
|
|
222
|
+
throw new Error(
|
|
223
|
+
`Agent "${subAgent.name}" already has a parent agent, current parent: "${subAgent.parentAgent.name}", trying to add: "${this.name}"`
|
|
224
|
+
);
|
|
221
225
|
}
|
|
222
226
|
subAgent.parentAgent = this;
|
|
223
227
|
}
|
|
@@ -225,7 +229,9 @@ class BaseAgent {
|
|
|
225
229
|
}
|
|
226
230
|
function validateAgentName(name) {
|
|
227
231
|
if (!isIdentifier(name)) {
|
|
228
|
-
throw new Error(
|
|
232
|
+
throw new Error(
|
|
233
|
+
`Found invalid agent name: "${name}". Agent name must be a valid identifier. It should start with a letter (a-z, A-Z) or an underscore (_), and can only contain letters, digits (0-9), and underscores.`
|
|
234
|
+
);
|
|
229
235
|
}
|
|
230
236
|
if (name === "user") {
|
|
231
237
|
throw new Error(
|
|
@@ -5,11 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
"use strict";
|
|
8
|
-
var __create = Object.create;
|
|
9
8
|
var __defProp = Object.defineProperty;
|
|
10
9
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
13
11
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
12
|
var __export = (target, all) => {
|
|
15
13
|
for (var name in all)
|
|
@@ -23,14 +21,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
23
21
|
}
|
|
24
22
|
return to;
|
|
25
23
|
};
|
|
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
|
-
));
|
|
34
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
25
|
var content_processor_utils_exports = {};
|
|
36
26
|
__export(content_processor_utils_exports, {
|
|
@@ -38,7 +28,7 @@ __export(content_processor_utils_exports, {
|
|
|
38
28
|
getCurrentTurnContents: () => getCurrentTurnContents
|
|
39
29
|
});
|
|
40
30
|
module.exports = __toCommonJS(content_processor_utils_exports);
|
|
41
|
-
var
|
|
31
|
+
var import_lodash_es = require("lodash-es");
|
|
42
32
|
var import_event = require("../events/event.js");
|
|
43
33
|
var import_functions = require("./functions.js");
|
|
44
34
|
/**
|
|
@@ -70,7 +60,7 @@ function getContents(events, agentName, currentBranch) {
|
|
|
70
60
|
resultEvents = rearrangeEventsForAsyncFunctionResponsesInHistory(resultEvents);
|
|
71
61
|
const contents = [];
|
|
72
62
|
for (const event of resultEvents) {
|
|
73
|
-
const content = (0,
|
|
63
|
+
const content = (0, import_lodash_es.cloneDeep)(event.content);
|
|
74
64
|
(0, import_functions.removeClientFunctionCallId)(content);
|
|
75
65
|
contents.push(content);
|
|
76
66
|
}
|
|
@@ -5,11 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
"use strict";
|
|
8
|
-
var __create = Object.create;
|
|
9
8
|
var __defProp = Object.defineProperty;
|
|
10
9
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
13
11
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
12
|
var __export = (target, all) => {
|
|
15
13
|
for (var name in all)
|
|
@@ -23,14 +21,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
23
21
|
}
|
|
24
22
|
return to;
|
|
25
23
|
};
|
|
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
|
-
));
|
|
34
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
25
|
var functions_exports = {};
|
|
36
26
|
__export(functions_exports, {
|
|
@@ -49,7 +39,7 @@ __export(functions_exports, {
|
|
|
49
39
|
});
|
|
50
40
|
module.exports = __toCommonJS(functions_exports);
|
|
51
41
|
var import_genai = require("@google/genai");
|
|
52
|
-
var
|
|
42
|
+
var import_lodash_es = require("lodash-es");
|
|
53
43
|
var import_event = require("../events/event.js");
|
|
54
44
|
var import_event_actions = require("../events/event_actions.js");
|
|
55
45
|
var import_tool_context = require("../tools/tool_context.js");
|
|
@@ -105,7 +95,7 @@ function getLongRunningFunctionCalls(functionCalls, toolsDict) {
|
|
|
105
95
|
}
|
|
106
96
|
function generateAuthEvent(invocationContext, functionResponseEvent) {
|
|
107
97
|
var _a;
|
|
108
|
-
if (!((_a = functionResponseEvent.actions) == null ? void 0 : _a.requestedAuthConfigs) || (0,
|
|
98
|
+
if (!((_a = functionResponseEvent.actions) == null ? void 0 : _a.requestedAuthConfigs) || (0, import_lodash_es.isEmpty)(functionResponseEvent.actions.requestedAuthConfigs)) {
|
|
109
99
|
return void 0;
|
|
110
100
|
}
|
|
111
101
|
const parts = [];
|
|
@@ -141,7 +131,7 @@ function generateRequestConfirmationEvent({
|
|
|
141
131
|
functionResponseEvent
|
|
142
132
|
}) {
|
|
143
133
|
var _a, _b;
|
|
144
|
-
if (!((_a = functionResponseEvent.actions) == null ? void 0 : _a.requestedToolConfirmations) || (0,
|
|
134
|
+
if (!((_a = functionResponseEvent.actions) == null ? void 0 : _a.requestedToolConfirmations) || (0, import_lodash_es.isEmpty)(functionResponseEvent.actions.requestedToolConfirmations)) {
|
|
145
135
|
return;
|
|
146
136
|
}
|
|
147
137
|
const parts = [];
|
|
@@ -47,7 +47,9 @@ class InvocationCostManager {
|
|
|
47
47
|
incrementAndEnforceLlmCallsLimit(runConfig) {
|
|
48
48
|
this.numberOfLlmCalls++;
|
|
49
49
|
if (runConfig && runConfig.maxLlmCalls > 0 && this.numberOfLlmCalls > runConfig.maxLlmCalls) {
|
|
50
|
-
throw new Error(
|
|
50
|
+
throw new Error(
|
|
51
|
+
`Max number of llm calls limit of ${runConfig.maxLlmCalls} exceeded`
|
|
52
|
+
);
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
}
|