feat(ai-session): add FlowPilot AI-powered troubleshooting sessions

Implements Phase 1 of the FlowPilot-First pivot — the core AI session
experience where engineers describe a problem and FlowPilot guides them
through structured diagnosis with selectable options, free-text escape
hatches, and auto-generated documentation on resolution.

Backend: AISession + AISessionStep models, FlowPilot Engine (LLM
orchestration with structured JSON output), Flow Matching Engine v1
(semantic + keyword + recency scoring), 8 API endpoints with auth,
rate limiting, and AI quota enforcement.

Frontend: Intake screen, conversational session view with sidebar,
step cards with options/actions/resolution suggestions, resolve/escalate
modals, documentation view with rating, session history integration,
and /pilot route with sidebar navigation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-18 14:27:36 +00:00
parent 44eb48e457
commit 5494816b06
29 changed files with 3647 additions and 5 deletions

View File

@@ -0,0 +1,129 @@
// ── Intake ──
export interface AISessionCreateRequest {
intake_type: 'free_text' | 'psa_ticket' | 'screenshot' | 'log_paste' | 'combined'
intake_content: Record<string, unknown>
psa_ticket_id?: string
psa_connection_id?: string
}
export interface AISessionCreateResponse {
session_id: string
status: string
confidence_tier: string
problem_summary: string | null
problem_domain: string | null
matched_flow_id: string | null
matched_flow_name: string | null
match_score: number | null
first_step: AISessionStepResponse
}
// ── Step interaction ──
export interface StepOptionSchema {
label: string
value: string
followup_hint: string | null
}
export interface AISessionStepResponse {
step_id: string
step_order: number
step_type: string
content: Record<string, unknown>
context_message: string | null
options: StepOptionSchema[]
allow_free_text: boolean
allow_skip: boolean
confidence_tier: string
confidence_score: number
}
export interface StepResponseRequest {
selected_option?: string | null
free_text_input?: string | null
was_skipped?: boolean
action_result?: Record<string, unknown> | null
}
export interface StepResponseResponse {
session_id: string
status: string
confidence_tier: string
confidence_score: number
next_step: AISessionStepResponse | null
resolution_suggested: boolean
resolution_summary: string | null
}
// ── Resolution / Escalation ──
export interface ResolveSessionRequest {
resolution_summary: string
resolution_action?: string | null
session_rating?: number | null
session_feedback?: string | null
}
export interface EscalateSessionRequest {
escalation_reason: string
escalated_to_id?: string | null
}
export interface DocumentationStep {
step_number: number
step_type: string
description: string
engineer_response: string | null
outcome: string | null
}
export interface SessionDocumentation {
problem_summary: string
problem_domain: string | null
intake_summary: string
diagnostic_steps: DocumentationStep[]
resolution_summary: string | null
escalation_reason: string | null
total_steps: number
duration_display: string | null
generated_at: string
}
export interface SessionCloseResponse {
session_id: string
status: string
documentation: SessionDocumentation
}
export interface RateSessionRequest {
rating: number
feedback?: string | null
}
// ── List / Detail ──
export interface AISessionSummary {
id: string
status: string
intake_type: string
problem_summary: string | null
problem_domain: string | null
confidence_tier: string
step_count: number
session_rating: number | null
created_at: string
resolved_at: string | null
}
export interface AISessionDetail extends AISessionSummary {
intake_content: Record<string, unknown>
matched_flow_id: string | null
match_score: number | null
resolution_summary: string | null
resolution_action: string | null
escalation_reason: string | null
session_feedback: string | null
steps: AISessionStepResponse[]
}

View File

@@ -12,6 +12,7 @@ export * from './admin'
export * from './analytics'
export * from './copilot'
export type { AssistantChat, AssistantChatMessage, ChatListItem, ChatMessageResponse, RetentionSettings } from './assistant-chat'
export * from './ai-session'
// API response wrapper types
export interface PaginatedResponse<T> {