/**
 * Task Executor
 *
 * Tier 2 of the Multi-Model Architecture.
 * Responsible for:
 * - Executing subtasks following planner specifications
 * - Managing retries and fallbacks
 * - Tracking execution results and costs
 */
import { ExecutionPlan, ExecutionResult, ModelConfig, MultiModelConfig } from './types.js';
import { ModelRouter } from './router.js';
import { TaskPlanner } from './planner.js';
/**
 * Model client interface for executing prompts
 */
export interface ModelClient {
    complete(model: ModelConfig, prompt: string, options?: {
        maxTokens?: number;
        timeout?: number;
        temperature?: number;
    }): Promise<{
        content: string;
        tokensUsed: {
            input: number;
            output: number;
        };
        latencyMs: number;
    }>;
}
/**
 * Execution context passed to model calls
 */
export interface ExecutionContext {
    planId: string;
    subtaskId: string;
    inputs: Map<string, string>;
    constraints: string[];
    previousAttempts: ExecutionResult[];
}
/**
 * Executor options
 */
export interface ExecutorOptions {
    maxRetries?: number;
    retryDelayMs?: number;
    stepTimeout?: number;
    enableFallback?: boolean;
    parallelExecution?: boolean;
    maxParallel?: number;
}
/**
 * Task Executor - executes plans created by the planner
 */
export declare class TaskExecutor {
    private router;
    readonly config: MultiModelConfig;
    private client;
    private options;
    private results;
    constructor(router: ModelRouter, config: MultiModelConfig, client: ModelClient, options?: ExecutorOptions);
    /**
     * Execute a complete plan
     */
    executePlan(plan: ExecutionPlan, planner: TaskPlanner, onProgress?: (result: ExecutionResult) => void): Promise<ExecutionResult[]>;
    /**
     * Execute multiple subtasks in parallel
     */
    private executeParallel;
    /**
     * Execute a single subtask with retry logic
     */
    executeSubtask(plan: ExecutionPlan, subtaskId: string, inputs: Map<string, string>): Promise<ExecutionResult>;
    /**
     * Attempt to execute a subtask with a specific model.
     * Uses withTimeout for hard deadline enforcement and PerformanceMonitor for tracking.
     */
    private attemptExecution;
    /**
     * Build the prompt for a subtask
     */
    private buildPrompt;
    /**
     * Build prompt with optional tool_call_batching suffix from model profile.
     */
    private buildPromptWithProfile;
    /**
     * Get temperature from model profile with optional dynamic decay per retry.
     * Returns undefined if no profile is configured (uses model default).
     */
    private getProfileTemperature;
    /**
     * Load model profile by ID. Caches the result.
     */
    private _rateLimitState;
    /**
     * Enforce per-model rate limits from profile configuration.
     * Waits if the rate limit window is exceeded.
     */
    private enforceRateLimit;
    private _profileCache;
    private _profileLoaderPromise;
    private getModelProfile;
    /**
     * Get max tokens based on subtask complexity.
     *
     * Previous values (2K/4K/8K/12K) caused premature truncation on local
     * models like Qwen3.5 35B A3B where generation is free and responses
     * routinely exceed 4K tokens for code tasks.
     */
    private getMaxTokens;
    /**
     * Create an error result
     */
    private createErrorResult;
    /**
     * Helper to delay
     */
    private delay;
    /**
     * Get results for a plan
     */
    getResults(planId: string): ExecutionResult[] | undefined;
    /**
     * Get total cost for a plan
     */
    getTotalCost(planId: string): number;
    /**
     * Get success rate for a plan
     */
    getSuccessRate(planId: string): number;
    /**
     * Generate execution summary
     */
    generateSummary(planId: string): string;
}
/**
 * Create an executor instance
 */
export declare function createExecutor(router: ModelRouter, config: MultiModelConfig, client: ModelClient, options?: ExecutorOptions): TaskExecutor;
/**
 * Mock client for testing
 */
export declare class MockModelClient implements ModelClient {
    private responses;
    private latency;
    constructor(responses?: Record<string, string>, latency?: number);
    complete(model: ModelConfig, prompt: string): Promise<{
        content: string;
        tokensUsed: {
            input: number;
            output: number;
        };
        latencyMs: number;
    }>;
}
//# sourceMappingURL=executor.d.ts.map