/** * 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; 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; /** * Execute multiple subtasks in parallel */ private executeParallel; /** * Execute a single subtask with retry logic */ executeSubtask(plan: ExecutionPlan, subtaskId: string, inputs: Map): Promise; /** * Attempt to execute a subtask with a specific model */ private attemptExecution; /** * Build the prompt for a subtask */ private buildPrompt; /** * Get max tokens based on subtask complexity */ 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, latency?: number); complete(model: ModelConfig, prompt: string): Promise<{ content: string; tokensUsed: { input: number; output: number; }; latencyMs: number; }>; } //# sourceMappingURL=executor.d.ts.map