/** * Comprehensive Policy and Configuration Types * All routing, execution, and orchestration configurations */ import { ModelProvider } from './vendors'; export interface Project { id: string; name: string; description?: string; owner_id: string; organization_id?: string; created_at: Date; updated_at: Date; status: ProjectStatus; config: ProjectConfig; quotas: ProjectQuotas; metadata: Record; } export declare enum ProjectStatus { ACTIVE = "active", PAUSED = "paused", ARCHIVED = "archived" } export interface ProjectConfig { default_timeout_ms: number; enable_caching: boolean; enable_telemetry: boolean; data_residency_regions?: string[]; allowed_providers?: ModelProvider[]; blocked_providers?: ModelProvider[]; } export interface ProjectQuotas { max_requests_per_day?: number; max_requests_per_month?: number; max_cost_per_day?: number; max_cost_per_month?: number; max_tokens_per_request?: number; max_concurrent_requests?: number; } export interface ModelConnector { id: string; project_id: string; name: string; provider: ModelProvider; model_name: string; model_version?: string; status: ConnectorStatus; config: ConnectorConfig; credentials: CredentialReference; metadata: ModelMetadata; created_at: Date; updated_at: Date; last_used_at?: Date; } export declare enum ConnectorStatus { HEALTHY = "healthy", DEGRADED = "degraded", DOWN = "down", DISABLED = "disabled", MAINTENANCE = "maintenance" } export interface ConnectorConfig { endpoint_url?: string; region?: string; timeout_ms?: number; max_retries?: number; retry_delay_ms?: number; rate_limit?: RateLimitConfig; proxy?: ProxyConfig; tls_config?: TLSConfig; custom_headers?: Record; } export interface CredentialReference { vault_id: string; credential_type: CredentialType; } export declare enum CredentialType { API_KEY = "api_key", OAUTH2 = "oauth2", AWS_IAM = "aws_iam", SERVICE_ACCOUNT = "service_account", BASIC_AUTH = "basic_auth", CUSTOM = "custom" } export interface ModelMetadata { capabilities: ModelCapability[]; pricing: PricingInfo; sla: SLAInfo; limits: ModelLimits; tags: string[]; } export declare enum ModelCapability { CHAT = "chat", COMPLETION = "completion", EMBEDDING = "embedding", FUNCTION_CALLING = "function_calling", VISION = "vision", AUDIO = "audio", STREAMING = "streaming", JSON_MODE = "json_mode", FINE_TUNING = "fine_tuning" } export interface PricingInfo { input_cost_per_1k_tokens: number; output_cost_per_1k_tokens: number; currency: string; batch_discount?: number; effective_date: Date; } export interface SLAInfo { availability_percentage: number; avg_latency_p50_ms: number; avg_latency_p95_ms: number; avg_latency_p99_ms: number; max_tokens_per_request: number; max_requests_per_minute: number; } export interface ModelLimits { max_context_length: number; max_output_tokens: number; max_batch_size?: number; supported_languages?: string[]; } export interface RoutingPolicy { id: string; project_id: string; name: string; description?: string; strategy: RoutingStrategy; config: RoutingStrategyConfig; filters?: PolicyFilter[]; fallback_policy?: FallbackPolicy; experiment?: ExperimentConfig; created_at: Date; updated_at: Date; version: number; } export declare enum RoutingStrategy { WEIGHTED = "weighted", CONDITIONAL = "conditional", CONFIDENCE_CASCADE = "confidence_cascade", COST_OPTIMIZED = "cost_optimized", LATENCY_OPTIMIZED = "latency_optimized", ENSEMBLE = "ensemble", ROUND_ROBIN = "round_robin", GEO_BASED = "geo_based", CAPABILITY_BASED = "capability_based", TIME_WINDOWED = "time_windowed" } export type RoutingStrategyConfig = WeightedRoutingConfig | ConditionalRoutingConfig | ConfidenceCascadeConfig | CostOptimizedConfig | LatencyOptimizedConfig | EnsembleConfig | RoundRobinConfig | GeoBasedConfig | CapabilityBasedConfig | TimeWindowedConfig; export interface WeightedRoutingConfig { strategy: RoutingStrategy.WEIGHTED; models: WeightedModel[]; sticky_session: boolean; session_ttl_seconds?: number; } export interface WeightedModel { connector_id: string; weight: number; conditions?: RoutingCondition[]; } export interface ConditionalRoutingConfig { strategy: RoutingStrategy.CONDITIONAL; rules: ConditionalRule[]; default_connector_id: string; } export interface ConditionalRule { priority: number; conditions: RoutingCondition[]; connector_id: string; name?: string; } export interface RoutingCondition { attribute: ConditionAttribute; operator: ConditionOperator; value: string | number | boolean | string[]; } export declare enum ConditionAttribute { PROMPT_LENGTH = "prompt_length", LANGUAGE = "language", TOPIC = "topic", USER_TIER = "user_tier", REQUEST_PRIORITY = "request_priority", TIME_OF_DAY = "time_of_day", DAY_OF_WEEK = "day_of_week", USER_LOCATION = "user_location", CUSTOM = "custom" } export declare enum ConditionOperator { EQUALS = "eq", NOT_EQUALS = "ne", GREATER_THAN = "gt", LESS_THAN = "lt", GREATER_OR_EQUAL = "gte", LESS_OR_EQUAL = "lte", IN = "in", NOT_IN = "not_in", CONTAINS = "contains", MATCHES = "matches" } export interface ConfidenceCascadeConfig { strategy: RoutingStrategy.CONFIDENCE_CASCADE; tiers: CascadeTier[]; min_confidence_threshold: number; max_cost_budget?: number; } export interface CascadeTier { connector_ids: string[]; confidence_threshold: number; max_latency_ms?: number; } export interface CostOptimizedConfig { strategy: RoutingStrategy.COST_OPTIMIZED; connector_ids: string[]; max_cost_per_request: number; quality_threshold?: number; fallback_to_quality?: boolean; } export interface LatencyOptimizedConfig { strategy: RoutingStrategy.LATENCY_OPTIMIZED; connector_ids: string[]; max_latency_ms: number; quality_threshold?: number; } export interface EnsembleConfig { strategy: RoutingStrategy.ENSEMBLE; connector_ids: string[]; execution_mode: ExecutionMode; aggregation_strategy: AggregationStrategy; aggregation_config?: AggregationStrategyConfig; min_successful_responses: number; timeout_ms?: number; } export declare enum ExecutionMode { PARALLEL = "parallel", SEQUENTIAL = "sequential", CASCADE = "cascade" } export declare enum AggregationStrategy { FIRST = "first", VOTING = "voting", CONFIDENCE_WEIGHTED = "confidence_weighted", RANKER = "ranker", SYNTHESIZER = "synthesizer", EARLIEST = "earliest", DIVERSITY = "diversity", CONSENSUS = "consensus" } export type AggregationStrategyConfig = VotingConfig | ConfidenceWeightedConfig | RankerConfig | SynthesizerConfig | DiversityConfig | ConsensusConfig; export interface VotingConfig { strategy: AggregationStrategy.VOTING; voting_method: 'majority' | 'plurality' | 'unanimous' | 'weighted'; normalization: 'exact' | 'semantic' | 'fuzzy'; tie_breaker: 'first' | 'highest_confidence' | 'lowest_cost' | 'random'; semantic_similarity_threshold?: number; } export interface ConfidenceWeightedConfig { strategy: AggregationStrategy.CONFIDENCE_WEIGHTED; confidence_source: 'model_logprobs' | 'custom_scorer' | 'ensemble_agreement'; min_confidence: number; weight_function: 'linear' | 'exponential' | 'sigmoid'; } export interface RankerConfig { strategy: AggregationStrategy.RANKER; ranker_model_id?: string; ranking_features: RankingFeature[]; top_k: number; } export declare enum RankingFeature { CONFIDENCE = "confidence", LATENCY = "latency", COST = "cost", MODEL_QUALITY = "model_quality", RELEVANCE = "relevance", DIVERSITY = "diversity" } export interface SynthesizerConfig { strategy: AggregationStrategy.SYNTHESIZER; synthesizer_model_id: string; synthesis_prompt_template: string; include_sources: boolean; max_input_responses: number; } export interface DiversityConfig { strategy: AggregationStrategy.DIVERSITY; diversity_metric: 'cosine' | 'jaccard' | 'levenshtein'; min_diversity_score: number; selection_count: number; } export interface ConsensusConfig { strategy: AggregationStrategy.CONSENSUS; consensus_threshold: number; fallback_on_no_consensus: boolean; } export interface RoundRobinConfig { strategy: RoutingStrategy.ROUND_ROBIN; connector_ids: string[]; reset_on_failure: boolean; } export interface GeoBasedConfig { strategy: RoutingStrategy.GEO_BASED; region_mappings: Array<{ regions: string[]; connector_id: string; }>; default_connector_id: string; } export interface CapabilityBasedConfig { strategy: RoutingStrategy.CAPABILITY_BASED; required_capabilities: ModelCapability[]; preference_order?: 'cost' | 'quality' | 'latency'; } export interface TimeWindowedConfig { strategy: RoutingStrategy.TIME_WINDOWED; windows: Array<{ start_time: string; end_time: string; days_of_week?: number[]; connector_id: string; }>; default_connector_id: string; timezone: string; } export interface PolicyFilter { type: FilterType; config: FilterConfig; enabled: boolean; order: number; } export declare enum FilterType { SAFETY = "safety", CONTENT_MODERATION = "content_moderation", PII_DETECTION = "pii_detection", RATE_LIMIT = "rate_limit", AUTHENTICATION = "authentication", CUSTOM = "custom" } export type FilterConfig = SafetyFilterConfig | ContentModerationConfig | PIIDetectionConfig | RateLimitFilterConfig | AuthenticationFilterConfig | CustomFilterConfig; export interface SafetyFilterConfig { type: FilterType.SAFETY; provider: 'openai-moderation' | 'perspective-api' | 'custom'; threshold: number; categories?: string[]; block_on_violation: boolean; } export interface ContentModerationConfig { type: FilterType.CONTENT_MODERATION; toxicity_threshold: number; check_prompt: boolean; check_response: boolean; } export interface PIIDetectionConfig { type: FilterType.PII_DETECTION; patterns: PIIPattern[]; redaction_mode: 'mask' | 'remove' | 'hash'; apply_to: 'prompt' | 'response' | 'both'; } export declare enum PIIPattern { EMAIL = "email", PHONE = "phone", SSN = "ssn", CREDIT_CARD = "credit_card", IP_ADDRESS = "ip_address", CUSTOM = "custom" } export interface RateLimitFilterConfig { type: FilterType.RATE_LIMIT; scope: 'user' | 'project' | 'ip_address'; window_seconds: number; max_requests: number; } export interface AuthenticationFilterConfig { type: FilterType.AUTHENTICATION; required: boolean; methods: string[]; } export interface CustomFilterConfig { type: FilterType.CUSTOM; name: string; endpoint?: string; config: Record; } export interface FallbackPolicy { enabled: boolean; fallback_chain: FallbackStep[]; max_attempts: number; retry_delay_ms: number; retry_multiplier: number; max_retry_delay_ms: number; } export interface FallbackStep { connector_id: string; conditions: FallbackCondition[]; timeout_ms?: number; } export interface FallbackCondition { trigger: FallbackTrigger; threshold?: number; } export declare enum FallbackTrigger { PRIMARY_FAILURE = "primary_failure", TIMEOUT = "timeout", COST_EXCEEDED = "cost_exceeded", LATENCY_EXCEEDED = "latency_exceeded", LOW_CONFIDENCE = "low_confidence", RATE_LIMIT = "rate_limit", CUSTOM = "custom" } export interface ExperimentConfig { id: string; name: string; type: ExperimentType; status: ExperimentStatus; variants: ExperimentVariant[]; traffic_allocation: TrafficAllocation; metrics: ExperimentMetric[]; start_date: Date; end_date?: Date; created_at: Date; } export declare enum ExperimentType { AB_TEST = "ab_test", MULTIVARIATE = "multivariate", CANARY = "canary", SHADOW = "shadow" } export declare enum ExperimentStatus { DRAFT = "draft", RUNNING = "running", PAUSED = "paused", COMPLETED = "completed", CANCELLED = "cancelled" } export interface ExperimentVariant { id: string; name: string; connector_id: string; is_control: boolean; description?: string; } export interface TrafficAllocation { method: 'percentage' | 'user_cohort' | 'gradual_rollout'; config: TrafficAllocationConfig; } export type TrafficAllocationConfig = PercentageAllocation | UserCohortAllocation | GradualRolloutAllocation; export interface PercentageAllocation { method: 'percentage'; percentages: Record; sticky_sessions: boolean; session_duration_seconds?: number; } export interface UserCohortAllocation { method: 'user_cohort'; cohorts: Array<{ cohort_id: string; variant_id: string; user_ids?: string[]; user_attributes?: Record; }>; } export interface GradualRolloutAllocation { method: 'gradual_rollout'; variant_id: string; rollout_schedule: Array<{ timestamp: Date; percentage: number; }>; rollback_on_degradation: boolean; degradation_threshold?: number; } export interface ExperimentMetric { name: string; type: MetricType; aggregation: MetricAggregation; goal: MetricGoal; baseline?: number; } export declare enum MetricType { LATENCY = "latency", COST = "cost", ERROR_RATE = "error_rate", SUCCESS_RATE = "success_rate", QUALITY_SCORE = "quality_score", USER_SATISFACTION = "user_satisfaction", CUSTOM = "custom" } export declare enum MetricAggregation { MEAN = "mean", MEDIAN = "median", P95 = "p95", P99 = "p99", SUM = "sum", COUNT = "count" } export declare enum MetricGoal { MINIMIZE = "minimize", MAXIMIZE = "maximize", TARGET = "target" } export interface RateLimitConfig { algorithm: RateLimitAlgorithm; config: RateLimitAlgorithmConfig; } export declare enum RateLimitAlgorithm { TOKEN_BUCKET = "token_bucket", LEAKY_BUCKET = "leaky_bucket", SLIDING_WINDOW = "sliding_window", FIXED_WINDOW = "fixed_window" } export type RateLimitAlgorithmConfig = TokenBucketConfig | LeakyBucketConfig | SlidingWindowConfig | FixedWindowConfig; export interface TokenBucketConfig { algorithm: RateLimitAlgorithm.TOKEN_BUCKET; capacity: number; refill_rate: number; refill_interval_ms: number; } export interface LeakyBucketConfig { algorithm: RateLimitAlgorithm.LEAKY_BUCKET; capacity: number; leak_rate: number; } export interface SlidingWindowConfig { algorithm: RateLimitAlgorithm.SLIDING_WINDOW; window_size_ms: number; max_requests: number; } export interface FixedWindowConfig { algorithm: RateLimitAlgorithm.FIXED_WINDOW; window_size_ms: number; max_requests: number; } export interface ProxyConfig { enabled: boolean; type: ProxyType; config: ProxyTypeConfig; } export declare enum ProxyType { HTTP = "http", HTTPS = "https", SOCKS5 = "socks5" } export type ProxyTypeConfig = HTTPProxyConfig | SOCKS5ProxyConfig; export interface HTTPProxyConfig { host: string; port: number; auth?: { username: string; password: string; }; headers?: Record; } export interface SOCKS5ProxyConfig { host: string; port: number; auth?: { username: string; password: string; }; } export interface TLSConfig { verify_certificate: boolean; certificate_pinning?: string[]; min_version?: string; max_version?: string; ciphers?: string[]; } export interface CircuitBreakerConfig { enabled: boolean; failure_threshold: number; success_threshold: number; timeout_ms: number; half_open_max_requests: number; } export declare enum CircuitBreakerState { CLOSED = "closed", OPEN = "open", HALF_OPEN = "half_open" } //# sourceMappingURL=policies.d.ts.map