import { CodeBuddyClient, CodeBuddyToolCall } from "../codebuddy/client.js";
import { ToolSelectionResult } from "../codebuddy/tools.js";
import { ToolResult } from "../types/index.js";
import { BaseAgent } from "./base-agent.js";
import type { RouteAgentConfig } from "../channels/peer-routing.js";
import { MessageQueue, type MessageQueueMode } from "./message-queue.js";
export type { ChatEntry, StreamingChunk } from "./types.js";
import type { ChatEntry, StreamingChunk } from "./types.js";
/**
 * Main agent class that orchestrates conversation with CodeBuddy AI and tool execution
 *
 * Usage:
 * ```typescript
 * const agent = new CodeBuddyAgent(apiKey);
 * for await (const chunk of agent.processUserMessageStream("Hello")) {
 *   console.log(chunk);
 * }
 *
 * // Clean up when done
 * agent.dispose();
 * ```
 */
export declare class CodeBuddyAgent extends BaseAgent {
    /** Encapsulated infrastructure dependencies */
    private readonly infrastructure;
    private codebuddyClient;
    private toolHandler;
    private promptBuilder;
    private streamingHandler;
    private executor;
    private toolSelectionStrategy;
    /** Optional peer routing config applied from channel route resolution */
    private peerRoutingConfig;
    /** Message queue for steer/followup/collect modes */
    private messageQueue;
    private repairListeners;
    /** Cost prediction before execution */
    private costPredictor;
    /** Budget alert monitoring */
    private budgetAlertManager;
    /**
     * Create a new CodeBuddyAgent instance
     *
     * @param apiKey - API key for authentication
     * @param baseURL - Optional base URL for the API endpoint
     * @param model - Optional model name (defaults to saved model or grok-code-fast-1)
     * @param maxToolRounds - Maximum tool execution rounds (default: depends on YOLO mode)
     * @param useRAGToolSelection - Enable RAG-based tool selection (default: true)
     */
    constructor(apiKey: string, baseURL?: string, model?: string, maxToolRounds?: number, useRAGToolSelection?: boolean, systemPromptId?: string);
    /** Resolves when the system prompt has been loaded (or failed gracefully). */
    systemPromptReady: Promise<void>;
    private initializeAgentSystemPrompt;
    private isGrokModel;
    /**
     * Match the user query against the skill registry and apply the matched
     * skill's context to the tool selection strategy (for tool augmentation)
     * and inject the skill's system prompt into the conversation.
     *
     * This is called at the start of every message processing cycle.
     */
    private applySkillMatching;
    processUserMessage(message: string): Promise<ChatEntry[]>;
    processUserMessageStream(message: string): AsyncGenerator<StreamingChunk, void, unknown>;
    protected executeTool(toolCall: CodeBuddyToolCall): Promise<ToolResult>;
    isAutoRepairEnabled(): boolean;
    setAutoRepair(enabled: boolean): void;
    attemptAutoRepair(errorOutput: string, command?: string): Promise<{
        attempted: boolean;
        success: boolean;
        fixes: unknown[];
        message?: string;
    }>;
    getChatHistory(): ChatEntry[];
    getCurrentDirectory(): string;
    executeBashCommand(command: string): Promise<ToolResult>;
    getCurrentModel(): string;
    getClient(): CodeBuddyClient;
    setModel(model: string): void;
    /**
     * Probe the model to check if it supports function calling
     * Makes a quick test request with a simple tool
     */
    probeToolSupport(): Promise<boolean>;
    switchToChatOnlyMode(): void;
    abortCurrentOperation(): void;
    clearChat(): void;
    processImage(imagePath: string): Promise<ToolResult>;
    isImageFile(filePath: string): boolean;
    /**
     * Enable or disable RAG-based tool selection
     *
     * When enabled, only semantically relevant tools are sent to the LLM,
     * reducing prompt bloat and improving tool selection accuracy.
     *
     * @param enabled - Whether to enable RAG tool selection
     */
    setRAGToolSelection(enabled: boolean): void;
    /**
     * Check if RAG tool selection is enabled
     */
    isRAGToolSelectionEnabled(): boolean;
    /**
     * Get the last tool selection result
     *
     * Contains information about which tools were selected,
     * their scores, and token savings.
     */
    getLastToolSelection(): ToolSelectionResult | null;
    /**
     * Get a formatted summary of the last tool selection
     */
    formatToolSelectionStats(): string;
    /**
     * Classify a query to understand what types of tools might be needed
     */
    classifyUserQuery(query: string): import("./index.js").QueryClassification;
    /**
     * Get tool selection metrics (success rates, missed tools, etc.)
     */
    getToolSelectionMetrics(): import("./index.js").ToolSelectionMetrics;
    /**
     * Format tool selection metrics as a readable string
     */
    formatToolSelectionMetrics(): string;
    /**
     * Get most frequently missed tools for debugging
     */
    getMostMissedTools(limit?: number): {
        tool: string;
        count: number;
    }[];
    /**
     * Reset tool selection metrics
     */
    resetToolSelectionMetrics(): void;
    /**
     * Get cache statistics
     */
    getCacheStats(): {
        hasCachedTools: boolean;
        cachedToolCount: number;
        cacheAge: number;
        isValid: boolean;
        classificationCache: {
            size: number;
        };
        selectionCache: {
            size: number;
        };
    };
    /**
     * Clear all caches
     */
    clearCaches(): void;
    /**
     * Enable or disable parallel tool execution
     *
     * When enabled, multiple read-only tool calls (view_file, search, web_search, etc.)
     * will be executed in parallel for faster response times.
     *
     * Write operations are automatically serialized to prevent conflicts.
     *
     * @param enabled - Whether to enable parallel tool execution
     */
    setParallelToolExecution(enabled: boolean): void;
    /**
     * Enable or disable self-healing for bash commands
     *
     * When enabled, failed bash commands will attempt automatic remediation.
     * When disabled (via --no-self-heal flag), commands fail without auto-fix attempts.
     *
     * @param enabled - Whether to enable self-healing
     */
    setSelfHealing(enabled: boolean): void;
    /**
     * Add context files content to the agent's message history.
     * Inserted as a system message after the main system prompt.
     */
    addSystemContext(contextContent: string): void;
    /**
     * Check if self-healing is enabled for bash commands
     */
    isSelfHealingEnabled(): boolean;
    /**
     * Set a custom system prompt (for custom agents)
     *
     * This replaces the current system prompt with a custom one.
     * Used by --agent flag to load custom agent configurations.
     *
     * @param prompt - The custom system prompt content
     */
    setSystemPrompt(prompt: string): void;
    /**
     * Get the current system prompt
     */
    getSystemPrompt(): string | null;
    /**
     * Check if parallel tool execution is enabled
     */
    isParallelToolExecutionEnabled(): boolean;
    /**
     * Enable or disable YOLO mode
     *
     * YOLO mode enables full autonomy with:
     * - 400 max tool rounds (vs 50 in normal mode)
     * - No session cost limit
     * - Aggressive system prompt for autonomous operation
     *
     * @param enabled - Whether to enable YOLO mode
     */
    setYoloMode(enabled: boolean): void;
    /**
     * Enable auto-observation middleware for the computer-use verify loop.
     * Lazily imports and adds AutoObservationMiddleware to the executor's pipeline.
     * Called automatically when a profile with metadata.enableAutoObservation is active.
     */
    enableAutoObservation(config?: Partial<import('./middleware/auto-observation.js').AutoObservationConfig>): void;
    /**
     * Record cost for current request
     * @param inputTokens - Number of input tokens
     * @param outputTokens - Number of output tokens
     */
    private recordSessionCost;
    /**
     * Format cost status for display
     */
    formatCostStatus(): string;
    /**
     * Apply peer routing configuration to the agent.
     *
     * When a message is resolved to a specific route via the PeerRouter,
     * the resulting RouteAgentConfig can be applied here to override model,
     * system prompt, temperature, and tool constraints for that session.
     *
     * @param config - The route agent config from peer routing resolution
     */
    /**
     * Set the message queue mode (steer/followup/collect)
     */
    setMessageQueueMode(mode: MessageQueueMode): void;
    /**
     * Get the message queue instance for external enqueuing
     */
    getMessageQueue(): MessageQueue;
    applyPeerRouting(config: RouteAgentConfig): void;
    /**
     * Get the currently applied peer routing configuration.
     *
     * @returns The current peer routing config, or null if none is applied
     */
    getPeerRoutingConfig(): RouteAgentConfig | null;
    /**
     * Clear peer routing configuration, reverting to defaults.
     */
    clearPeerRouting(): void;
    /**
     * Check if a message should be forwarded to a different agent
     * based on the peer routing config.
     *
     * @returns The target agent ID if message should be forwarded, null otherwise
     */
    shouldForwardToAgent(): string | null;
    /**
     * Check if a request is complex enough to warrant planning
     */
    needsPlanning(request: string): boolean;
    /**
     * Execute a complex request via task planning and DAG execution
     */
    executePlan(request: string): Promise<ChatEntry[]>;
    /**
     * Check if a request needs multi-agent orchestration
     */
    needsOrchestration(request: string): boolean;
    /**
     * Clean up all resources
     * Should be called when the agent is no longer needed
     */
    dispose(): void;
}
