@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.
Files changed (107) hide show
  1. package/dist/cjs/agents/base_agent.js +9 -3
  2. package/dist/cjs/agents/content_processor_utils.js +2 -12
  3. package/dist/cjs/agents/functions.js +3 -13
  4. package/dist/cjs/agents/invocation_context.js +3 -1
  5. package/dist/cjs/agents/llm_agent.js +132 -88
  6. package/dist/cjs/agents/loop_agent.js +16 -5
  7. package/dist/cjs/agents/parallel_agent.js +17 -3
  8. package/dist/cjs/agents/readonly_context.js +4 -1
  9. package/dist/cjs/agents/sequential_agent.js +34 -12
  10. package/dist/cjs/code_executors/base_code_executor.js +12 -2
  11. package/dist/cjs/code_executors/built_in_code_executor.js +15 -3
  12. package/dist/cjs/code_executors/code_execution_utils.js +2 -12
  13. package/dist/cjs/code_executors/code_executor_context.js +2 -12
  14. package/dist/cjs/common.js +41 -0
  15. package/dist/cjs/examples/base_example_provider.js +18 -2
  16. package/dist/cjs/examples/example_util.js +1 -1
  17. package/dist/cjs/index.js +11 -11
  18. package/dist/cjs/index.js.map +4 -4
  19. package/dist/cjs/plugins/base_plugin.js +59 -49
  20. package/dist/cjs/plugins/security_plugin.js +4 -1
  21. package/dist/cjs/runner/runner.js +38 -27
  22. package/dist/cjs/sessions/in_memory_session_service.js +3 -13
  23. package/dist/cjs/tools/agent_tool.js +18 -9
  24. package/dist/cjs/tools/base_tool.js +16 -6
  25. package/dist/cjs/tools/function_tool.js +14 -5
  26. package/dist/cjs/tools/google_search_tool.js +8 -3
  27. package/dist/cjs/tools/tool_context.js +4 -9
  28. package/dist/cjs/utils/gemini_schema_util.js +1 -0
  29. package/dist/cjs/version.js +1 -1
  30. package/dist/esm/agents/base_agent.js +9 -3
  31. package/dist/esm/agents/content_processor_utils.js +1 -1
  32. package/dist/esm/agents/functions.js +1 -1
  33. package/dist/esm/agents/invocation_context.js +3 -1
  34. package/dist/esm/agents/llm_agent.js +166 -84
  35. package/dist/esm/agents/loop_agent.js +14 -4
  36. package/dist/esm/agents/parallel_agent.js +15 -2
  37. package/dist/esm/agents/readonly_context.js +4 -1
  38. package/dist/esm/agents/sequential_agent.js +33 -12
  39. package/dist/esm/code_executors/base_code_executor.js +10 -1
  40. package/dist/esm/code_executors/built_in_code_executor.js +13 -2
  41. package/dist/esm/code_executors/code_execution_utils.js +1 -1
  42. package/dist/esm/code_executors/code_executor_context.js +1 -1
  43. package/dist/esm/common.js +53 -10
  44. package/dist/esm/examples/base_example_provider.js +16 -1
  45. package/dist/esm/examples/example_util.js +4 -2
  46. package/dist/esm/index.js +11 -11
  47. package/dist/esm/index.js.map +4 -4
  48. package/dist/esm/plugins/base_plugin.js +59 -49
  49. package/dist/esm/plugins/security_plugin.js +4 -1
  50. package/dist/esm/runner/runner.js +47 -30
  51. package/dist/esm/sessions/in_memory_session_service.js +1 -1
  52. package/dist/esm/tools/agent_tool.js +17 -9
  53. package/dist/esm/tools/base_tool.js +14 -5
  54. package/dist/esm/tools/function_tool.js +13 -7
  55. package/dist/esm/tools/google_search_tool.js +9 -3
  56. package/dist/esm/tools/tool_context.js +4 -9
  57. package/dist/esm/utils/gemini_schema_util.js +1 -0
  58. package/dist/esm/version.js +1 -1
  59. package/dist/types/agents/base_agent.d.ts +14 -3
  60. package/dist/types/agents/invocation_context.d.ts +4 -2
  61. package/dist/types/agents/llm_agent.d.ts +42 -30
  62. package/dist/types/agents/loop_agent.d.ts +16 -0
  63. package/dist/types/agents/parallel_agent.d.ts +16 -0
  64. package/dist/types/agents/sequential_agent.d.ts +17 -1
  65. package/dist/types/auth/auth_schemes.d.ts +5 -2
  66. package/dist/types/code_executors/base_code_executor.d.ts +14 -0
  67. package/dist/types/code_executors/built_in_code_executor.d.ts +19 -0
  68. package/dist/types/common.d.ts +38 -14
  69. package/dist/types/examples/base_example_provider.d.ts +16 -0
  70. package/dist/types/plugins/base_plugin.d.ts +50 -40
  71. package/dist/types/runner/runner.d.ts +17 -9
  72. package/dist/types/tools/agent_tool.d.ts +14 -0
  73. package/dist/types/tools/base_tool.d.ts +14 -0
  74. package/dist/types/tools/function_tool.d.ts +14 -1
  75. package/dist/types/tools/google_search_tool.d.ts +3 -4
  76. package/dist/types/tools/tool_context.d.ts +1 -1
  77. package/dist/types/version.d.ts +1 -1
  78. package/dist/web/agents/base_agent.js +9 -3
  79. package/dist/web/agents/content_processor_utils.js +1 -1
  80. package/dist/web/agents/functions.js +1 -1
  81. package/dist/web/agents/invocation_context.js +3 -1
  82. package/dist/web/agents/llm_agent.js +166 -84
  83. package/dist/web/agents/loop_agent.js +14 -4
  84. package/dist/web/agents/parallel_agent.js +15 -2
  85. package/dist/web/agents/readonly_context.js +4 -1
  86. package/dist/web/agents/sequential_agent.js +33 -12
  87. package/dist/web/code_executors/base_code_executor.js +10 -1
  88. package/dist/web/code_executors/built_in_code_executor.js +13 -2
  89. package/dist/web/code_executors/code_execution_utils.js +1 -1
  90. package/dist/web/code_executors/code_executor_context.js +1 -1
  91. package/dist/web/common.js +53 -10
  92. package/dist/web/examples/base_example_provider.js +16 -1
  93. package/dist/web/examples/example_util.js +4 -2
  94. package/dist/web/index.js +1 -1
  95. package/dist/web/index.js.map +4 -4
  96. package/dist/web/plugins/base_plugin.js +59 -49
  97. package/dist/web/plugins/security_plugin.js +4 -1
  98. package/dist/web/runner/runner.js +48 -31
  99. package/dist/web/sessions/in_memory_session_service.js +1 -1
  100. package/dist/web/tools/agent_tool.js +17 -9
  101. package/dist/web/tools/base_tool.js +14 -5
  102. package/dist/web/tools/function_tool.js +13 -7
  103. package/dist/web/tools/google_search_tool.js +9 -3
  104. package/dist/web/tools/tool_context.js +4 -9
  105. package/dist/web/utils/gemini_schema_util.js +1 -0
  106. package/dist/web/version.js +1 -1
  107. 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(config.beforeAgentCallback);
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(`Agent "${subAgent.name}" already has a parent agent, current parent: "${subAgent.parentAgent.name}", trying to add: "${this.name}"`);
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(`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.`);
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 import_cloneDeep = __toESM(require("lodash-es/cloneDeep.js"), 1);
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, import_cloneDeep.default)(event.content);
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 import_isEmpty = __toESM(require("lodash-es/isEmpty.js"), 1);
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, import_isEmpty.default)(functionResponseEvent.actions.requestedAuthConfigs)) {
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, import_isEmpty.default)(functionResponseEvent.actions.requestedToolConfirmations)) {
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(`Max number of llm calls limit of ${runConfig.maxLlmCalls} exceeded`);
50
+ throw new Error(
51
+ `Max number of llm calls limit of ${runConfig.maxLlmCalls} exceeded`
52
+ );
51
53
  }
52
54
  }
53
55
  }