/**
 * Tool Result Sanitization System
 *
 * OpenClaw-inspired result sanitization for:
 * - Image payload downscaling/recompression
 * - Size limiting for tool results
 * - Provider-specific policies
 * - Orphaned tool_result cleanup
 * - Content block sanitization
 */
/**
 * Supported LLM providers
 */
export type LLMProvider = 'grok' | 'openai' | 'anthropic' | 'gemini' | 'mistral' | 'ollama' | 'lmstudio';
/**
 * Provider-specific sanitization policy
 */
export interface ProviderPolicy {
    /** Provider name */
    provider: LLMProvider;
    /** Max result size in bytes */
    maxResultSize: number;
    /** Max image dimension (width or height) */
    maxImageDimension: number;
    /** Max image size in bytes */
    maxImageSize: number;
    /** Supported image formats */
    supportedImageFormats: string[];
    /** Tool call ID requirements */
    toolCallIdRequirements?: {
        /** Alphanumeric only */
        alphanumeric?: boolean;
        /** Minimum length */
        minLength?: number;
        /** Maximum length */
        maxLength?: number;
        /** Prefix requirement */
        prefix?: string;
    };
    /** Strip thinking/reasoning from responses */
    stripThinking?: boolean;
    /** Custom sanitizers */
    customSanitizers?: Array<(content: string) => string>;
}
/**
 * Default provider policies
 */
export declare const PROVIDER_POLICIES: Record<LLMProvider, ProviderPolicy>;
/**
 * Tool result to sanitize
 */
export interface ToolResultInput {
    /** Tool call ID */
    toolCallId: string;
    /** Tool name */
    toolName: string;
    /** Success status */
    success: boolean;
    /** Output content */
    output?: string;
    /** Error message */
    error?: string;
    /** Image data (base64) */
    imageData?: string;
    /** Image format */
    imageFormat?: string;
    /** Raw data for special handling */
    rawData?: unknown;
}
/**
 * Sanitized tool result
 */
export interface SanitizedToolResult {
    /** Sanitized tool call ID */
    toolCallId: string;
    /** Tool name */
    toolName: string;
    /** Success status */
    success: boolean;
    /** Sanitized output content */
    output?: string;
    /** Sanitized error message */
    error?: string;
    /** Sanitized image data */
    imageData?: string;
    /** Image format */
    imageFormat?: string;
    /** Sanitization metadata */
    sanitization: {
        /** Was content truncated */
        truncated: boolean;
        /** Original size */
        originalSize: number;
        /** Final size */
        finalSize: number;
        /** Was image resized */
        imageResized: boolean;
        /** Was tool call ID modified */
        toolCallIdModified: boolean;
        /** Applied sanitizers */
        appliedSanitizers: string[];
    };
}
/**
 * Sanitization configuration
 */
export interface SanitizationConfig {
    /** Provider to use */
    provider: LLMProvider;
    /** Override max result size */
    maxResultSize?: number;
    /** Strip ANSI codes */
    stripAnsi?: boolean;
    /** Strip control characters */
    stripControlChars?: boolean;
    /** Truncation suffix */
    truncationSuffix?: string;
    /** Custom sanitizers to apply */
    customSanitizers?: Array<(content: string) => string>;
}
/**
 * Tool result sanitizer
 */
export declare class ResultSanitizer {
    private policy;
    private config;
    constructor(config: SanitizationConfig);
    /**
     * Sanitize a tool result
     */
    sanitize(result: ToolResultInput): SanitizedToolResult;
    /**
     * Sanitize tool call ID according to provider requirements
     */
    private sanitizeToolCallId;
    /**
     * Strip ANSI escape codes
     */
    private stripAnsi;
    /**
     * Strip control characters (except newlines and tabs)
     */
    private stripControlChars;
    /**
     * Truncate text with suffix
     */
    private truncate;
    /**
     * Sanitize image data
     */
    private sanitizeImage;
    /**
     * Detect image format from base64 data
     */
    private detectImageFormat;
    /**
     * Calculate approximate size of result
     */
    private calculateSize;
}
/**
 * Tool use from assistant message
 */
export interface ToolUse {
    id: string;
    name: string;
    arguments: Record<string, unknown>;
}
/**
 * Tool result from tool response
 */
export interface ToolResultPair {
    toolCallId: string;
    content: string;
}
/**
 * Validation result
 */
export interface PairingValidationResult {
    /** Is valid */
    valid: boolean;
    /** Orphaned tool results (no matching tool use) */
    orphanedResults: string[];
    /** Missing results (tool use without result) */
    missingResults: string[];
    /** Synthesized results for missing tool uses */
    synthesizedResults: ToolResultPair[];
    /** Cleaned results (orphans removed) */
    cleanedResults: ToolResultPair[];
}
/**
 * Validate and sanitize tool use/result pairing
 * Removes orphaned results and creates synthetic results for missing tool uses
 */
export declare function sanitizeToolUseResultPairing(toolUses: ToolUse[], toolResults: ToolResultPair[]): PairingValidationResult;
/**
 * Create a sanitizer for a specific provider
 */
export declare function createSanitizer(provider: LLMProvider, config?: Partial<SanitizationConfig>): ResultSanitizer;
/**
 * Quick sanitize for a provider
 */
export declare function sanitizeResult(provider: LLMProvider, result: ToolResultInput): SanitizedToolResult;
export default ResultSanitizer;
