/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import { ReadonlyContext } from '../agents/readonly_context.js'; import { LlmRequest } from '../models/llm_request.js'; import { Context } from '../agents/context.js'; import { BaseTool } from './base_tool.js'; /** * Function to decide whether a tool should be exposed to LLM. Toolset * implementer could consider whether to accept such instance in the toolset's * constructor and apply the predicate in getTools method. */ export type ToolPredicate = (tool: BaseTool, readonlyContext: ReadonlyContext) => boolean; /** * A unique symbol to identify ADK agent classes. * Defined once and shared by all BaseTool instances. */ declare const BASE_TOOLSET_SIGNATURE_SYMBOL: unique symbol; export declare function isBaseToolset(obj: unknown): obj is BaseToolset; /** * Base class for toolset. * * A toolset is a collection of tools that can be used by an agent. */ export declare abstract class BaseToolset { readonly toolFilter: ToolPredicate | string[]; readonly prefix?: string | undefined; readonly [BASE_TOOLSET_SIGNATURE_SYMBOL] = true; constructor(toolFilter: ToolPredicate | string[], prefix?: string | undefined); /** * Returns the tools that should be exposed to LLM. * * @param context Context used to filter tools available to the agent. If * not defined, all tools in the toolset are returned. * @return A Promise that resolves to the list of tools. */ abstract getTools(context?: ReadonlyContext): Promise; /** * Closes the toolset. * * NOTE: This method is invoked, for example, at the end of an agent server's * lifecycle or when the toolset is no longer needed. Implementations * should ensure that any open connections, files, or other managed * resources are properly released to prevent leaks. * * @return A Promise that resolves when the toolset is closed. */ abstract close(): Promise; /** * Returns whether the tool should be exposed to LLM. * * @param tool The tool to check. * @param context Context used to filter tools available to the agent. * @return Whether the tool should be exposed to LLM. */ protected isToolSelected(tool: BaseTool, context: ReadonlyContext): boolean; /** * Processes the outgoing LLM request for this toolset. This method will be * called before each tool processes the llm request. * * Use cases: * - Instead of let each tool process the llm request, we can let the toolset * process the llm request. e.g. ComputerUseToolset can add computer use * tool to the llm request. * * @param toolContext The context of the tool. * @param llmRequest The outgoing LLM request, mutable this method. */ processLlmRequest(toolContext: Context, // eslint-disable-line @typescript-eslint/no-unused-vars llmRequest: LlmRequest): Promise; } export {};