Phase 2 of the FlowPilot-First Pivot connecting AI sessions to ConnectWise PSA: Slice 1 — PSA Ticket Intake: - FlowPilotEngine accepts psa_ticket intake with graceful CW API fallback - Ticket picker on intake screen (refactored TicketPickerModal for dual-mode) - Ticket context card in session sidebar Slice 2 — Auto Documentation Push: - PSA documentation service with resolution/escalation note formatting - Time entry creation via new ConnectWise provider method - Automatic retry scheduler (APScheduler, 5min interval, 3 retries) - PSA push status indicators in frontend with manual retry button - Member mapping warning when CW member not mapped Slice 3 — Session Pause/Resume & Escalation Handoff: - Pause/resume endpoints for same-engineer session bookmarking - Escalation flow: requesting_escalation status, self-escalation blocked - Enhanced escalation package with LLM-generated hypotheses/suggestions - Pickup endpoint with continue/fresh resume modes and briefing step - Escalation queue (sidebar nav + dedicated page) - SessionBriefing component with continue/fresh choice UI - EscalateModal with PSA-aware button text Slice 4 — Mid-Session Ticket Linking: - Link ticket retroactively with context injection into system prompt - Link Ticket button in session sidebar Slice 5 — FlowPilot PSA Settings: - Settings tab on IntegrationsPage with 7 configurable options - Stored as flowpilot_settings JSONB on PsaConnection Database: 2 migrations (flowpilot_settings, psa_post_log changes, status constraint) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
105 lines
3.4 KiB
TypeScript
105 lines
3.4 KiB
TypeScript
import apiClient from './client'
|
|
import type {
|
|
AISessionCreateRequest,
|
|
AISessionCreateResponse,
|
|
StepResponseRequest,
|
|
StepResponseResponse,
|
|
ResolveSessionRequest,
|
|
EscalateSessionRequest,
|
|
SessionCloseResponse,
|
|
SessionDocumentation,
|
|
AISessionSummary,
|
|
AISessionDetail,
|
|
PickupSessionRequest,
|
|
} from '@/types/ai-session'
|
|
|
|
export const aiSessionsApi = {
|
|
async createSession(data: AISessionCreateRequest): Promise<AISessionCreateResponse> {
|
|
const response = await apiClient.post<AISessionCreateResponse>('/ai-sessions', data)
|
|
return response.data
|
|
},
|
|
|
|
async respondToStep(sessionId: string, data: StepResponseRequest): Promise<StepResponseResponse> {
|
|
const response = await apiClient.post<StepResponseResponse>(
|
|
`/ai-sessions/${sessionId}/respond`,
|
|
data
|
|
)
|
|
return response.data
|
|
},
|
|
|
|
async resolveSession(sessionId: string, data: ResolveSessionRequest): Promise<SessionCloseResponse> {
|
|
const response = await apiClient.post<SessionCloseResponse>(
|
|
`/ai-sessions/${sessionId}/resolve`,
|
|
data
|
|
)
|
|
return response.data
|
|
},
|
|
|
|
async escalateSession(sessionId: string, data: EscalateSessionRequest): Promise<SessionCloseResponse> {
|
|
const response = await apiClient.post<SessionCloseResponse>(
|
|
`/ai-sessions/${sessionId}/escalate`,
|
|
data
|
|
)
|
|
return response.data
|
|
},
|
|
|
|
async listSessions(params?: { status?: string; skip?: number; limit?: number }): Promise<AISessionSummary[]> {
|
|
const response = await apiClient.get<AISessionSummary[]>('/ai-sessions', { params })
|
|
return response.data
|
|
},
|
|
|
|
async getSession(sessionId: string): Promise<AISessionDetail> {
|
|
const response = await apiClient.get<AISessionDetail>(`/ai-sessions/${sessionId}`)
|
|
return response.data
|
|
},
|
|
|
|
async getDocumentation(sessionId: string): Promise<SessionDocumentation> {
|
|
const response = await apiClient.get<SessionDocumentation>(
|
|
`/ai-sessions/${sessionId}/documentation`
|
|
)
|
|
return response.data
|
|
},
|
|
|
|
async rateSession(sessionId: string, data: { rating: number; feedback?: string }): Promise<void> {
|
|
await apiClient.post(`/ai-sessions/${sessionId}/rate`, data)
|
|
},
|
|
|
|
async retryPsaPush(sessionId: string): Promise<{ psa_push_status: string; psa_push_error: string | null }> {
|
|
const response = await apiClient.post<{ psa_push_status: string; psa_push_error: string | null }>(
|
|
`/ai-sessions/${sessionId}/retry-psa-push`
|
|
)
|
|
return response.data
|
|
},
|
|
|
|
async pauseSession(sessionId: string): Promise<void> {
|
|
await apiClient.post(`/ai-sessions/${sessionId}/pause`)
|
|
},
|
|
|
|
async resumeSession(sessionId: string): Promise<void> {
|
|
await apiClient.post(`/ai-sessions/${sessionId}/resume`)
|
|
},
|
|
|
|
async pickupSession(sessionId: string, data: PickupSessionRequest): Promise<StepResponseResponse> {
|
|
const response = await apiClient.post<StepResponseResponse>(
|
|
`/ai-sessions/${sessionId}/pickup`,
|
|
data
|
|
)
|
|
return response.data
|
|
},
|
|
|
|
async linkTicket(sessionId: string, data: { psa_ticket_id: string; psa_connection_id: string }): Promise<AISessionDetail> {
|
|
const response = await apiClient.post<AISessionDetail>(
|
|
`/ai-sessions/${sessionId}/link-ticket`,
|
|
data
|
|
)
|
|
return response.data
|
|
},
|
|
|
|
async getEscalationQueue(): Promise<AISessionSummary[]> {
|
|
const response = await apiClient.get<AISessionSummary[]>('/ai-sessions/escalation-queue')
|
|
return response.data
|
|
},
|
|
}
|
|
|
|
export default aiSessionsApi
|