/** * Status enum for executable function responses */ export declare enum ExecutableFpfFunctionStatus { /** Function completed successfully */ Done = "done", /** Function failed to complete */ Failed = "failed" } export type ExecutableFpfFunctionResponseJSON = ReturnType; /** * Response object returned by executable functions */ export declare class ExecutableFpfFunctionResponse { status: ExecutableFpfFunctionStatus; feedback: string; /** * Create a new function response * @param status - Success or failure status * @param feedback - Human-readable feedback message describing the result */ constructor(status: ExecutableFpfFunctionStatus, feedback: string); /** * Convert the response to JSON format for API transmission * @param id - Action ID assigned by the backend * @returns JSON object with action details * @internal */ toJSON(id: string): { action_id: string; action_status: ExecutableFpfFunctionStatus; feedback_message: string; }; } /** * Function argument definition interface */ export interface FpfFunctionArg { /** Argument name */ name: string; /** Argument description for LLM understanding */ description: string; /** TypeScript type hint (e.g., "string", "number", "boolean") */ type?: string; /** Whether this argument is optional */ optional?: boolean; } /** * Interface for defining an FpfFunction */ export interface IFpfFunction { /** Unique function name (used for invocation) */ name: string; /** Description of what this function does */ description: string; /** Array of argument definitions */ args: T; /** The executable implementation */ executable: (args: Partial>, logger: (msg: string) => void) => Promise; /** Optional hint to guide the LLM on when/how to use this function */ hint?: string; } /** * Base type for function objects (used internally) */ export type FpfFunctionBase = { name: string; description: string; args: FpfFunctionArg[]; executable: (args: Record, logger: (msg: string) => void) => Promise; hint?: string; execute: (args: Record, logger: (msg: string) => void) => Promise; toJSON(): { fn_name: string; fn_description: string; args: FpfFunctionArg[]; hint?: string; }; }; type ExecutableArgs = { [K in T[number]["name"]]: string; }; /** * FpfFunction represents an atomic executable action that can be performed by a worker * * @example * ```typescript * const swapFunction = new FpfFunction({ * name: "swap_tokens", * description: "Execute a token swap on Solana using Jupiter", * args: [ * { name: "inputToken", type: "string", description: "Input token address" }, * { name: "outputToken", type: "string", description: "Output token address" }, * { name: "amount", type: "number", description: "Amount to swap" } * ] as const, * executable: async (args, logger) => { * logger(`Swapping ${args.amount} tokens`); * // Implementation here * return new ExecutableFpfFunctionResponse( * ExecutableFpfFunctionStatus.Done, * "Swap completed" * ); * } * }); * ``` */ declare class FpfFunction implements IFpfFunction { name: string; description: string; args: T; executable: (args: Partial>, logger: (msg: string) => void) => Promise; hint?: string; /** * Create a new FpfFunction * @param options - Function configuration */ constructor(options: IFpfFunction); /** * Convert function definition to JSON for API transmission * @returns JSON representation of the function * @internal */ toJSON(): { fn_name: string; fn_description: string; args: T; hint: string | undefined; }; /** * Execute the function with provided arguments * @param args - Arguments with value wrappers from API * @param logger - Logger function for outputting messages * @returns Promise resolving to function response * @internal */ execute(args: { [key in FpfFunctionArg["name"]]: { value: string; }; }, logger: (msg: string) => void): Promise; } export default FpfFunction; //# sourceMappingURL=function.d.ts.map