/**
 * Unified Input Validation Layer
 *
 * Provides Result-based validation functions for all user inputs:
 * - CLI arguments
 * - Slash command arguments
 * - Tool arguments
 * - API parameters
 *
 * Uses a functional Result<T, E> pattern for type-safe error handling
 * without exceptions.
 */
import { ValidationError } from './errors.js';
/**
 * Represents a successful result containing a value
 */
export interface Ok<T> {
    readonly ok: true;
    readonly value: T;
}
/**
 * Represents a failed result containing an error
 */
export interface Err<E> {
    readonly ok: false;
    readonly error: E;
}
/**
 * Result type - either Ok with value or Err with error
 * Provides a type-safe way to handle operations that can fail
 */
export type Result<T, E = ValidationError> = Ok<T> | Err<E>;
/**
 * Create a successful result
 */
export declare function ok<T>(value: T): Ok<T>;
/**
 * Create a failed result
 */
export declare function err<E>(error: E): Err<E>;
/**
 * Create a validation error result with a message
 */
export declare function validationErr(message: string, field?: string, value?: unknown): Err<ValidationError>;
/**
 * Check if result is Ok
 */
export declare function isOk<T, E>(result: Result<T, E>): result is Ok<T>;
/**
 * Check if result is Err
 */
export declare function isErr<T, E>(result: Result<T, E>): result is Err<E>;
/**
 * Unwrap a Result, throwing if it's an error
 */
export declare function unwrap<T, E extends Error>(result: Result<T, E>): T;
/**
 * Unwrap a Result with a default value if it's an error
 */
export declare function unwrapOr<T, E>(result: Result<T, E>, defaultValue: T): T;
/**
 * Map a successful result to a new value
 */
export declare function map<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E>;
/**
 * Chain result operations (flatMap/bind)
 */
export declare function andThen<T, U, E>(result: Result<T, E>, fn: (value: T) => Result<U, E>): Result<U, E>;
export interface FilePathOptions {
    /** Allow absolute paths (default: true) */
    allowAbsolute?: boolean;
    /** Allow relative paths (default: true) */
    allowRelative?: boolean;
    /** Base directory for relative path resolution */
    baseDirectory?: string;
    /** Allowed file extensions (e.g., ['.ts', '.js']) */
    allowedExtensions?: string[];
    /** Disallowed file extensions (e.g., ['.exe', '.sh']) */
    disallowedExtensions?: string[];
    /** Maximum path length */
    maxLength?: number;
    /** Field name for error messages */
    fieldName?: string;
}
/**
 * Validate a file path for security and correctness
 *
 * Checks for:
 * - Path traversal attacks (../)
 * - Null byte injection
 * - Invalid characters
 * - Extension restrictions
 *
 * @param filePath - The file path to validate
 * @param options - Validation options
 * @returns Result with sanitized path or validation error
 */
export declare function validateFilePath(filePath: unknown, options?: FilePathOptions): Result<string, ValidationError>;
export interface CommandOptions {
    /** Allow dangerous commands (default: false) */
    allowDangerous?: boolean;
    /** Allowed command prefixes (e.g., ['git', 'npm']) */
    allowedCommands?: string[];
    /** Disallowed command prefixes */
    disallowedCommands?: string[];
    /** Maximum command length */
    maxLength?: number;
    /** Field name for error messages */
    fieldName?: string;
}
/**
 * Validate a shell command for security
 *
 * Checks for:
 * - Dangerous patterns (rm -rf /, fork bombs, etc.)
 * - Command injection patterns
 * - Allowed/disallowed commands
 *
 * @param command - The command to validate
 * @param options - Validation options
 * @returns Result with command or validation error
 */
export declare function validateCommand(command: unknown, options?: CommandOptions): Result<string, ValidationError>;
export interface ApiKeyOptions {
    /** Provider type for format validation */
    provider?: 'grok' | 'openai' | 'anthropic' | 'generic';
    /** Minimum key length */
    minLength?: number;
    /** Maximum key length */
    maxLength?: number;
    /** Field name for error messages */
    fieldName?: string;
}
/**
 * Validate an API key
 *
 * Checks for:
 * - Proper format based on provider
 * - Length constraints
 * - Invalid characters
 *
 * @param apiKey - The API key to validate
 * @param options - Validation options
 * @returns Result with API key or validation error
 */
export declare function validateApiKey(apiKey: unknown, options?: ApiKeyOptions): Result<string, ValidationError>;
export interface JsonOptions<T = unknown> {
    /** Zod schema for validation (optional) */
    schema?: {
        safeParse: (data: unknown) => {
            success: boolean;
            data?: T;
            error?: {
                message: string;
            };
        };
    };
    /** Maximum JSON string length */
    maxLength?: number;
    /** Field name for error messages */
    fieldName?: string;
}
/**
 * Validate and parse a JSON string
 *
 * @param jsonString - The JSON string to parse
 * @param options - Validation options
 * @returns Result with parsed JSON or validation error
 */
export declare function validateJson<T = unknown>(jsonString: unknown, options?: JsonOptions<T>): Result<T, ValidationError>;
export interface UrlOptions {
    /** Allowed protocols (default: ['http:', 'https:']) */
    protocols?: string[];
    /** Require HTTPS only */
    httpsOnly?: boolean;
    /** Allowed hostnames */
    allowedHosts?: string[];
    /** Blocked hostnames */
    blockedHosts?: string[];
    /** Maximum URL length */
    maxLength?: number;
    /** Field name for error messages */
    fieldName?: string;
}
/**
 * Validate a URL
 *
 * Checks for:
 * - Valid URL format
 * - Allowed protocols
 * - Host restrictions
 * - Common attack patterns
 *
 * @param urlString - The URL to validate
 * @param options - Validation options
 * @returns Result with URL object or validation error
 */
export declare function validateUrl(urlString: unknown, options?: UrlOptions): Result<URL, ValidationError>;
/**
 * Validators object with all validation functions
 * Convenient for use as a single import
 */
export declare const validators: {
    /** Validate file path */
    filePath: typeof validateFilePath;
    /** Validate shell command */
    command: typeof validateCommand;
    /** Validate API key */
    apiKey: typeof validateApiKey;
    /** Validate JSON string */
    json: typeof validateJson;
    /** Validate URL */
    url: typeof validateUrl;
};
/**
 * Sanitize a file path by removing dangerous patterns
 * Returns the sanitized path or throws if path is too dangerous
 */
export declare function sanitizePath(filePath: string): string;
/**
 * Escape a string for safe use in shell commands
 * Wraps the string in single quotes and escapes internal quotes
 */
export declare function escapeForShell(input: string): string;
/**
 * Combine multiple validation results
 * Returns the first error or ok with all values
 */
export declare function combineResults<T extends readonly Result<unknown, ValidationError>[]>(...results: T): Result<{
    [K in keyof T]: T[K] extends Result<infer V, unknown> ? V : never;
}, ValidationError>;
/**
 * Type guard for checking if a value is a non-empty string
 */
export declare function isNonEmptyString(value: unknown): value is string;
/**
 * Type guard for checking if a value is a valid number
 */
export declare function isValidNumber(value: unknown): value is number;
/**
 * Type guard for checking if a value is a plain object
 */
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
