/**
 * Provider-aware token measurement and persistence.
 *
 * Central SSoT for CLI/MCP/tooling token estimation with a three-layer chain:
 * 1) OTel/provider telemetry when available
 * 2) Exact tokenizer for supported models
 * 3) Heuristic fallback calibrated for JSON vs text payloads
 *
 * @task T5618
 * @why CLEO needs a provider-aware in-house token service instead of relying on a single external runtime.
 * @what Adds central token measurement, persistence, CRUD, and summary helpers for CLI, MCP, tests, and telemetry tooling.
 */
import { type TokenUsageRow } from '../store/tasks-schema.js';
export type TokenMethod = 'otel' | 'provider_api' | 'tokenizer' | 'heuristic';
export type TokenConfidence = 'real' | 'high' | 'estimated' | 'coarse';
export type TokenTransport = 'cli' | 'mcp' | 'api' | 'agent' | 'unknown';
export interface TokenExchangeInput {
    requestPayload?: unknown;
    responsePayload?: unknown;
    provider?: string;
    model?: string;
    transport?: TokenTransport;
    gateway?: string;
    domain?: string;
    operation?: string;
    sessionId?: string;
    taskId?: string;
    requestId?: string;
    cwd?: string;
    metadata?: Record<string, unknown>;
}
export interface TokenMeasurement {
    inputChars: number;
    outputChars: number;
    inputTokens: number;
    outputTokens: number;
    totalTokens: number;
    method: TokenMethod;
    confidence: TokenConfidence;
    provider: string;
    model?: string;
    requestHash?: string;
    responseHash?: string;
    metadata: Record<string, unknown>;
}
export interface TokenUsageFilters {
    provider?: string;
    transport?: TokenTransport;
    gateway?: string;
    domain?: string;
    operation?: string;
    sessionId?: string;
    taskId?: string;
    method?: TokenMethod;
    confidence?: TokenConfidence;
    requestId?: string;
    since?: string;
    until?: string;
    limit?: number;
    offset?: number;
}
export interface TokenUsageSummary {
    totalRecords: number;
    inputTokens: number;
    outputTokens: number;
    totalTokens: number;
    byMethod: Array<{
        method: string;
        count: number;
        totalTokens: number;
    }>;
    byTransport: Array<{
        transport: string;
        count: number;
        totalTokens: number;
    }>;
    byOperation: Array<{
        key: string;
        count: number;
        totalTokens: number;
    }>;
}
export declare function measureTokenExchange(input: TokenExchangeInput): Promise<TokenMeasurement>;
export declare function recordTokenExchange(input: TokenExchangeInput): Promise<TokenUsageRow>;
export declare function showTokenUsage(id: string, cwd?: string): Promise<TokenUsageRow | null>;
export declare function listTokenUsage(filters?: TokenUsageFilters, cwd?: string): Promise<{
    records: TokenUsageRow[];
    total: number;
    filtered: number;
}>;
export declare function summarizeTokenUsage(filters?: TokenUsageFilters, cwd?: string): Promise<TokenUsageSummary>;
export declare function deleteTokenUsage(id: string, cwd?: string): Promise<{
    deleted: boolean;
    id: string;
}>;
export declare function clearTokenUsage(filters?: TokenUsageFilters, cwd?: string): Promise<{
    deleted: number;
}>;
export declare function autoRecordDispatchTokenUsage(input: TokenExchangeInput): Promise<void>;
export declare function getLatestTokenRecord(cwd?: string): Promise<TokenUsageRow | null>;
export declare function getTokenUsageAggregateSql(cwd?: string): Promise<Array<{
    provider: string;
    transport: string;
    totalTokens: number;
    count: number;
}>>;
//# sourceMappingURL=token-service.d.ts.map