/** * CodeAgent - Code generation, execution, review, and refactoring * * Python parity with praisonaiagents/agent/code_agent.py */ /** * Configuration for CodeAgent. * Python parity with CodeConfig dataclass. */ export interface CodeConfig { /** Enable sandboxed execution (default: true for safety) */ sandbox?: boolean; /** Execution timeout in seconds */ timeout?: number; /** List of allowed programming languages */ allowedLanguages?: string[]; /** Maximum output length in characters */ maxOutputLength?: number; /** Working directory for code execution */ workingDirectory?: string; /** Environment variables for execution */ environment?: Record; } /** * Result of code execution. */ export interface CodeExecutionResult { /** Whether execution was successful */ success: boolean; /** Standard output from execution */ output: string; /** Error message if execution failed */ error?: string; /** Exit code from execution */ exitCode: number; /** Execution time in seconds */ executionTime: number; } /** * Configuration for creating a CodeAgent. */ export interface CodeAgentConfig { /** Agent name */ name?: string; /** LLM model (default: gpt-4o-mini) */ llm?: string; /** Code configuration (bool, object, or CodeConfig) */ code?: boolean | CodeConfig; /** System instructions */ instructions?: string; /** Enable verbose output */ verbose?: boolean; } /** * Agent for code generation, execution, review, and refactoring. * * This agent provides capabilities for: * - Generating code from natural language descriptions * - Executing code in a sandboxed environment * - Reviewing code for issues and improvements * - Refactoring and fixing code * - Explaining code functionality * * @example * ```typescript * import { CodeAgent } from 'praisonai'; * * const agent = new CodeAgent({ name: 'Coder' }); * * // Generate code * const code = await agent.generate('Write a function to calculate fibonacci'); * * // Execute code * const result = await agent.execute("console.log('Hello, World!')"); * * // Review code * const review = await agent.review(code); * ``` */ export declare class CodeAgent { readonly name: string; private readonly llm; private readonly instructions?; private readonly verbose; private readonly codeConfig; private readonly agent; constructor(config: CodeAgentConfig); private buildSystemPrompt; /** * Generate code from natural language description. * * @param prompt - Natural language description of desired code * @param language - Target programming language (default: python) * @returns Generated code as string */ generate(prompt: string, language?: string): Promise; /** * Alias for generate() method. */ generateCode(prompt: string, language?: string): Promise; /** * Execute code in a sandboxed environment. * * @param code - Code to execute * @param language - Programming language (default: python) * @returns Execution result */ execute(code: string, language?: string): Promise; /** * Alias for execute() method. */ executeCode(code: string, language?: string): Promise; /** * Review code for issues and improvements. * * @param code - Code to review * @param language - Programming language * @returns Review feedback */ review(code: string, language?: string): Promise; /** * Alias for review() method. */ reviewCode(code: string, language?: string): Promise; /** * Refactor code for better quality. * * @param code - Code to refactor * @param instructions - Specific refactoring instructions * @returns Refactored code */ refactor(code: string, instructions?: string): Promise; /** * Fix bugs in code. * * @param code - Code with bugs * @param errorMessage - Optional error message to help identify the bug * @returns Fixed code */ fix(code: string, errorMessage?: string): Promise; /** * Explain code functionality. * * @param code - Code to explain * @returns Explanation of the code */ explain(code: string): Promise; } /** * Create a CodeAgent instance. * * @param config - CodeAgent configuration * @returns CodeAgent instance */ export declare function createCodeAgent(config: CodeAgentConfig): CodeAgent;