import { ITicketProperty, TicketPropertyValue } from "./Common"; import { TicketMetricCode } from "./Dashboard"; import { TicketSecurityOperation } from "./Security"; /** Identifies the native AI experiences that Tickets can request from the central AI module. */ export declare enum TicketAICapability { SUMMARIZE = "SUMMARIZE", SUMMARIZE_SINCE_LAST_READ = "SUMMARIZE_SINCE_LAST_READ", SUGGEST_REPLY = "SUGGEST_REPLY", REWRITE = "REWRITE", TRANSLATE = "TRANSLATE", SUGGEST_NEXT_ACTION = "SUGGEST_NEXT_ACTION", SUGGEST_KNOWLEDGE = "SUGGEST_KNOWLEDGE", FIND_SIMILAR_TICKETS = "FIND_SIMILAR_TICKETS", DETECT_MISSING_INFORMATION = "DETECT_MISSING_INFORMATION", CLASSIFY = "CLASSIFY", EXTRACT_FIELDS = "EXTRACT_FIELDS", ANALYZE_SENTIMENT = "ANALYZE_SENTIMENT", PREDICT_RISK = "PREDICT_RISK" } /** Classifies machine-generated observations persisted against a ticket. */ export declare enum TicketAIInsightType { INTENT = "INTENT", TOPIC = "TOPIC", SENTIMENT = "SENTIMENT", URGENCY = "URGENCY", COMPLEXITY = "COMPLEXITY", ESCALATION_RISK = "ESCALATION_RISK", SLA_BREACH_RISK = "SLA_BREACH_RISK", LANGUAGE = "LANGUAGE", SPAM = "SPAM", SUGGESTED_CATEGORY = "SUGGESTED_CATEGORY", SUGGESTED_PRIORITY = "SUGGESTED_PRIORITY", SUGGESTED_SKILLS = "SUGGESTED_SKILLS", SUGGESTED_ASSIGNEE = "SUGGESTED_ASSIGNEE", RESOLUTION_PROBABILITY = "RESOLUTION_PROBABILITY", MISSING_INFORMATION = "MISSING_INFORMATION" } /** Describes whether an AI output is only proposed, accepted, rejected or superseded. */ export declare enum TicketAIOutputStatus { GENERATED = "GENERATED", ACCEPTED = "ACCEPTED", EDITED = "EDITED", REJECTED = "REJECTED", APPLIED = "APPLIED", SUPERSEDED = "SUPERSEDED", EXPIRED = "EXPIRED", FAILED = "FAILED" } /** Records explicit and implicit feedback used to evaluate model usefulness. */ export declare enum TicketAIFeedbackType { ACCEPTED = "ACCEPTED", EDITED = "EDITED", REJECTED = "REJECTED", HELPFUL = "HELPFUL", NOT_HELPFUL = "NOT_HELPFUL", INCORRECT = "INCORRECT", UNSAFE = "UNSAFE" } /** Severity used by supervisor insights to prioritize anomalies and recommendations. */ export declare enum TicketAIInsightSeverity { INFO = "INFO", LOW = "LOW", MEDIUM = "MEDIUM", HIGH = "HIGH", CRITICAL = "CRITICAL" } /** Types of cross-ticket analysis surfaced in dashboards and supervisor workspaces. */ export declare enum TicketAIAnalyticsInsightType { ANOMALY = "ANOMALY", TREND = "TREND", FORECAST = "FORECAST", EMERGING_TOPIC = "EMERGING_TOPIC", ROOT_CAUSE = "ROOT_CAUSE", SLA_RISK = "SLA_RISK", STAFFING_RISK = "STAFFING_RISK", QUALITY_RISK = "QUALITY_RISK", RECOMMENDATION = "RECOMMENDATION", EXECUTIVE_SUMMARY = "EXECUTIVE_SUMMARY" } /** Declares why an autonomous or assisted AI session handed work to a human. */ export declare enum TicketAIHandoffReason { CUSTOMER_REQUESTED = "CUSTOMER_REQUESTED", LOW_CONFIDENCE = "LOW_CONFIDENCE", POLICY_REQUIRED = "POLICY_REQUIRED", UNSUPPORTED_INTENT = "UNSUPPORTED_INTENT", NEGATIVE_SENTIMENT = "NEGATIVE_SENTIMENT", SECURITY_RISK = "SECURITY_RISK", TOOL_FAILURE = "TOOL_FAILURE", SLA_RISK = "SLA_RISK", OTHER = "OTHER" } /** Controls how much ticket context may be sent to AI after authorization and PII filtering. */ export declare enum TicketAIContextScope { TICKET_FIELDS = "TICKET_FIELDS", PUBLIC_MESSAGES = "PUBLIC_MESSAGES", INTERNAL_NOTES = "INTERNAL_NOTES", ATTACHMENT_TEXT = "ATTACHMENT_TEXT", CONTACT_PROFILE = "CONTACT_PROFILE", ORGANIZATION_PROFILE = "ORGANIZATION_PROFILE", KNOWLEDGE = "KNOWLEDGE", RELATED_TICKETS = "RELATED_TICKETS", SLA = "SLA", TASKS = "TASKS", APPROVALS = "APPROVALS" } /** Configuration exposed by Tickets so UI and Flow know which AI experiences are available and permitted. */ export interface ITicketAICapabilityDefinition { code: TicketAICapability; name: string; description: string; enabled: boolean; allowedRoleIds?: string[]; requiredOperations?: TicketSecurityOperation[]; contextScopes: TicketAIContextScope[]; providerId?: string; modelId?: string; promptTemplateId?: string; minimumConfidence?: number; requireHumanApproval: boolean; } /** Per-tenant policy enforced before any ticket context is sent to a model. */ export interface ITicketAIPolicy { id: string; spaceId: string; name: string; enabled: boolean; allowedCapabilities: TicketAICapability[]; allowedContextScopes: TicketAIContextScope[]; excludedFieldNameKeys?: string[]; allowPii: boolean; allowSensitivePii: boolean; redactBeforeInference: boolean; retainInputs: boolean; retainOutputs: boolean; retentionDays?: number; maximumTokensPerRequest?: number; maximumCostPerRequest?: number; requireSourceCitations?: boolean; createdAt: Date; createdBy: string; updatedAt?: Date; updatedBy?: string; } /** Request issued by an agent-facing UI for summaries, replies, rewrites or recommendations. */ export interface ICreateTicketAIAssistanceDto { ticketId: string; capability: TicketAICapability; instruction?: string; locale?: string; tone?: string; conversationId?: string; sinceMessageId?: string; selectedMessageIds?: string[]; selectedFieldNameKeys?: string[]; contextScopes?: TicketAIContextScope[]; idempotencyKey: string; } /** Immutable reference to a source used by an AI response; content remains authoritative in its owning module. */ export interface ITicketAISourceReference { sourceType: "TICKET" | "MESSAGE" | "DOCUMENT" | "ATTACHMENT" | "CONTACT" | "ORGANIZATION" | "SLA" | "TASK" | "APPROVAL"; sourceId: string; title?: string; excerpt?: string; relevanceScore?: number; } /** Result returned to the agent UI; generated text is a suggestion until explicitly accepted or applied. */ export interface ITicketAIAssistanceResult { id: string; spaceId: string; ticketId: string; capability: TicketAICapability; status: TicketAIOutputStatus; text?: string; structuredOutput?: { [key: string]: TicketPropertyValue; }; suggestedProperties?: ITicketProperty[]; suggestedKnowledgeDocumentIds?: string[]; similarTicketIds?: string[]; confidence?: number; sources?: ITicketAISourceReference[]; traceId: string; generatedAt: Date; expiresAt?: Date; } /** Persisted prediction or classification used by routing, prioritization and agent context. */ export interface ITicketAIInsight { id: string; spaceId: string; ticketId: string; type: TicketAIInsightType; value: TicketPropertyValue; confidence: number; status: TicketAIOutputStatus; modelId: string; modelVersion?: string; promptTemplateId?: string; sourceEventId?: string; generatedAt: Date; expiresAt?: Date; acceptedAt?: Date; acceptedBy?: string; rejectedAt?: Date; rejectedBy?: string; rejectionReason?: string; } /** Lightweight projection embedded in ITicket lists; full insights are queried separately. */ export interface ITicketAISummary { sentiment?: string; intent?: string; language?: string; escalationRisk?: number; slaBreachRisk?: number; suggestedPriority?: string; activeInsightIds?: string[]; updatedAt: Date; } /** Request for refreshing selected insights after a ticket or conversation changes. */ export interface IGenerateTicketAIInsightsDto { ticketId: string; insightTypes: TicketAIInsightType[]; sourceEventId?: string; contextScopes?: TicketAIContextScope[]; idempotencyKey: string; } /** Applies an accepted AI recommendation through normal ticket APIs, preserving validation and audit. */ export interface IApplyTicketAIRecommendationDto { expectedVersion: number; assistanceResultId?: string; insightId?: string; fieldValues?: ITicketProperty[]; actionCode?: string; actionParameters?: { [key: string]: TicketPropertyValue; }; idempotencyKey: string; } /** Records whether an agent used, edited or rejected an output; required for quality and adoption metrics. */ export interface ICreateTicketAIFeedbackDto { outputId: string; feedbackType: TicketAIFeedbackType; editedText?: string; correctedValue?: TicketPropertyValue; comment?: string; } /** Stored feedback event consumed by analytics and model evaluation pipelines. */ export interface ITicketAIFeedback { id: string; spaceId: string; ticketId: string; outputId: string; userId: string; type: TicketAIFeedbackType; editDistancePercentage?: number; correctedValue?: TicketPropertyValue; comment?: string; createdAt: Date; } /** Evidence supporting a supervisor insight; enables drill-down instead of presenting an opaque conclusion. */ export interface ITicketAIAnalyticsEvidence { metricCode?: TicketMetricCode; ticketIds?: string[]; groupIds?: string[]; categoryIds?: string[]; currentValue?: number; baselineValue?: number; changePercentage?: number; description?: string; } /** Cross-ticket insight shown in dashboards to explain trends, anomalies and operational risks. */ export interface ITicketAIAnalyticsInsight { id: string; spaceId: string; dashboardId?: string; type: TicketAIAnalyticsInsightType; title: string; summary: string; severity: TicketAIInsightSeverity; confidence: number; metricCodes?: TicketMetricCode[]; evidence: ITicketAIAnalyticsEvidence[]; recommendedActions?: ITicketAIRecommendedAction[]; modelId: string; modelVersion?: string; generatedAt: Date; expiresAt?: Date; dismissedAt?: Date; dismissedBy?: string; } /** Suggested supervisor response; execution must go through Flow or a normal Tickets API after approval. */ export interface ITicketAIRecommendedAction { code: string; label: string; description?: string; parameters?: { [key: string]: TicketPropertyValue; }; requiresApproval: boolean; } /** Query used by supervisor dashboards to request anomaly, forecast or explanation generation. */ export interface IGenerateTicketAIAnalyticsDto { dashboardId?: string; insightTypes: TicketAIAnalyticsInsightType[]; metricCodes?: TicketMetricCode[]; from: Date; to: Date; comparisonFrom?: Date; comparisonTo?: Date; groupIds?: string[]; categoryIds?: string[]; idempotencyKey: string; } /** Context transferred from a virtual agent or AI-driven Flow when a human ticket is created or resumed. */ export interface ITicketAIVirtualAgentHandoff { id: string; spaceId: string; sessionId: string; ticketId?: string; flowId?: string; conversationId?: string; summary: string; detectedIntent?: string; detectedLanguage?: string; confidence?: number; collectedProperties: ITicketProperty[]; attemptedKnowledgeDocumentIds?: string[]; toolResults?: { toolCode: string; success: boolean; summary?: string; }[]; reason: TicketAIHandoffReason; customerRequestedHuman?: boolean; handedOffAt: Date; } /** DTO used by Flow or a virtual agent to attach its structured handoff to an existing or newly created ticket. */ export interface IAttachTicketAIHandoffDto { ticketId: string; handoffId: string; expectedVersion: number; } /** Trace metadata retained for governance without requiring storage of raw prompts containing PII. */ export interface ITicketAITrace { id: string; spaceId: string; ticketId?: string; capability: TicketAICapability; providerId: string; modelId: string; modelVersion?: string; promptTemplateId?: string; promptTemplateVersion?: number; promptHash?: string; inputRetained: boolean; outputRetained: boolean; sourceReferences?: ITicketAISourceReference[]; requestedBy?: string; flowId?: string; flowExecutionId?: string; startedAt: Date; completedAt?: Date; latencyMs?: number; inputTokens?: number; outputTokens?: number; totalCost?: number; success: boolean; errorCode?: string; errorMessage?: string; } /** Aggregated measurements used to compare AI quality, adoption, savings and cost over time. */ export interface ITicketAIMetrics { from: Date; to: Date; capability?: TicketAICapability; requests: number; successes: number; failures: number; accepted: number; edited: number; rejected: number; acceptanceRate: number; averageConfidence?: number; averageLatencyMs?: number; inputTokens: number; outputTokens: number; totalCost: number; estimatedMinutesSaved?: number; automatedResolutions?: number; humanHandoffs?: number; } /** Query used by administrators and supervisors to retrieve AI operational and adoption metrics. */ export interface ITicketAIMetricsQuery { from: Date; to: Date; capabilities?: TicketAICapability[]; modelIds?: string[]; userIds?: string[]; groupIds?: string[]; categoryIds?: string[]; }