/**
 * Token Estimation Engine
 *
 * Calculates deployment quotes and pre-execution token estimates based on
 * team templates, model pricing, task complexity, and historical data.
 * Supports Phase 3 O8 KR1 objectives.
 *
 * @module services/monitoring/token-estimator.service
 */
/** Task complexity levels for estimation */
export type TaskComplexity = 'simple' | 'moderate' | 'complex' | 'very_complex';
/** Template role definition used for estimation */
export interface TemplateRole {
    role: string;
    label?: string;
    count: number;
    defaultTools?: string[];
    modelConfig?: {
        provider?: string;
        model?: string;
        temperature?: number;
    };
}
/** Parsed template structure for estimation */
export interface TemplateInfo {
    id: string;
    name: string;
    roles: TemplateRole[];
}
/** Request body for the estimate-tokens endpoint */
export interface EstimateTokensRequest {
    templateId: string;
    objective: string;
    modelId?: string;
}
/** Response from the estimate-tokens endpoint */
export interface TokenEstimate {
    estimatedInputTokens: number;
    estimatedOutputTokens: number;
    estimatedCost: number;
    confidence: 'low' | 'medium' | 'high';
    breakdown: {
        systemPromptTokens: number;
        toolOverheadTokens: number;
        conversationTokens: number;
        agentCount: number;
        estimatedTurns: number;
        taskComplexity: TaskComplexity;
        modelMultiplier: number;
        historicalCalibration: boolean;
    };
}
/** Quote result structure */
export interface DeploymentQuote {
    templateId: string;
    templateName: string;
    agentCount: number;
    estimatedCostPerTask: number;
    estimatedDailyBudget: number;
    serviceFee: number;
    totalEstimatedCost: number;
    modelBreakdown: Array<{
        model: string;
        percentage: number;
        costPerMillion: number;
    }>;
    currency: string;
}
/** Historical usage record for calibration */
export interface HistoricalUsageRecord {
    totalInput: number;
    totalOutput: number;
    eventCount: number;
}
/**
 * Service for estimating token usage costs before deployment.
 *
 * Provides two estimation modes:
 * 1. Deployment quotes (getQuote) — cost-focused estimates from cloud manifest
 * 2. Task token estimates (estimateTokens) — granular per-task predictions
 *    using template analysis, task complexity heuristics, and historical calibration
 */
export declare class TokenEstimatorService {
    private static instance;
    private projectPath;
    /**
     * Optional function to retrieve historical usage data for calibration.
     * Injected via setHistoricalDataProvider() to avoid circular dependency
     * with TokenUsageService.
     */
    private historicalDataProvider;
    constructor(projectPath?: string);
    /**
     * Get the singleton TokenEstimatorService instance.
     *
     * @param projectPath - Optional project path override
     * @returns The shared TokenEstimatorService instance
     */
    static getInstance(projectPath?: string): TokenEstimatorService;
    /**
     * Reset the singleton instance (for testing).
     */
    static resetInstance(): void;
    /**
     * Set the historical data provider for calibration.
     *
     * The provider function should return an array of historical usage records
     * (e.g. from TokenUsageService.getUsageBySessions()).
     *
     * @param provider - Function that returns historical usage records
     */
    setHistoricalDataProvider(provider: () => HistoricalUsageRecord[]): void;
    /**
     * Estimate token consumption for a task before execution.
     *
     * Algorithm:
     * 1. Load the template and count agents + tools per role
     * 2. Estimate system prompt tokens per agent
     * 3. Classify task complexity from the objective text
     * 4. Calculate per-turn token overhead (tools + conversation)
     * 5. Multiply by expected turns for the complexity level
     * 6. Apply model-specific efficiency multiplier
     * 7. If historical data exists, calibrate the estimate
     *
     * @param request - The estimation request (templateId, objective, optional modelId)
     * @returns Token estimate with cost and confidence
     * @throws Error if template cannot be loaded
     */
    estimateTokens(request: EstimateTokensRequest): Promise<TokenEstimate>;
    /**
     * Load a template from the templates directory.
     *
     * Searches for template.json in the template directory, then falls back
     * to a top-level {templateId}.json file.
     *
     * @param templateId - Template identifier (directory name or file stem)
     * @returns Parsed template info
     * @throws Error if template cannot be found or parsed
     */
    loadTemplate(templateId: string): Promise<TemplateInfo>;
    /**
     * Estimate system prompt tokens across all agents in a template.
     *
     * Uses DEFAULT_SYSTEM_PROMPT_TOKENS per agent as a baseline, scaled by
     * the number of tools (more tools = longer tool definitions in the prompt).
     *
     * @param template - Parsed template info
     * @returns Total estimated system prompt tokens across all agents
     */
    estimateSystemPromptTokens(template: TemplateInfo): number;
    /**
     * Classify task complexity from the objective text.
     *
     * Heuristic based on:
     * - Text length (longer descriptions → more complex tasks)
     * - Presence of complexity keywords
     *
     * @param objective - Task description / objective text
     * @returns Estimated task complexity level
     */
    classifyComplexity(objective: string): TaskComplexity;
    /**
     * Determine estimate confidence level.
     *
     * Higher confidence when:
     * - Historical calibration data is available
     * - Task complexity is lower (more predictable)
     * - Template has fewer agents (less variance)
     *
     * @param complexity - Task complexity
     * @param hasHistorical - Whether historical calibration was applied
     * @param agentCount - Number of agents in the template
     * @returns Confidence level
     */
    determineConfidence(complexity: TaskComplexity, hasHistorical: boolean, agentCount: number): 'low' | 'medium' | 'high';
    /**
     * Get historical usage data for calibration.
     *
     * @returns Array of historical usage records, or null if no provider set
     */
    private getHistoricalData;
    /**
     * Calculate a deployment quote for a specific template.
     *
     * @param templateId - ID of the team template
     * @returns Detailed deployment quote
     * @throws Error if template not found or manifest missing
     */
    getQuote(templateId: string): Promise<DeploymentQuote>;
    /**
     * Get quotes for all available cloud templates.
     *
     * @returns Array of deployment quotes for each template in the manifest
     */
    getAllQuotes(): Promise<DeploymentQuote[]>;
}
//# sourceMappingURL=token-estimator.service.d.ts.map