declare module "agents-js" { export interface AgentOptions { name?: string; model?: string; instructions?: string | ((context: Record) => string); functions?: (Function | ToolConfirmation)[]; toolChoice?: string | null; parallelToolCalls?: boolean; beforeModel?: (context: CallbackContext) => Promise | any; afterModel?: ( context: CallbackContext & { response: any } ) => Promise | any; beforeTool?: ( toolName: string, args: Record, contextVariables: Record ) => Promise | boolean | void; afterTool?: ( toolName: string, args: Record, result: Result, contextVariables: Record ) => Promise | void; subAgents?: Agent[]; description?: string; } export interface CallbackContext { agent: Agent; messages: Message[]; contextVariables: Record; } export interface Message { role: "system" | "user" | "assistant" | "tool"; content: string; tool_calls?: ToolCall[]; tool_call_id?: string; tool_name?: string; sender?: string; } export interface ToolCall { id: string; type: string; function: { name: string; arguments: string; }; } export class Agent { name: string; model: string; instructions: string | ((context: Record) => string); functions: (Function | ToolConfirmation)[]; toolChoice: string | null; parallelToolCalls: boolean; beforeModel: ((context: CallbackContext) => Promise | any) | null; afterModel: | ((context: CallbackContext & { response: any }) => Promise | any) | null; beforeTool: | (( toolName: string, args: Record, contextVariables: Record ) => Promise | boolean | void) | null; afterTool: | (( toolName: string, args: Record, result: Result, contextVariables: Record ) => Promise | void) | null; subAgents: Agent[]; description: string; _originalSubAgents: Agent[]; constructor(options?: AgentOptions); } export interface ResultOptions { value?: string; agent?: Agent | null; agentName?: string | null; contextVariables?: Record; } export class Result { value: string; agent: Agent | null; agentName: string | null; contextVariables: Record; constructor(options?: ResultOptions); } export interface TokenUsage { totalInputTokens: number; totalOutputTokens: number; inputTokens?: number; outputTokens?: number; totalTokens?: number; } export interface ResponseOptions { messages?: Message[]; agent?: Agent | null; contextVariables?: Record; tokenUsage?: TokenUsage | null; } export class Response { messages: Message[]; agent: Agent | null; contextVariables: Record; tokenUsage: TokenUsage | null; constructor(options?: ResponseOptions); } export interface SessionOptions { id?: string | null; storage?: Storage | null; } export class Session { id: string; storage: Storage | null; data: Record; constructor(options?: SessionOptions); get(key: string): Promise; set(key: string, value: any): Promise; delete(key: string): Promise; clear(): Promise; } export interface Storage { get(sessionId: string, key: string): Promise; set(sessionId: string, key: string, value: any): Promise; delete(sessionId: string, key: string): Promise; clear(sessionId: string): Promise; } export class MemoryStorage implements Storage { store: Record>; constructor(); get(sessionId: string, key: string): Promise; set(sessionId: string, key: string, value: any): Promise; delete(sessionId: string, key: string): Promise; clear(sessionId: string): Promise; } export interface ToolConfirmationOptions { tool: Function; message?: string | null; autoConfirm?: boolean; } export class ToolConfirmation { tool: Function; message: string | null; autoConfirm: boolean; requiresConfirmation: boolean; constructor(options: ToolConfirmationOptions); } export interface AgentControllerOptions { confirmationHandler?: | (( toolName: string, args: Record, message: string ) => Promise) | null; apiKeys?: Record; enableLogging?: boolean; } export class AgentController { client: any; confirmationHandler: | (( toolName: string, args: Record, message: string ) => Promise) | null; apiKeys: Record; tokenUsage: TokenUsage; enableLogging: boolean; constructor(client: any, options?: AgentControllerOptions); setApiKey(service: string, key: string): void; getApiKey(service: string): string | undefined; updateTokenUsage(model: string, usage: any): TokenUsage; resetTokenUsage(): void; getTokenUsage(): TokenUsage; log( message: string, type?: | "info" | "success" | "warning" | "error" | "transfer" | "tool" | "agent" ): void; getChatCompletion( agent: Agent, history: Message[], contextVariables: Record, modelOverride: string | null, stream: boolean, debug: boolean ): Promise; handleFunctionResult(result: any, debug: boolean): Result; handleToolCalls( toolCalls: ToolCall[], functions: (Function | ToolConfirmation)[], contextVariables: Record, debug: boolean, agent: Agent ): Promise; runAndStream( agent: Agent, messages: Message[], contextVariables?: Record, modelOverride?: string | null, debug?: boolean, maxTurns?: number, executeTools?: boolean ): AsyncGenerator; run( agent: Agent, messages: Message[], contextVariables?: Record, modelOverride?: string | null, stream?: boolean, debug?: boolean, maxTurns?: number, executeTools?: boolean ): Promise | AsyncGenerator; } } declare module "agents-js/tools" { import { Result } from "agents-js"; export function serperSearch(params: { query: string }): Promise; export function firecrawlScrape(params: { url: string }): Promise; export function firecrawlSearch(params: { query: string }): Promise; export function firecrawlCrawl(params: { url: string; limit?: number; }): Promise; export function calculate(params: { expression: string }): Result; export function add(params: { a: number; b: number }): Result; export function subtract(params: { a: number; b: number }): Result; export function multiply(params: { a: number; b: number }): Result; export function divide(params: { a: number; b: number }): Result; export function getCurrentTime(params: { timezone?: string }): Result; export function getTimestamp(): Result; export function formatDate(params: { timestamp: number; format?: string; }): Result; }