import { ActionType, LLMModel } from "./interface/FpfClient"; import type FpfWorker from "./worker"; /** * Configuration interface for creating an FpfAgent */ interface IFpfAgent { /** Display name for the agent */ name: string; /** High-level goal driving the agent's behavior */ goal: string; /** Detailed description of the agent's purpose and personality */ description: string; /** Array of workers that can execute tasks for this agent */ workers: FpfWorker[]; /** Optional function to provide custom agent state */ getAgentState?: () => Promise>; /** LLM model to use for agent reasoning (defaults to Llama-3.1-405B-Instruct) */ llmModel?: LLMModel | string; /** Base URL for custom LLM endpoint */ llmModelBaseUrl?: string; /** API key for custom LLM endpoint */ llmModelApiKey?: string; } /** * FpfAgent represents an autonomous AI agent that can execute tasks through workers * * @example * ```typescript * const agent = new FpfAgent(apiKey, { * name: "Trading Agent", * goal: "Maximize portfolio value", * description: "AI trading agent for Solana DeFi", * workers: [tradingWorker, analysisWorker] * }); * * await agent.init(); * await agent.run(60, { verbose: true }); * ``` */ declare class FpfAgent implements IFpfAgent { name: string; goal: string; description: string; workers: FpfWorker[]; getAgentState?: () => Promise>; private workerId; private fpfClient; private agentId; private mapId; private fpfActionResult; /** * Log a message with the agent's name prefix * @param msg - Message to log */ log(msg: string): void; /** * Create a new FpfAgent * @param apiKey - API key for authentication (starts with 'sa-' or 'apt-') * @param options - Agent configuration options * @throws {Error} If workers array is empty * @throws {Error} If custom LLM URL is provided without API key (or vice versa) */ constructor(apiKey: string, options: IFpfAgent); /** * Initialize the agent by creating map and agent on the backend * Must be called before running the agent * @throws {Error} If map or agent creation fails */ init(): Promise; /** * Set a custom logger for the agent * @param logger - Custom logging function that receives the agent instance and message */ setLogger(logger: (agent: FpfAgent, msg: string) => void): void; /** * Get a worker by its ID * @param workerId - The ID of the worker to retrieve * @returns The worker with the specified ID * @throws {Error} If worker with the specified ID is not found */ getWorkerById(workerId: string): FpfWorker; /** * Execute one step of the agent's decision-making process * @param options - Options for step execution * @param options.verbose - Enable detailed logging * @returns The action type that was executed * @throws {Error} If agent is not initialized * @throws {Error} If worker or function is not found */ step(options?: { verbose: boolean; }): Promise; /** * Run the agent continuously with a fixed interval between steps * The agent will run until it encounters a Wait or Unknown action * @param heartbeatSeconds - Interval in seconds between each step * @param options - Run options * @param options.verbose - Enable detailed logging * @throws {Error} If agent is not initialized */ run(heartbeatSeconds: number, options?: { verbose: boolean; }): Promise; /** * Save the current agent state for later restoration * @returns Object containing agent ID, map ID, and last action result */ save(): Record; /** * Initialize all workers with the agent's configuration * @internal */ initWorkers(): Promise; /** * Load an agent from saved state * @param apiKey - API key for authentication * @param name - Agent name * @param goal - Agent goal * @param description - Agent description * @param savedState - Previously saved agent state from save() * @param workers - Array of workers * @returns A new FpfAgent instance restored from saved state */ static load(apiKey: string, name: string, goal: string, description: string, savedState: Record, workers: FpfWorker[]): Promise; } export default FpfAgent; //# sourceMappingURL=agent.d.ts.map