/** * AI Feedback System Types * * Type definitions and Zod validation schemas for the secure feedback system * that allows AI users to report issues with browsing quality, accuracy, and performance. * * Security Design: * - Rate limiting at session and tenant levels * - Anomaly detection for feedback poisoning * - Max 5% confidence adjustment per feedback * - Require 3 consistent signals before applying adjustments * - HMAC-SHA256 webhook signature verification */ import { z } from 'zod'; /** * High-level feedback categories */ export type FeedbackCategory = 'content_quality' | 'accuracy' | 'performance' | 'functionality' | 'security' | 'feature_request'; export declare const FeedbackCategorySchema: z.ZodEnum<{ security: "security"; performance: "performance"; content_quality: "content_quality"; accuracy: "accuracy"; functionality: "functionality"; feature_request: "feature_request"; }>; /** * Detailed subtypes for each category */ export type FeedbackSubtype = 'missing_content' | 'garbled_content' | 'incomplete_content' | 'wrong_format' | 'incorrect_data' | 'outdated_content' | 'misattribution' | 'hallucination' | 'slow_response' | 'timeout' | 'resource_exhaustion' | 'rate_limited' | 'pattern_failure' | 'api_discovery_miss' | 'selector_broken' | 'auth_failure' | 'credential_exposure' | 'xss_detected' | 'injection_risk' | 'new_capability' | 'improvement' | 'other'; export declare const FeedbackSubtypeSchema: z.ZodEnum<{ rate_limited: "rate_limited"; timeout: "timeout"; wrong_format: "wrong_format"; other: "other"; missing_content: "missing_content"; garbled_content: "garbled_content"; incomplete_content: "incomplete_content"; incorrect_data: "incorrect_data"; outdated_content: "outdated_content"; misattribution: "misattribution"; hallucination: "hallucination"; slow_response: "slow_response"; resource_exhaustion: "resource_exhaustion"; pattern_failure: "pattern_failure"; api_discovery_miss: "api_discovery_miss"; selector_broken: "selector_broken"; auth_failure: "auth_failure"; credential_exposure: "credential_exposure"; xss_detected: "xss_detected"; injection_risk: "injection_risk"; new_capability: "new_capability"; improvement: "improvement"; }>; /** * Severity levels for feedback */ export type FeedbackSeverity = 'low' | 'medium' | 'high' | 'critical'; export declare const FeedbackSeveritySchema: z.ZodEnum<{ high: "high"; medium: "medium"; low: "low"; critical: "critical"; }>; /** * Overall sentiment of the feedback */ export type FeedbackSentiment = 'positive' | 'negative' | 'neutral'; export declare const FeedbackSentimentSchema: z.ZodEnum<{ positive: "positive"; negative: "negative"; neutral: "neutral"; }>; /** * Zod schema for validating feedback submissions */ export declare const FeedbackSubmissionSchema: z.ZodObject<{ category: z.ZodEnum<{ security: "security"; performance: "performance"; content_quality: "content_quality"; accuracy: "accuracy"; functionality: "functionality"; feature_request: "feature_request"; }>; sentiment: z.ZodEnum<{ positive: "positive"; negative: "negative"; neutral: "neutral"; }>; subtype: z.ZodOptional>; severity: z.ZodOptional>; context: z.ZodObject<{ url: z.ZodString; domain: z.ZodString; operation: z.ZodOptional; skillId: z.ZodOptional; patternId: z.ZodOptional; requestId: z.ZodOptional; }, z.core.$strip>; message: z.ZodOptional; expectedBehavior: z.ZodOptional; actualBehavior: z.ZodOptional; evidence: z.ZodOptional; errorMessage: z.ZodOptional; responseTime: z.ZodOptional; statusCode: z.ZodOptional; }, z.core.$strip>>; suggestedAction: z.ZodOptional>; }, z.core.$strip>; export type FeedbackSubmission = z.infer; /** * A stored feedback record with metadata */ export interface FeedbackRecord { id: string; tenantId: string; sessionId: string; submission: FeedbackSubmission; status: 'pending' | 'processing' | 'applied' | 'rejected' | 'escalated'; processedAt?: number; adjustments: FeedbackAdjustment[]; anomalyFlags: AnomalyFlag[]; createdAt: number; updatedAt: number; } /** * An adjustment made in response to feedback */ export interface FeedbackAdjustment { type: 'pattern_confidence' | 'tier_routing' | 'selector_priority' | 'api_preference'; target: { id: string; domain: string; }; previousValue: number; newValue: number; changePercent: number; revertible: boolean; revertedAt?: number; } /** * Anomaly flags for suspicious feedback patterns */ export interface AnomalyFlag { type: 'category_flooding' | 'targeted_attack' | 'conflicting_feedback' | 'rate_exceeded'; severity: 'warning' | 'critical'; description: string; detectedAt: number; } /** * Audit log entry for feedback operations */ export interface FeedbackAuditEntry { id: string; action: 'submitted' | 'validated' | 'rejected' | 'adjustment_applied' | 'adjustment_reverted' | 'anomaly_detected' | 'escalated' | 'notified'; actor: { type: 'system' | 'ai_user' | 'human_admin'; id: string; }; feedbackId?: string; tenantId: string; details: Record; timestamp: number; } /** * Types of notifications that can be sent */ export type NotificationType = 'security_alert' | 'critical_feedback' | 'pattern_failure' | 'anomaly_detected' | 'feature_request' | 'escalation_required'; export declare const NotificationTypeSchema: z.ZodEnum<{ feature_request: "feature_request"; pattern_failure: "pattern_failure"; anomaly_detected: "anomaly_detected"; security_alert: "security_alert"; critical_feedback: "critical_feedback"; escalation_required: "escalation_required"; }>; /** * A notification to be sent via webhook */ export interface FeedbackNotification { id: string; type: NotificationType; tenantId: string; title: string; summary: string; feedback: FeedbackRecord; priority: 'low' | 'normal' | 'high' | 'urgent'; status: 'pending' | 'sent' | 'failed' | 'acknowledged'; sentAt?: number; acknowledgedAt?: number; idempotencyKey: string; createdAt: number; } /** * Webhook configuration for a tenant */ export interface WebhookConfig { url: string; secret: string; enabledTypes: NotificationType[]; enabled: boolean; maxRetries: number; retryDelayMs: number; lastDeliveryAt?: number; lastDeliveryStatus?: 'success' | 'failure'; consecutiveFailures: number; createdAt: number; updatedAt: number; } /** * Zod schema for webhook configuration input */ export declare const WebhookConfigInputSchema: z.ZodObject<{ url: z.ZodString; secret: z.ZodString; enabledTypes: z.ZodArray>; enabled: z.ZodDefault; maxRetries: z.ZodDefault; retryDelayMs: z.ZodDefault; }, z.core.$strip>; export type WebhookConfigInput = z.infer; /** * Rate limit configuration */ export interface FeedbackRateLimits { sessionMaxPerMinute: number; tenantMaxPerHour: number; targetNegativeMaxPerHour: number; } /** * Default rate limits */ export declare const DEFAULT_FEEDBACK_RATE_LIMITS: FeedbackRateLimits; /** * Result of submitting feedback */ export interface FeedbackSubmitResult { success: boolean; feedbackId?: string; status: 'accepted' | 'rate_limited' | 'validation_failed' | 'anomaly_detected'; message: string; adjustmentsApplied?: number; notificationSent?: boolean; anomalyFlags?: AnomalyFlag[]; validationErrors?: string[]; } /** * Feedback statistics for a tenant */ export interface FeedbackStats { tenantId: string; period: { start: number; end: number; }; byCategory: Record; bySentiment: Record; byStatus: Record; anomaliesDetected: number; escalationsRequired: number; adjustmentsApplied: number; adjustmentsReverted: number; total: number; } /** * Tracks consistent feedback signals for the same target * (require 3 agreeing signals before applying adjustments) */ export interface ConsistencyTracker { targetType: 'pattern' | 'skill' | 'domain' | 'api'; targetId: string; domain: string; signals: Array<{ feedbackId: string; sentiment: FeedbackSentiment; suggestedAction?: FeedbackSubmission['suggestedAction']; timestamp: number; }>; consensus?: { sentiment: FeedbackSentiment; suggestedAction?: FeedbackSubmission['suggestedAction']; signalCount: number; reachedAt: number; }; } //# sourceMappingURL=feedback.d.ts.map