adk-typescript
Version:
TypeScript port of Google's Agent Development Kit (ADK)
81 lines (80 loc) • 2.12 kB
TypeScript
import { ToolContext } from './ToolContext';
/**
* Function declaration schema
*/
export interface FunctionDeclaration {
name: string;
description: string;
parameters: any;
}
/**
* Options for creating a BaseTool
*/
export interface BaseToolOptions {
/**
* The name of the tool
*/
name: string;
/**
* The description of the tool
*/
description: string;
/**
* Whether the tool is a long-running operation
*/
isLongRunning?: boolean;
}
/**
* Base class for all tools
*/
export declare abstract class BaseTool {
/**
* The name of the tool
*/
readonly name: string;
/**
* The description of the tool
*/
readonly description: string;
/**
* Whether the tool is a long-running operation
*/
readonly isLongRunning: boolean;
/**
* Create a new base tool
* @param options Options for the base tool
*/
constructor(options: BaseToolOptions);
/**
* Internal method to get the function declaration
* @returns The function declaration for this tool
*/
protected _getDeclaration(): FunctionDeclaration | null;
/**
* Get the declaration for this tool
* @returns The function declaration for this tool
*/
getDeclaration(): FunctionDeclaration | null;
/**
* Get the parameters for this tool
* @returns The parameters for this tool
*/
getParameters(): any;
/**
* Execute the tool
* @param params The parameters for the tool execution
* @param context The context for the tool execution
* @returns The result of the tool execution
*/
abstract execute(params: Record<string, any>, context: ToolContext): Promise<any>;
/**
* Find a tool in the LLM request that has function declarations
* @param llmRequest The LLM request to search in
* @returns The tool with function declarations, or null if not found
*/
private _findToolWithFunctionDeclarations;
/**
* Get the API variant (Vertex AI or Google AI)
*/
protected get _apiVariant(): string;
}