@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
@@ -110,13 +110,13 @@ export declare abstract class BasePlugin {
110
110
  * This callback helps logging and modifying the user message before the
111
111
  * runner starts the invocation.
112
112
  *
113
- * @param invocationContext The context for the entire invocation.
114
- * @param userMessage The message content input by user.
113
+ * @param params.invocationContext The context for the entire invocation.
114
+ * @param params.userMessage The message content input by user.
115
115
  * @returns An optional `Content` to be returned to the ADK. Returning a
116
116
  * value to replace the user message. Returning `undefined` to proceed
117
117
  * normally.
118
118
  */
119
- onUserMessageCallback({ invocationContext, userMessage }: {
119
+ onUserMessageCallback(params: {
120
120
  invocationContext: InvocationContext;
121
121
  userMessage: Content;
122
122
  }): Promise<Content | undefined>;
@@ -126,13 +126,13 @@ export declare abstract class BasePlugin {
126
126
  * This is the first callback to be called in the lifecycle, ideal for global
127
127
  * setup or initialization tasks.
128
128
  *
129
- * @param invocationContext The context for the entire invocation, containing
129
+ * @param params.invocationContext The context for the entire invocation, containing
130
130
  * session information, the root agent, etc.
131
131
  * @returns An optional `Event` to be returned to the ADK. Returning a value
132
132
  * to halt execution of the runner and ends the runner with that event.
133
133
  * Return `undefined` to proceed normally.
134
134
  */
135
- beforeRunCallback({ invocationContext }: {
135
+ beforeRunCallback(params: {
136
136
  invocationContext: InvocationContext;
137
137
  }): Promise<Content | undefined>;
138
138
  /**
@@ -141,13 +141,13 @@ export declare abstract class BasePlugin {
141
141
  * This is the ideal place to make modification to the event before the event
142
142
  * is handled by the underlying agent app.
143
143
  *
144
- * @param invocationContext The context for the entire invocation.
145
- * @param event The event raised by the runner.
144
+ * @param params.invocationContext The context for the entire invocation.
145
+ * @param params.event The event raised by the runner.
146
146
  * @returns An optional value. A non-`undefined` return may be used by the
147
147
  * framework to modify or replace the response. Returning `undefined`
148
148
  * allows the original response to be used.
149
149
  */
150
- onEventCallback({ invocationContext, event }: {
150
+ onEventCallback(params: {
151
151
  invocationContext: InvocationContext;
152
152
  event: Event;
153
153
  }): Promise<Event | undefined>;
@@ -157,10 +157,10 @@ export declare abstract class BasePlugin {
157
157
  * This is the final callback in the ADK lifecycle, suitable for cleanup,
158
158
  * final logging, or reporting tasks.
159
159
  *
160
- * @param invocationContext The context for the entire invocation.
160
+ * @param params.invocationContext The context for the entire invocation.
161
161
  * @returns undefined
162
162
  */
163
- afterRunCallback({ invocationContext }: {
163
+ afterRunCallback(params: {
164
164
  invocationContext: InvocationContext;
165
165
  }): Promise<void>;
166
166
  /**
@@ -169,13 +169,13 @@ export declare abstract class BasePlugin {
169
169
  * This callback can be used for logging, setup, or to short-circuit the
170
170
  * agent's execution by returning a value.
171
171
  *
172
- * @param agent The agent that is about to run.
173
- * @param callbackContext The context for the agent invocation.
172
+ * @param params.agent The agent that is about to run.
173
+ * @param params.callbackContext The context for the agent invocation.
174
174
  * @returns An optional `Content` object. If a value is returned, it will
175
175
  * bypass the agent's callbacks and its execution, and return this value
176
176
  * directly. Returning `undefined` allows the agent to proceed normally.
177
177
  */
178
- beforeAgentCallback({ agent, callbackContext }: {
178
+ beforeAgentCallback(params: {
179
179
  agent: BaseAgent;
180
180
  callbackContext: CallbackContext;
181
181
  }): Promise<Content | undefined>;
@@ -185,13 +185,13 @@ export declare abstract class BasePlugin {
185
185
  * This callback can be used to inspect, log, or modify the agent's final
186
186
  * result before it is returned.
187
187
  *
188
- * @param agent The agent that has just run.
189
- * @param callbackContext The context for the agent invocation.
188
+ * @param params.agent The agent that has just run.
189
+ * @param params.callbackContext The context for the agent invocation.
190
190
  * @returns An optional `Content` object. If a value is returned, it will
191
191
  * replace the agent's original result. Returning `undefined` uses the
192
192
  * original, unmodified result.
193
193
  */
194
- afterAgentCallback({ agent, callbackContext }: {
194
+ afterAgentCallback(params: {
195
195
  agent: BaseAgent;
196
196
  callbackContext: CallbackContext;
197
197
  }): Promise<Content | undefined>;
@@ -202,13 +202,13 @@ export declare abstract class BasePlugin {
202
202
  * object. It can also be used to implement caching by returning a cached
203
203
  * `LlmResponse`, which would skip the actual model call.
204
204
  *
205
- * @param callbackContext The context for the current agent call.
206
- * @param llmRequest The prepared request object to be sent to the model.
205
+ * @param params.callbackContext The context for the current agent call.
206
+ * @param params.llmRequest The prepared request object to be sent to the model.
207
207
  * @returns An optional value. The interpretation of a non-`undefined`
208
208
  * trigger an early exit and returns the response immediately. Returning
209
209
  * `undefined` allows the LLM request to proceed normally.
210
210
  */
211
- beforeModelCallback({ callbackContext, llmRequest }: {
211
+ beforeModelCallback(params: {
212
212
  callbackContext: CallbackContext;
213
213
  llmRequest: LlmRequest;
214
214
  }): Promise<LlmResponse | undefined>;
@@ -218,13 +218,13 @@ export declare abstract class BasePlugin {
218
218
  * This is the ideal place to log model responses, collect metrics on token
219
219
  * usage, or perform post-processing on the raw `LlmResponse`.
220
220
  *
221
- * @param callbackContext The context for the current agent call.
222
- * @param llmResponse The response object received from the model.
221
+ * @param params.callbackContext The context for the current agent call.
222
+ * @param params.llmResponse The response object received from the model.
223
223
  * @returns An optional value. A non-`undefined` return may be used by the
224
224
  * framework to modify or replace the response. Returning `undefined`
225
225
  * allows the original response to be used.
226
226
  */
227
- afterModelCallback({ callbackContext, llmResponse }: {
227
+ afterModelCallback(params: {
228
228
  callbackContext: CallbackContext;
229
229
  llmResponse: LlmResponse;
230
230
  }): Promise<LlmResponse | undefined>;
@@ -234,15 +234,15 @@ export declare abstract class BasePlugin {
234
234
  * This callback provides an opportunity to handle model errors gracefully,
235
235
  * potentially providing alternative responses or recovery mechanisms.
236
236
  *
237
- * @param callbackContext The context for the current agent call.
238
- * @param llmRequest The request that was sent to the model when the error
237
+ * @param params.callbackContext The context for the current agent call.
238
+ * @param params.llmRequest The request that was sent to the model when the error
239
239
  * occurred.
240
- * @param error The exception that was raised during model execution.
240
+ * @param params.error The exception that was raised during model execution.
241
241
  * @returns An optional LlmResponse. If an LlmResponse is returned, it will be
242
242
  * used instead of propagating the error. Returning `undefined` allows
243
243
  * the original error to be raised.
244
244
  */
245
- onModelErrorCallback({ callbackContext, llmRequest, error }: {
245
+ onModelErrorCallback(params: {
246
246
  callbackContext: CallbackContext;
247
247
  llmRequest: LlmRequest;
248
248
  error: Error;
@@ -253,15 +253,15 @@ export declare abstract class BasePlugin {
253
253
  * This callback is useful for logging tool usage, input validation, or
254
254
  * modifying the arguments before they are passed to the tool.
255
255
  *
256
- * @param tool The tool instance that is about to be executed.
257
- * @param toolArgs The dictionary of arguments to be used for invoking the
256
+ * @param params.tool The tool instance that is about to be executed.
257
+ * @param params.toolArgs The dictionary of arguments to be used for invoking the
258
258
  * tool.
259
- * @param toolContext The context specific to the tool execution.
259
+ * @param params.toolContext The context specific to the tool execution.
260
260
  * @returns An optional dictionary. If a dictionary is returned, it will stop
261
261
  * the tool execution and return this response immediately. Returning
262
262
  * `undefined` uses the original, unmodified arguments.
263
263
  */
264
- beforeToolCallback({ tool, toolArgs, toolContext }: {
264
+ beforeToolCallback(params: {
265
265
  tool: BaseTool;
266
266
  toolArgs: Record<string, unknown>;
267
267
  toolContext: ToolContext;
@@ -272,36 +272,46 @@ export declare abstract class BasePlugin {
272
272
  * This callback allows for inspecting, logging, or modifying the result
273
273
  * returned by a tool.
274
274
  *
275
- * @param tool The tool instance that has just been executed.
276
- * @param toolArgs The original arguments that were passed to the tool.
277
- * @param toolContext The context specific to the tool execution.
278
- * @param result The dictionary returned by the tool invocation.
275
+ * @param params.tool The tool instance that has just been executed.
276
+ * @param params.toolArgs The original arguments that were passed to the tool.
277
+ * @param params.toolContext The context specific to the tool execution.
278
+ * @param params.result The dictionary returned by the tool invocation.
279
279
  * @returns An optional dictionary. If a dictionary is returned, it will
280
280
  * **replace** the original result from the tool. This allows for
281
281
  * post-processing or altering tool outputs. Returning `undefined` uses
282
282
  * the original, unmodified result.
283
283
  */
284
- afterToolCallback({ tool, toolArgs, toolContext, result }: {
284
+ afterToolCallback(params: {
285
285
  tool: BaseTool;
286
286
  toolArgs: Record<string, unknown>;
287
287
  toolContext: ToolContext;
288
288
  result: Record<string, unknown>;
289
289
  }): Promise<Record<string, unknown> | undefined>;
290
+ /**
291
+ * Callback executed when a tool call encounters an error.
292
+ tool: BaseTool;
293
+ toolArgs: Record<string, unknown>;
294
+ toolContext: ToolContext;
295
+ result: Record<string, unknown>;
296
+ }): Promise<Record<string, unknown> | undefined> {
297
+ return;
298
+ }
299
+
290
300
  /**
291
301
  * Callback executed when a tool call encounters an error.
292
302
  *
293
303
  * This callback provides an opportunity to handle tool errors gracefully,
294
304
  * potentially providing alternative responses or recovery mechanisms.
295
305
  *
296
- * @param tool The tool instance that encountered an error.
297
- * @param toolArgs The arguments that were passed to the tool.
298
- * @param toolContext The context specific to the tool execution.
299
- * @param error The exception that was raised during tool execution.
306
+ * @param params.tool The tool instance that encountered an error.
307
+ * @param params.toolArgs The arguments that were passed to the tool.
308
+ * @param params.toolContext The context specific to the tool execution.
309
+ * @param params.error The exception that was raised during tool execution.
300
310
  * @returns An optional dictionary. If a dictionary is returned, it will be
301
311
  * used as the tool response instead of propagating the error. Returning
302
312
  * `undefined` allows the original error to be raised.
303
313
  */
304
- onToolErrorCallback({ tool, toolArgs, toolContext, error }: {
314
+ onToolErrorCallback(params: {
305
315
  tool: BaseTool;
306
316
  toolArgs: Record<string, unknown>;
307
317
  toolContext: ToolContext;
@@ -13,8 +13,17 @@ import { BaseMemoryService } from '../memory/base_memory_service.js';
13
13
  import { BasePlugin } from '../plugins/base_plugin.js';
14
14
  import { PluginManager } from '../plugins/plugin_manager.js';
15
15
  import { BaseSessionService } from '../sessions/base_session_service.js';
16
- interface RunnerInput {
16
+ /**
17
+ * The configuration parameters for the Runner.
18
+ */
19
+ export interface RunnerConfig {
20
+ /**
21
+ * The application name.
22
+ */
17
23
  appName: string;
24
+ /**
25
+ * The agent to run.
26
+ */
18
27
  agent: BaseAgent;
19
28
  plugins?: BasePlugin[];
20
29
  artifactService?: BaseArtifactService;
@@ -30,19 +39,19 @@ export declare class Runner {
30
39
  readonly sessionService: BaseSessionService;
31
40
  readonly memoryService?: BaseMemoryService;
32
41
  readonly credentialService?: BaseCredentialService;
33
- constructor(input: RunnerInput);
42
+ constructor(input: RunnerConfig);
34
43
  /**
35
44
  * Runs the agent with the given message, and returns an async generator of
36
45
  * events.
37
46
  *
38
- * @param userId The user ID of the session.
39
- * @param sessionId The session ID of the session.
40
- * @param newMessage A new message to append to the session.
41
- * @param stateDelta An optional state delta to apply to the session.
42
- * @param runConfig The run config for the agent.
47
+ * @param params.userId The user ID of the session.
48
+ * @param params.sessionId The session ID of the session.
49
+ * @param params.newMessage A new message to append to the session.
50
+ * @param params.stateDelta An optional state delta to apply to the session.
51
+ * @param params.runConfig The run config for the agent.
43
52
  * @yields The events generated by the agent.
44
53
  */
45
- runAsync({ userId, sessionId, newMessage, stateDelta, runConfig, }: {
54
+ runAsync(params: {
46
55
  userId: string;
47
56
  sessionId: string;
48
57
  newMessage: Content;
@@ -77,4 +86,3 @@ export declare class Runner {
77
86
  */
78
87
  private isRoutableLlmAgent;
79
88
  }
80
- export {};
@@ -19,6 +19,17 @@ export interface AgentToolConfig {
19
19
  */
20
20
  skipSummarization?: boolean;
21
21
  }
22
+ /**
23
+ * A unique symbol to identify ADK agent classes.
24
+ * Defined once and shared by all BaseTool instances.
25
+ */
26
+ declare const AGENT_TOOL_SIGNATURE_SYMBOL: unique symbol;
27
+ /**
28
+ * Type guard to check if an object is an instance of BaseTool.
29
+ * @param obj The object to check.
30
+ * @returns True if the object is an instance of BaseTool, false otherwise.
31
+ */
32
+ export declare function isAgentTool(obj: unknown): obj is AgentTool;
22
33
  /**
23
34
  * A tool that wraps an agent.
24
35
  *
@@ -29,9 +40,12 @@ export interface AgentToolConfig {
29
40
  * @param config: The configuration of the agent tool.
30
41
  */
31
42
  export declare class AgentTool extends BaseTool {
43
+ /** A unique symbol to identify ADK agent tool class. */
44
+ readonly [AGENT_TOOL_SIGNATURE_SYMBOL] = true;
32
45
  private readonly agent;
33
46
  private readonly skipSummarization;
34
47
  constructor(config: AgentToolConfig);
35
48
  _getDeclaration(): FunctionDeclaration;
36
49
  runAsync({ args, toolContext }: RunAsyncToolRequest): Promise<unknown>;
37
50
  }
51
+ export {};
@@ -28,10 +28,23 @@ export interface BaseToolParams {
28
28
  description: string;
29
29
  isLongRunning?: boolean;
30
30
  }
31
+ /**
32
+ * A unique symbol to identify ADK agent classes.
33
+ * Defined once and shared by all BaseTool instances.
34
+ */
35
+ declare const BASE_TOOL_SIGNATURE_SYMBOL: unique symbol;
36
+ /**
37
+ * Type guard to check if an object is an instance of BaseTool.
38
+ * @param obj The object to check.
39
+ * @returns True if the object is an instance of BaseTool, false otherwise.
40
+ */
41
+ export declare function isBaseTool(obj: unknown): obj is BaseTool;
31
42
  /**
32
43
  * The base class for all tools.
33
44
  */
34
45
  export declare abstract class BaseTool {
46
+ /** A unique symbol to identify ADK base tool class. */
47
+ readonly [BASE_TOOL_SIGNATURE_SYMBOL] = true;
35
48
  readonly name: string;
36
49
  readonly description: string;
37
50
  readonly isLongRunning: boolean;
@@ -82,3 +95,4 @@ export declare abstract class BaseTool {
82
95
  */
83
96
  get apiVariant(): import("../utils/variant_utils.js").GoogleLLMVariant;
84
97
  }
98
+ export {};
@@ -12,7 +12,7 @@ import { ToolContext } from './tool_context.js';
12
12
  */
13
13
  export type ToolInputParameters = undefined | ZodObject<ZodRawShape> | Schema;
14
14
  export type ToolExecuteArgument<TParameters extends ToolInputParameters> = TParameters extends ZodObject<infer T, infer U, infer V> ? zInfer<ZodObject<T, U, V>> : TParameters extends Schema ? unknown : string;
15
- type ToolExecuteFunction<TParameters extends ToolInputParameters> = (input: ToolExecuteArgument<TParameters>, tool_context?: ToolContext) => Promise<unknown> | unknown;
15
+ export type ToolExecuteFunction<TParameters extends ToolInputParameters> = (input: ToolExecuteArgument<TParameters>, tool_context?: ToolContext) => Promise<unknown> | unknown;
16
16
  /**
17
17
  * The configuration options for creating a function-based tool.
18
18
  * The `name`, `description` and `parameters` fields are used to generate the
@@ -28,7 +28,20 @@ export type ToolOptions<TParameters extends ToolInputParameters> = {
28
28
  execute: ToolExecuteFunction<TParameters>;
29
29
  isLongRunning?: boolean;
30
30
  };
31
+ /**
32
+ * A unique symbol to identify ADK agent classes.
33
+ * Defined once and shared by all BaseTool instances.
34
+ */
35
+ declare const FUNCTION_TOOL_SIGNATURE_SYMBOL: unique symbol;
36
+ /**
37
+ * Type guard to check if an object is an instance of BaseTool.
38
+ * @param obj The object to check.
39
+ * @returns True if the object is an instance of BaseTool, false otherwise.
40
+ */
41
+ export declare function isFunctionTool(obj: unknown): obj is FunctionTool;
31
42
  export declare class FunctionTool<TParameters extends ToolInputParameters = undefined> extends BaseTool {
43
+ /** A unique symbol to identify ADK function tool class. */
44
+ readonly [FUNCTION_TOOL_SIGNATURE_SYMBOL] = true;
32
45
  private readonly execute;
33
46
  private readonly parameters?;
34
47
  /**
@@ -6,13 +6,12 @@ import { BaseTool, RunAsyncToolRequest, ToolProcessLlmRequest } from './base_too
6
6
  * This tool operates internally within the model and does not require or
7
7
  * perform local code execution.
8
8
  */
9
- declare class GoogleSearchTool extends BaseTool {
9
+ export declare class GoogleSearchTool extends BaseTool {
10
10
  constructor();
11
11
  runAsync(request: RunAsyncToolRequest): Promise<unknown>;
12
- processLlmRequest({ toolContext, llmRequest }: ToolProcessLlmRequest): Promise<void>;
12
+ processLlmRequest({ toolContext, llmRequest, }: ToolProcessLlmRequest): Promise<void>;
13
13
  }
14
14
  /**
15
- * A global instance of GoogleSearchTool.
15
+ * A global instance of {@link GoogleSearchTool}.
16
16
  */
17
17
  export declare const GOOGLE_SEARCH: GoogleSearchTool;
18
- export {};
@@ -24,7 +24,7 @@ export declare class ToolContext extends CallbackContext {
24
24
  * @param params.toolConfirmation The tool confirmation of the current tool
25
25
  * call.
26
26
  */
27
- constructor({ invocationContext, eventActions, functionCallId, toolConfirmation, }: {
27
+ constructor(params: {
28
28
  invocationContext: InvocationContext;
29
29
  eventActions?: EventActions;
30
30
  functionCallId?: string;
@@ -3,4 +3,4 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- export declare const version = "0.2.3";
6
+ export declare const version = "0.2.5";
@@ -60,7 +60,9 @@ class BaseAgent {
60
60
  this.parentAgent = config.parentAgent;
61
61
  this.subAgents = config.subAgents || [];
62
62
  this.rootAgent = getRootAgent(this);
63
- this.beforeAgentCallback = getCannonicalCallback(config.beforeAgentCallback);
63
+ this.beforeAgentCallback = getCannonicalCallback(
64
+ config.beforeAgentCallback
65
+ );
64
66
  this.afterAgentCallback = getCannonicalCallback(config.afterAgentCallback);
65
67
  this.setParentAgentForSubAgents();
66
68
  }
@@ -237,7 +239,9 @@ class BaseAgent {
237
239
  setParentAgentForSubAgents() {
238
240
  for (const subAgent of this.subAgents) {
239
241
  if (subAgent.parentAgent) {
240
- throw new Error('Agent "'.concat(subAgent.name, '" already has a parent agent, current parent: "').concat(subAgent.parentAgent.name, '", trying to add: "').concat(this.name, '"'));
242
+ throw new Error(
243
+ 'Agent "'.concat(subAgent.name, '" already has a parent agent, current parent: "').concat(subAgent.parentAgent.name, '", trying to add: "').concat(this.name, '"')
244
+ );
241
245
  }
242
246
  subAgent.parentAgent = this;
243
247
  }
@@ -245,7 +249,9 @@ class BaseAgent {
245
249
  }
246
250
  function validateAgentName(name) {
247
251
  if (!isIdentifier(name)) {
248
- throw new Error('Found invalid agent name: "'.concat(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.'));
252
+ throw new Error(
253
+ 'Found invalid agent name: "'.concat(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.')
254
+ );
249
255
  }
250
256
  if (name === "user") {
251
257
  throw new Error(
@@ -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-es/cloneDeep.js";
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-es/isEmpty.js";
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";
@@ -17,7 +17,9 @@ class InvocationCostManager {
17
17
  incrementAndEnforceLlmCallsLimit(runConfig) {
18
18
  this.numberOfLlmCalls++;
19
19
  if (runConfig && runConfig.maxLlmCalls > 0 && this.numberOfLlmCalls > runConfig.maxLlmCalls) {
20
- throw new Error("Max number of llm calls limit of ".concat(runConfig.maxLlmCalls, " exceeded"));
20
+ throw new Error(
21
+ "Max number of llm calls limit of ".concat(runConfig.maxLlmCalls, " exceeded")
22
+ );
21
23
  }
22
24
  }
23
25
  }