/** * Interrupt Service * * Handles API interactions for Human-in-the-Loop (HITL) interrupts, * including fetching interrupt details, resolving interrupts with user * responses, and optional dedicated polling for interrupt status. * * @module services/interruptService */ import type { Interrupt, InterruptPollingConfig } from '../types/interrupt.js'; /** * Interrupt Service class * * Provides methods to interact with interrupt API endpoints including * fetching, resolving, cancelling, and listing interrupts. * Supports optional dedicated polling for interrupt status. */ export declare class InterruptService { private static instance; private pollingInterval; private pollingSessionId; private currentBackoff; private pollingConfig; /** * Private constructor for singleton pattern */ private constructor(); /** * Get the singleton instance of InterruptService * * @returns The InterruptService singleton instance */ static getInstance(): InterruptService; /** * Configure interrupt polling settings * * @param config - Polling configuration options */ setPollingConfig(config: Partial): void; /** * Get the current polling configuration * * @returns Current polling configuration */ getPollingConfig(): InterruptPollingConfig; /** * Check if interrupt endpoints are configured * * @returns True if interrupt endpoints are available */ isConfigured(): boolean; /** * Get the endpoint configuration * * @throws Error if endpoint configuration is not set * @returns The endpoint configuration */ private getConfig; /** * Generic API request helper * * @param url - The URL to fetch * @param options - Fetch options * @returns The parsed JSON response */ private request; /** * Get interrupt details by ID * * @param interruptId - The interrupt UUID * @returns The interrupt details */ getInterrupt(interruptId: string): Promise; /** * Resolve an interrupt with user response * * @param interruptId - The interrupt UUID * @param value - The user's response value * @returns The updated interrupt */ resolveInterrupt(interruptId: string, value: unknown): Promise; /** * Cancel a pending interrupt * * @param interruptId - The interrupt UUID * @returns The updated interrupt */ cancelInterrupt(interruptId: string): Promise; /** * List interrupts for a playground session * * @param sessionId - The session UUID * @returns Array of interrupts for the session */ listSessionInterrupts(sessionId: string): Promise; /** * List interrupts for a pipeline * * @param pipelineId - The pipeline UUID * @returns Array of interrupts for the pipeline */ listPipelineInterrupts(pipelineId: string): Promise; /** * Start polling for interrupts in a session * * This is optional - interrupts are typically detected via message metadata. * Use this for scenarios where dedicated polling is preferred. * * @param sessionId - The session UUID to poll * @param callback - Callback function to handle new interrupts */ startPolling(sessionId: string, callback: (interrupts: Interrupt[]) => void): void; /** * Stop polling for interrupts */ stopPolling(): void; /** * Check if polling is active * * @returns True if polling is active */ isPolling(): boolean; /** * Get the current polling session ID * * @returns The session ID being polled, or null */ getPollingSessionId(): string | null; } /** * Export singleton instance */ export declare const interruptService: InterruptService;